瀏覽代碼

use $wp_styles to add IE conditional comments to ie.css

Signed-off-by: Gabriel Luethje <gabriel@thefstopdesign.com>
Gabriel Luethje 13 年之前
父節點
當前提交
d4692ffb34
共有 1 個文件被更改,包括 4 次插入9 次删除
  1. 4 9
      library/bones.php

+ 4 - 9
library/bones.php

@@ -35,7 +35,6 @@ function bones_ahoy() {
     // enqueue base scripts and styles
     add_action('wp_enqueue_scripts', 'bones_scripts_and_styles', 999);
     // ie conditional wrapper
-    add_filter( 'style_loader_tag', 'bones_ie_conditional', 10, 2 );
 
     // launching this stuff after theme setup
     add_action('after_setup_theme','bones_theme_support');
@@ -122,6 +121,7 @@ SCRIPTS & ENQUEUEING
 
 // loading modernizr and jquery, and reply script
 function bones_scripts_and_styles() {
+  global $wp_styles; // call global $wp_styles variable so we can add condtional comments for ie.css the WordPress way
   if (!is_admin()) {
 
     // modernizr (without media query polyfill)
@@ -145,6 +145,9 @@ function bones_scripts_and_styles() {
     wp_enqueue_script( 'bones-modernizr' );
     wp_enqueue_style( 'bones-stylesheet' );
     wp_enqueue_style('bones-ie-only');
+
+    $wp_styles->add_data( 'bones-ie-only', 'conditional', 'lt IE 9' ); // add conditional comments for ie.css
+
     /*
     I recommend using a plugin to call jQuery
     using the google cdn. That way it stays cached
@@ -156,14 +159,6 @@ function bones_scripts_and_styles() {
   }
 }
 
-// adding the conditional wrapper around ie stylesheet
-// source: http://code.garyjones.co.uk/ie-conditional-style-sheets-wordpress/
-function bones_ie_conditional( $tag, $handle ) {
-	if ( 'bones-ie-only' == $handle )
-		$tag = '<!--[if lt IE 9]>' . "\n" . $tag . '<![endif]-->' . "\n";
-	return $tag;
-}
-
 /*********************
 THEME SUPPORT
 *********************/