The following column WordPress Tutorial will introduce to you how WordPress determines the browser. I hope it will be helpful to friends in need!
Most of the current theme templates do not support the obsolete IE, which affects the experience. You can use the variables provided by WordPress to determine the browser used by the visitor, and then remind the user to upgrade. browser.
For example, add in the appropriate position of the theme template:
<?php global $is_IE; if ($is_IE) { echo '您正在使用不安全的IE浏览器,请使用现代浏览器,浏览本站,以获得最佳体验!'; } ?>
When someone uses IE to access the web page, a prompt message will be displayed. When someone uses IE to access the WP backend, there will be a similar prompt.
If you want to target other browsers, you can refer to the following variables, and so on.
$is_iphone (boolean) iPhone Safari $is_chrome (boolean) Google Chrome $is_safari (boolean) Safari $is_NS4 (boolean) Netscape 4 $is_opera (boolean) Opera $is_macIE (boolean) Mac Internet Explorer $is_winIE (boolean) Windows Internet Explorer $is_gecko (boolean) FireFox $is_lynx (boolean) $is_IE (boolean) Internet Explorer $is_edge (boolean) Microsoft Edge
Source code: https://codex.wordpress.org/Global_Variables
The above is the detailed content of How WordPress determines the browser. For more information, please follow other related articles on the PHP Chinese website!