Home  >  Article  >  CMS Tutorial  >  How WordPress determines the browser

How WordPress determines the browser

藏色散人
藏色散人forward
2020-12-18 15:27:392577browse

The following column WordPress Tutorial will introduce to you how WordPress determines the browser. I hope it will be helpful to friends in need!

How WordPress determines the browser

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 &#39;您正在使用不安全的IE浏览器,请使用现代浏览器,浏览本站,以获得最佳体验!&#39;;
}
?>

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!

Statement:
This article is reproduced at:zmingcx.com. If there is any infringement, please contact admin@php.cn delete