| [ XREF Home ] [ Index ] |
PHP Cross Reference of WordPress TrunkProvided by Yoast |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Creates common globals for the rest of WordPress 4 * 5 * Sets $pagenow global which is the current page. Checks 6 * for the browser to set which one is currently being used. 7 * 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. 11 * 12 * @package WordPress 13 */ 14 15 // On which page are we ? 16 if ( is_admin() ) { 17 // wp-admin pages are checked more carefully 18 if ( is_network_admin() ) 19 preg_match('#/wp-admin/network/?(.*?)$#i', $PHP_SELF, $self_matches); 20 elseif ( is_user_admin() ) 21 preg_match('#/wp-admin/user/?(.*?)$#i', $PHP_SELF, $self_matches); 22 else 23 preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches); 24 $pagenow = $self_matches[1]; 25 $pagenow = trim($pagenow, '/'); 26 $pagenow = preg_replace('#\?.*?$#', '', $pagenow); 27 if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { 28 $pagenow = 'index.php'; 29 } else { 30 preg_match('#(.*?)(/|$)#', $pagenow, $self_matches); 31 $pagenow = strtolower($self_matches[1]); 32 if ( '.php' !== substr($pagenow, -4, 4) ) 33 $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) 34 } 35 } else { 36 if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $PHP_SELF, $self_matches) ) 37 $pagenow = strtolower($self_matches[1]); 38 else 39 $pagenow = 'index.php'; 40 } 41 unset($self_matches); 42 43 // Simple browser detection 44 $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false; 45 46 if ( isset($_SERVER['HTTP_USER_AGENT']) ) { 47 if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) { 48 $is_lynx = true; 49 } elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'chrome') !== false ) { 50 if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) { 51 if ( $is_chrome = apply_filters( 'use_google_chrome_frame', is_admin() ) ) 52 header( 'X-UA-Compatible: chrome=1' ); 53 $is_winIE = ! $is_chrome; 54 } else { 55 $is_chrome = true; 56 } 57 } elseif ( stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false ) { 58 $is_safari = true; 59 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ) { 60 $is_gecko = true; 61 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false ) { 62 $is_winIE = true; 63 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false ) { 64 $is_macIE = true; 65 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ) { 66 $is_opera = true; 67 } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false ) { 68 $is_NS4 = true; 69 } 70 } 71 72 if ( $is_safari && stripos($_SERVER['HTTP_USER_AGENT'], 'mobile') !== false ) 73 $is_iphone = true; 74 75 $is_IE = ( $is_macIE || $is_winIE ); 76 77 // Server detection 78 79 /** 80 * Whether the server software is Apache or something else 81 * @global bool $is_apache 82 */ 83 $is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false); 84 85 /** 86 * Whether the server software is IIS or something else 87 * @global bool $is_IIS 88 */ 89 $is_IIS = !$is_apache && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false); 90 91 /** 92 * Whether the server software is IIS 7.X 93 * @global bool $is_iis7 94 */ 95 $is_iis7 = $is_IIS && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false); 96 97 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jun 1 08:30:02 2011 |
Cross-referenced by PHPXref 0.7 Provided by Yoast and awesome WordPress Hosting |