Преглед на файлове

Seedlet: Use WordPress global to detect IE support (#2387)

Noah Allen преди 4 години
родител
ревизия
de000ad8a7
променени са 1 файла, в които са добавени 10 реда и са изтрити 10 реда
  1. 10 10
      seedlet/functions.php

+ 10 - 10
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 {