Changeset 42343 for trunk/src/wp-includes/vars.php
- Timestamp:
- 11/30/2017 11:09:33 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/vars.php
r42201 r42343 23 23 if ( is_admin() ) { 24 24 // wp-admin pages are checked more carefully 25 if ( is_network_admin() ) 26 preg_match('#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches); 27 elseif ( is_user_admin() ) 28 preg_match('#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches); 29 else 30 preg_match('#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches); 25 if ( is_network_admin() ) { 26 preg_match( '#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); 27 } elseif ( is_user_admin() ) { 28 preg_match( '#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); 29 } else { 30 preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); 31 } 31 32 $pagenow = $self_matches[1]; 32 $pagenow = trim( $pagenow, '/');33 $pagenow = preg_replace( '#\?.*?$#', '', $pagenow);33 $pagenow = trim( $pagenow, '/' ); 34 $pagenow = preg_replace( '#\?.*?$#', '', $pagenow ); 34 35 if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { 35 36 $pagenow = 'index.php'; 36 37 } else { 37 preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches);38 $pagenow = strtolower( $self_matches[1]);39 if ( '.php' !== substr( $pagenow, -4, 4) )38 preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches ); 39 $pagenow = strtolower( $self_matches[1] ); 40 if ( '.php' !== substr( $pagenow, -4, 4 ) ) { 40 41 $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) 42 } 41 43 } 42 44 } else { 43 if ( preg_match( '#([^/]+\.php)([?/].*?)?$#i', $_SERVER['PHP_SELF'], $self_matches) )44 $pagenow = strtolower( $self_matches[1]);45 else45 if ( preg_match( '#([^/]+\.php)([?/].*?)?$#i', $_SERVER['PHP_SELF'], $self_matches ) ) { 46 $pagenow = strtolower( $self_matches[1] ); 47 } else { 46 48 $pagenow = 'index.php'; 49 } 47 50 } 48 unset( $self_matches);51 unset( $self_matches ); 49 52 50 53 // Simple browser detection 51 54 $is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = $is_edge = false; 52 55 53 if ( isset( $_SERVER['HTTP_USER_AGENT']) ) {54 if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false ) {56 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { 57 if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Lynx' ) !== false ) { 55 58 $is_lynx = true; 56 59 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Edge' ) !== false ) { 57 60 $is_edge = true; 58 } elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chrome') !== false ) {61 } elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chrome' ) !== false ) { 59 62 if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) { 60 63 $is_admin = is_admin(); … … 66 69 * @param bool $is_admin Whether to use the Google Chrome Frame. Default is the value of is_admin(). 67 70 */ 68 if ( $is_chrome = apply_filters( 'use_google_chrome_frame', $is_admin ) ) 71 if ( $is_chrome = apply_filters( 'use_google_chrome_frame', $is_admin ) ) { 69 72 header( 'X-UA-Compatible: chrome=1' ); 73 } 70 74 $is_winIE = ! $is_chrome; 71 75 } else { 72 76 $is_chrome = true; 73 77 } 74 } elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'safari') !== false ) {78 } elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'safari' ) !== false ) { 75 79 $is_safari = true; 76 } elseif ( ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false ) && strpos($_SERVER['HTTP_USER_AGENT'], 'Win') !== false ) {80 } elseif ( ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident' ) !== false ) && strpos( $_SERVER['HTTP_USER_AGENT'], 'Win' ) !== false ) { 77 81 $is_winIE = true; 78 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false ) {82 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false && strpos( $_SERVER['HTTP_USER_AGENT'], 'Mac' ) !== false ) { 79 83 $is_macIE = true; 80 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false ) {84 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Gecko' ) !== false ) { 81 85 $is_gecko = true; 82 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera') !== false ) {86 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera' ) !== false ) { 83 87 $is_opera = true; 84 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false ) {88 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Nav' ) !== false && strpos( $_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.' ) !== false ) { 85 89 $is_NS4 = true; 86 90 } 87 91 } 88 92 89 if ( $is_safari && stripos( $_SERVER['HTTP_USER_AGENT'], 'mobile') !== false )93 if ( $is_safari && stripos( $_SERVER['HTTP_USER_AGENT'], 'mobile' ) !== false ) { 90 94 $is_iphone = true; 95 } 91 96 92 97 $is_IE = ( $is_macIE || $is_winIE ); … … 96 101 /** 97 102 * Whether the server software is Apache or something else 103 * 98 104 * @global bool $is_apache 99 105 */ 100 $is_apache = ( strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);106 $is_apache = ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Apache' ) !== false || strpos( $_SERVER['SERVER_SOFTWARE'], 'LiteSpeed' ) !== false ); 101 107 102 108 /** 103 109 * Whether the server software is Nginx or something else 110 * 104 111 * @global bool $is_nginx 105 112 */ 106 $is_nginx = ( strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false);113 $is_nginx = ( strpos( $_SERVER['SERVER_SOFTWARE'], 'nginx' ) !== false ); 107 114 108 115 /** 109 116 * Whether the server software is IIS or something else 117 * 110 118 * @global bool $is_IIS 111 119 */ 112 $is_IIS = ! $is_apache && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false);120 $is_IIS = ! $is_apache && ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) !== false || strpos( $_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer' ) !== false ); 113 121 114 122 /** 115 123 * Whether the server software is IIS 7.X or greater 124 * 116 125 * @global bool $is_iis7 117 126 */ … … 122 131 * 123 132 * @since 3.4.0 124 * 133 * 125 134 * @return bool 126 135 */ 127 136 function wp_is_mobile() { 128 if ( empty( $_SERVER['HTTP_USER_AGENT']) ) {137 if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { 129 138 $is_mobile = false; 130 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.)131 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Android') !== false132 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false133 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false134 || strpos( $_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false135 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false136 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !== false ) {139 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Mobile' ) !== false // many mobile devices (all iPhone, iPad, etc.) 140 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Android' ) !== false 141 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Silk/' ) !== false 142 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Kindle' ) !== false 143 || strpos( $_SERVER['HTTP_USER_AGENT'], 'BlackBerry' ) !== false 144 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mini' ) !== false 145 || strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mobi' ) !== false ) { 137 146 $is_mobile = true; 138 147 } else {
Note: See TracChangeset
for help on using the changeset viewer.