3 * Creates common globals for the rest of WordPress
5 * Sets $pagenow global which is the current page. Checks
6 * for the browser to set which one is currently being used.
8 * Detects which user environment WordPress is being used on.
9 * Only attempts to check for Apache and IIS. Two web servers
10 * with known permalink capability.
16 $is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $is_IE,
17 $is_apache, $is_IIS, $is_iis7;
19 // On which page are we ?
21 // wp-admin pages are checked more carefully
22 if ( is_network_admin() )
23 preg_match('#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches);
24 elseif ( is_user_admin() )
25 preg_match('#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches);
27 preg_match('#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches);
28 $pagenow = $self_matches[1];
29 $pagenow = trim($pagenow, '/');
30 $pagenow = preg_replace('#\?.*?$#', '', $pagenow);
31 if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) {
32 $pagenow = 'index.php';
34 preg_match('#(.*?)(/|$)#', $pagenow, $self_matches);
35 $pagenow = strtolower($self_matches[1]);
36 if ( '.php' !== substr($pagenow, -4, 4) )
37 $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried)
40 if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $_SERVER['PHP_SELF'], $self_matches) )
41 $pagenow = strtolower($self_matches[1]);
43 $pagenow = 'index.php';
47 // Simple browser detection
48 $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;
50 if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
51 if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) {
53 } elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'chrome') !== false ) {
54 if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) {
55 if ( $is_chrome = apply_filters( 'use_google_chrome_frame', is_admin() ) )
56 header( 'X-UA-Compatible: chrome=1' );
57 $is_winIE = ! $is_chrome;
61 } elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false ) {
63 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ) {
65 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false ) {
67 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false ) {
69 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ) {
71 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false ) {
76 if ( $is_safari && stripos($_SERVER['HTTP_USER_AGENT'], 'mobile') !== false )
79 $is_IE = ( $is_macIE || $is_winIE );
84 * Whether the server software is Apache or something else
85 * @global bool $is_apache
87 $is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);
90 * Whether the server software is IIS or something else
91 * @global bool $is_IIS
93 $is_IIS = !$is_apache && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false);
96 * Whether the server software is IIS 7.X
97 * @global bool $is_iis7
99 $is_iis7 = $is_IIS && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);