mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Creates common globals for the rest of WordPress
mp-wp_genesis 4 *
mp-wp_genesis 5 * Sets $pagenow global which is the current page. Checks
mp-wp_genesis 6 * for the browser to set which one is currently being used.
mp-wp_genesis 7 *
mp-wp_genesis 8 * Detects which user environment WordPress is being used on.
mp-wp_genesis 9 * Only attempts to check for Apache and IIS. Two web servers
mp-wp_genesis 10 * with known permalink capability.
mp-wp_genesis 11 *
mp-wp_genesis 12 * @package WordPress
mp-wp_genesis 13 */
mp-wp_genesis 14
mp-wp_genesis 15 // On which page are we ?
mp-wp_genesis 16 if ( is_admin() ) {
mp-wp_genesis 17 // wp-admin pages are checked more carefully
mp-wp_genesis 18 preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches);
mp-wp_genesis 19 $pagenow = $self_matches[1];
mp-wp_genesis 20 $pagenow = preg_replace('#\?.*?$#', '', $pagenow);
mp-wp_genesis 21 if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) {
mp-wp_genesis 22 $pagenow = 'index.php';
mp-wp_genesis 23 } else {
mp-wp_genesis 24 preg_match('#(.*?)(/|$)#', $pagenow, $self_matches);
mp-wp_genesis 25 $pagenow = strtolower($self_matches[1]);
mp-wp_genesis 26 if ( '.php' !== substr($pagenow, -4, 4) )
mp-wp_genesis 27 $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried)
mp-wp_genesis 28 }
mp-wp_genesis 29 } else {
mp-wp_genesis 30 if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $PHP_SELF, $self_matches) )
mp-wp_genesis 31 $pagenow = strtolower($self_matches[1]);
mp-wp_genesis 32 else
mp-wp_genesis 33 $pagenow = 'index.php';
mp-wp_genesis 34 }
mp-wp_genesis 35
mp-wp_genesis 36 // Simple browser detection
mp-wp_genesis 37 $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;
mp-wp_genesis 38
mp-wp_genesis 39 if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) {
mp-wp_genesis 40 $is_lynx = true;
mp-wp_genesis 41 } elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) {
mp-wp_genesis 42 $is_chrome = true;
mp-wp_genesis 43 } elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false ) {
mp-wp_genesis 44 $is_safari = true;
mp-wp_genesis 45 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) {
mp-wp_genesis 46 $is_gecko = true;
mp-wp_genesis 47 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false) {
mp-wp_genesis 48 $is_winIE = true;
mp-wp_genesis 49 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
mp-wp_genesis 50 $is_macIE = true;
mp-wp_genesis 51 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) {
mp-wp_genesis 52 $is_opera = true;
mp-wp_genesis 53 } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false) {
mp-wp_genesis 54 $is_NS4 = true;
mp-wp_genesis 55 }
mp-wp_genesis 56
mp-wp_genesis 57 if ( $is_safari && strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') !== false )
mp-wp_genesis 58 $is_iphone = true;
mp-wp_genesis 59
mp-wp_genesis 60 $is_IE = ( $is_macIE || $is_winIE );
mp-wp_genesis 61
mp-wp_genesis 62 // Server detection
mp-wp_genesis 63
mp-wp_genesis 64 /**
mp-wp_genesis 65 * Whether the server software is Apache or something else
mp-wp_genesis 66 * @global bool $is_apache
mp-wp_genesis 67 */
mp-wp_genesis 68 $is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false;
mp-wp_genesis 69
mp-wp_genesis 70 /**
mp-wp_genesis 71 * Whether the server software is IIS or something else
mp-wp_genesis 72 * @global bool $is_IIS
mp-wp_genesis 73 */
mp-wp_genesis 74 $is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false;
mp-wp_genesis 75
mp-wp_genesis 76 ?>