php - Enqueueing IE conditional stylesheets in WordPress correctly -
i've been trying follow tutorial shows how correctly enqueue stylesheets in wordpress functions folder, , how set internet explorer stylesheets overwrite/ add necessary components compatibility older browsers. there 2 methods of doing tutorial, second of update first method, has since become outdated.
here's link: https://gist.github.com/wpscholar/4947518
the first method uses global styles, , can 1 work using code below:
function enqueue_my_styles_and_scripts() { global $wp_styles; if (is_page_template('page-templates/full-page.php')) { wp_enqueue_style( 'theme-full-page' , get_template_directory_uri() . '/css/full-page.css'); } else { wp_enqueue_style( 'theme_style', get_stylesheet_uri() ); wp_enqueue_style( 'theme_style_ie8', get_stylesheet_directory_uri() . '/css/ie8.css', array( 'theme_style' ) ); $wp_styles->add_data( 'theme_style_ie8', 'conditional', 'ie 8' ); wp_enqueue_style( 'theme_style_ie9', get_stylesheet_directory_uri() . '/css/ie9.css', array( 'theme_style' ) ); $wp_styles->add_data( 'theme_style_ie9', 'conditional', 'ie 9' ); } } add_action( 'wp_enqueue_scripts', 'enqueue_my_styles_and_scripts' );
the second method uses wp_styles. article states former method outdated , second method best way it. i've followed part of tutorial , came with. reason ignores i.e stylesheets, , i'm not sure why. on appreciated i'd rather use up-to-date method rather old 1 potentially cause issues later. can see might problem code?
function enqueue_my_styles_and_scripts() { if (is_page_template('page-templates/full-page.php')) { wp_enqueue_style( 'theme-full-page' , get_template_directory_uri() . '/css/full-page.css'); } else { wp_enqueue_style( 'theme_style', get_stylesheet_uri() ); wp_enqueue_style( 'theme_style_ie8', get_stylesheet_directory_uri() . '/css/ie8.css', array( 'theme_style' ) ); wp_style_add_data( 'theme_style_ie8', 'conditional', 'lt ie 8' ); wp_enqueue_style( 'theme_style_ie9', get_stylesheet_directory_uri() . '/css/ie9.css', array( 'theme_style' ) ); wp_style_add_data( 'theme_style_ie9', 'conditional', 'lt ie 9' ); } } add_action( 'wp_enqueue_scripts', 'enqueue_my_styles_and_scripts' );
Comments
Post a Comment