diff --git a/src/wp-includes/class.wp-styles.php b/src/wp-includes/class.wp-styles.php index eb160670ca..46cb913bd3 100644 --- a/src/wp-includes/class.wp-styles.php +++ b/src/wp-includes/class.wp-styles.php @@ -107,17 +107,24 @@ class WP_Styles extends WP_Dependencies { } } - if ( isset($obj->extra['conditional']) && $obj->extra['conditional'] ) { - $tag = "\n"; + $conditional_pre = $conditional_post = ''; + if ( isset( $obj->extra['conditional'] ) && $obj->extra['conditional'] ) { + $conditional_pre = "\n"; } if ( $this->do_concat ) { + $this->print_html .= $conditional_pre; $this->print_html .= $tag; - if ( $inline_style = $this->print_inline_style( $handle, false ) ) + if ( $inline_style = $this->print_inline_style( $handle, false ) ) { $this->print_html .= sprintf( "\n", esc_attr( $handle ), $inline_style ); + } + $this->print_html .= $conditional_post; } else { + echo $conditional_pre; echo $tag; $this->print_inline_style( $handle ); + echo $conditional_post; } return true; diff --git a/tests/phpunit/tests/dependencies/styles.php b/tests/phpunit/tests/dependencies/styles.php index b576b20371..6788d8af9f 100644 --- a/tests/phpunit/tests/dependencies/styles.php +++ b/tests/phpunit/tests/dependencies/styles.php @@ -96,7 +96,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase { $style = ".thing {\n"; $style .= "\tbackground: red;\n"; $style .= "}"; - + $expected = "\n"; $expected .= " + + +CSS; + wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); + wp_style_add_data( 'handle', 'conditional', 'IE' ); + wp_add_inline_style( 'handle', 'a { color: blue; }' ); + + $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); + } + }