Revert [25202] and enforce that wp_add_inline_style() does not want <style> tags.
Prior to 3.7, these tags were not printed (and thus needed to be provided), but only in the admin and when concatenation was enabled. They should never be required. Strip them when we find them and issue a notice for incorrect usage. props atimmer, georgestephanis. fixes #24813. Built from https://develop.svn.wordpress.org/trunk@25786 git-svn-id: http://core.svn.wordpress.org/trunk@25698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7b0088c938
commit
f9be8e4f0c
|
@ -87,10 +87,11 @@ class WP_Styles extends WP_Dependencies {
|
|||
|
||||
if ( $this->do_concat ) {
|
||||
$this->print_html .= $tag;
|
||||
$this->print_html .= $this->print_inline_style( $handle, false );
|
||||
if ( $inline_style = $this->print_inline_style( $handle, false ) )
|
||||
$this->print_html .= sprintf( "<style type='text/css'>\n%s\n</style>\n", $inline_style );
|
||||
} else {
|
||||
echo $tag;
|
||||
echo $this->print_inline_style( $handle, false );
|
||||
$this->print_inline_style( $handle );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* Passing an empty array to $handles prints the queue,
|
||||
* passing an array with one string prints that style,
|
||||
* and passing an array of strings prints those styles.
|
||||
*
|
||||
*
|
||||
* @see do_action() Calls 'wp_print_styles' hook.
|
||||
* @global WP_Styles $wp_styles The WP_Styles object for printing styles.
|
||||
*
|
||||
|
@ -71,6 +71,11 @@ function wp_add_inline_style( $handle, $data ) {
|
|||
$wp_styles = new WP_Styles();
|
||||
}
|
||||
|
||||
if ( false !== stripos( $data, '</style>' ) ) {
|
||||
_doing_it_wrong( __FUNCTION__, 'Do not pass <style> tags to wp_add_inline_style()', '3.7' );
|
||||
$data = trim( preg_replace( '#<style[^>]*>(.*)</style>#is', '$1', $data ) );
|
||||
}
|
||||
|
||||
return $wp_styles->add_inline_style( $handle, $data );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue