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

This commit is contained in:
Noah Allen 2020-08-31 11:28:07 -07:00 committed by GitHub
parent 017e6f2572
commit de000ad8a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {