From de000ad8a70870877c5fe07f1acd8b3f2b5d7d7e Mon Sep 17 00:00:00 2001 From: Noah Allen Date: Mon, 31 Aug 2020 11:28:07 -0700 Subject: [PATCH] Seedlet: Use WordPress global to detect IE support (#2387) --- seedlet/functions.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/seedlet/functions.php b/seedlet/functions.php index 24066f5a3..433635488 100755 --- a/seedlet/functions.php +++ b/seedlet/functions.php @@ -16,14 +16,6 @@ if ( version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) { return; } -/** - * Determine whether the site is being requested from IE. - */ -$is_ie = false; -if ( preg_match( '~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false ) ) { - $is_ie = true; -} - if ( ! function_exists( 'seedlet_setup' ) ) : /** * Sets up theme defaults and registers support for various WordPress features. @@ -114,7 +106,11 @@ if ( ! function_exists( 'seedlet_setup' ) ) : add_theme_support( 'editor-styles' ); $editor_stylesheet_path = './assets/css/style-editor.css'; - if ( $is_ie ) { + + // Note, the is_IE global variable is defined by WordPress and is used + // to detect if the current browser is internet explorer. + global $is_IE; + if ( $is_IE ) { $editor_stylesheet_path = './assets/css/ie-editor.css'; } @@ -369,7 +365,11 @@ function seedlet_scripts() { wp_enqueue_style( 'seedlet-fonts', seedlet_fonts_url(), array(), null ); // Theme styles - if ( $is_ie ) { + + // Note, the is_IE global variable is defined by WordPress and is used + // to detect if the current browser is internet explorer. + global $is_IE; + if ( $is_IE ) { // If IE 11 or below, use a flattened stylesheet with static values replacing CSS Variables wp_enqueue_style( 'seedlet-style', get_template_directory_uri() . '/assets/css/ie.css', array(), wp_get_theme()->get( 'Version' ) ); } else {