From 021e23e70b239bd459a631cac7e37827b83806db Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 31 Aug 2016 06:42:33 +0000 Subject: [PATCH] General: use a new function, `wp_is_IE()`, instead of the `$is_IE` global in a number of places. See #37699. Built from https://develop.svn.wordpress.org/trunk@38467 git-svn-id: http://core.svn.wordpress.org/trunk@38408 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/edit-form-advanced.php | 2 +- wp-admin/includes/class-wp-press-this.php | 3 +-- wp-admin/includes/media.php | 3 +-- wp-admin/includes/template.php | 9 ++------- wp-includes/class-wp-admin-bar.php | 13 +++++-------- wp-includes/general-template.php | 5 ++--- wp-includes/link-template.php | 6 +----- wp-includes/media-template.php | 6 ++---- wp-includes/vars.php | 12 ++++++++++++ wp-includes/version.php | 2 +- 10 files changed, 28 insertions(+), 33 deletions(-) diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 75c3cef2f2..0a6b50d6ad 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -30,7 +30,7 @@ $_wp_editor_expand = $_content_editor_dfw = false; * @param string $post_type Post type. */ if ( post_type_supports( $post_type, 'editor' ) && ! wp_is_mobile() && - ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) && + ! ( wp_is_IE() && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) && apply_filters( 'wp_editor_expand', true, $post_type ) ) { wp_enqueue_script('editor-expand'); diff --git a/wp-admin/includes/class-wp-press-this.php b/wp-admin/includes/class-wp-press-this.php index 3ff242bed8..c8e78a23d1 100644 --- a/wp-admin/includes/class-wp-press-this.php +++ b/wp-admin/includes/class-wp-press-this.php @@ -1187,7 +1187,6 @@ class WP_Press_This { * @access public * * @global WP_Locale $wp_locale - * @global bool $is_IE */ public function html() { global $wp_locale; @@ -1227,7 +1226,7 @@ class WP_Press_This { add_filter( 'mce_css', array( $this, 'add_editor_style' ) ); - if ( ! empty( $GLOBALS['is_IE'] ) ) { + if ( wp_is_IE() ) { @header( 'X-UA-Compatible: IE=edge' ); } diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 63807f71de..140d03a0ec 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -1783,13 +1783,12 @@ function media_upload_header() { * * @global string $type * @global string $tab - * @global bool $is_IE * @global bool $is_opera * * @param array $errors */ function media_upload_form( $errors = null ) { - global $type, $tab, $is_IE, $is_opera; + global $type, $tab, $is_opera; if ( ! _device_can_upload() ) { echo '

' . sprintf( __('The web browser on your device cannot be used to upload files. You may be able to use the native app for your device instead.'), 'https://apps.wordpress.org/' ) . '

'; diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index dce84fc43a..18284a0799 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1945,17 +1945,12 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit return $button; } -/** - * - * @global bool $is_IE - */ function _wp_admin_html_begin() { - global $is_IE; - $admin_html_class = ( is_admin_bar_showing() ) ? 'wp-toolbar' : ''; - if ( $is_IE ) + if ( wp_is_IE() ) { @header('X-UA-Compatible: IE=edge'); + } ?> diff --git a/wp-includes/class-wp-admin-bar.php b/wp-includes/class-wp-admin-bar.php index 49986ac225..4b42527b06 100644 --- a/wp-includes/class-wp-admin-bar.php +++ b/wp-includes/class-wp-admin-bar.php @@ -391,23 +391,20 @@ class WP_Admin_Bar { } /** - * - * @global bool $is_IE * @param object $root */ final protected function _render( $root ) { - global $is_IE; - // Add browser classes. // We have to do this here since admin bar shows on the front end. $class = 'nojq nojs'; - if ( $is_IE ) { - if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) + if ( wp_is_IE() ) { + if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) { $class .= ' ie7'; - elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) + } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) { $class .= ' ie8'; - elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) ) + } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) ) { $class .= ' ie9'; + } } elseif ( wp_is_mobile() ) { $class .= ' mobile'; } diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 7a056412d5..9cacf229f4 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -2904,12 +2904,11 @@ function wp_dependencies_unique_hosts() { * @global bool $is_opera * @global bool $is_safari * @global bool $is_chrome - * @global bool $is_IE * * @return bool */ function user_can_richedit() { - global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge; + global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_edge; if ( !isset($wp_rich_edit) ) { $wp_rich_edit = false; @@ -2917,7 +2916,7 @@ function user_can_richedit() { if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users if ( $is_safari ) { $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 ); - } elseif ( $is_gecko || $is_chrome || $is_IE || $is_edge || ( $is_opera && !wp_is_mobile() ) ) { + } elseif ( $is_gecko || $is_chrome || wp_is_IE() || $is_edge || ( $is_opera && !wp_is_mobile() ) ) { $wp_rich_edit = true; } } diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 0460a3284d..b218d78ff8 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -2896,15 +2896,11 @@ function the_comments_pagination( $args = array() ) { * Retrieves the Press This bookmarklet link. * * @since 2.6.0 - * - * @global bool $is_IE Whether the browser matches an Internet Explorer user agent. */ function get_shortcut_link() { - global $is_IE; - $link = ''; - if ( $is_IE ) { + if ( wp_is_IE() ) { /* * Return the old/shorter bookmarklet code for MSIE 8 and lower, * since they only support a max length of ~2000 characters for diff --git a/wp-includes/media-template.php b/wp-includes/media-template.php index c6699216e9..22d1e4feb1 100644 --- a/wp-includes/media-template.php +++ b/wp-includes/media-template.php @@ -133,14 +133,12 @@ function wp_underscore_video_template() { * Prints the templates used in the media manager. * * @since 3.5.0 - * - * @global bool $is_IE */ function wp_print_media_templates() { - global $is_IE; $class = 'media-modal wp-core-ui'; - if ( $is_IE && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false ) + if ( wp_is_IE() && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false ) { $class .= ' ie7'; + } ?>