1 <?php |
1 <?php |
2 /** |
2 /** |
3 * Creates common globals for the rest of WordPress |
3 * Creates common globals for the rest of WordPress |
4 * |
4 * |
5 * Sets $pagenow global which is the current page. Checks |
5 * Sets $pagenow global which is the filename of the current screen. |
6 * for the browser to set which one is currently being used. |
6 * Checks for the browser to set which one is currently being used. |
7 * |
7 * |
8 * Detects which user environment WordPress is being used on. |
8 * Detects which user environment WordPress is being used on. |
9 * Only attempts to check for Apache, Nginx and IIS -- three web |
9 * Only attempts to check for Apache, Nginx and IIS -- three web |
10 * servers with known pretty permalink capability. |
10 * servers with known pretty permalink capability. |
11 * |
11 * |
27 } elseif ( is_user_admin() ) { |
27 } elseif ( is_user_admin() ) { |
28 preg_match( '#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); |
28 preg_match( '#/wp-admin/user/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); |
29 } else { |
29 } else { |
30 preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); |
30 preg_match( '#/wp-admin/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); |
31 } |
31 } |
32 $pagenow = $self_matches[1]; |
32 |
|
33 $pagenow = ! empty( $self_matches[1] ) ? $self_matches[1] : ''; |
33 $pagenow = trim( $pagenow, '/' ); |
34 $pagenow = trim( $pagenow, '/' ); |
34 $pagenow = preg_replace( '#\?.*?$#', '', $pagenow ); |
35 $pagenow = preg_replace( '#\?.*?$#', '', $pagenow ); |
|
36 |
35 if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { |
37 if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { |
36 $pagenow = 'index.php'; |
38 $pagenow = 'index.php'; |
37 } else { |
39 } else { |
38 preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches ); |
40 preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches ); |
39 $pagenow = strtolower( $self_matches[1] ); |
41 $pagenow = strtolower( $self_matches[1] ); |
63 $is_edge = false; |
65 $is_edge = false; |
64 |
66 |
65 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { |
67 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { |
66 if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Lynx' ) !== false ) { |
68 if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Lynx' ) !== false ) { |
67 $is_lynx = true; |
69 $is_lynx = true; |
68 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Edge' ) !== false ) { |
70 } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Edg' ) !== false ) { |
69 $is_edge = true; |
71 $is_edge = true; |
70 } elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chrome' ) !== false ) { |
72 } elseif ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chrome' ) !== false ) { |
71 if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) { |
73 if ( stripos( $_SERVER['HTTP_USER_AGENT'], 'chromeframe' ) !== false ) { |
72 $is_admin = is_admin(); |
74 $is_admin = is_admin(); |
73 /** |
75 /** |