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.
15 // On which page are we ?
17 // wp-admin pages are checked more carefully
18 preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches);
19 $pagenow = $self_matches[1];
20 $pagenow = preg_replace('#\?.*?$#', '', $pagenow);
21 if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) {
22 $pagenow = 'index.php';
24 preg_match('#(.*?)(/|$)#', $pagenow, $self_matches);
25 $pagenow = strtolower($self_matches[1]);
26 if ( '.php' !== substr($pagenow, -4, 4) )
27 $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried)
30 if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $PHP_SELF, $self_matches) )
31 $pagenow = strtolower($self_matches[1]);
33 $pagenow = 'index.php';
36 // Simple browser detection
37 $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;
39 if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) {
41 } elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) {
43 } elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false ) {
45 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) {
47 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false) {
49 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
51 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) {
53 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false) {
57 if ( $is_safari && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') !== false )
60 $is_IE = ( $is_macIE || $is_winIE );
65 * Whether the server software is Apache or something else
66 * @global bool $is_apache
68 $is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);
71 * Whether the server software is IIS or something else
72 * @global bool $is_IIS
74 $is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false);
77 * Whether the server software is IIS 7.X
78 * @global bool $is_iis7
80 $is_iis7 = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);