mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-06 15:47:05 +00:00
Script/Style Dependencies: Make sure that inline styles for handles without a source are printed.
This prevents breaking plugins which are adding inline styles to the `wp-admin` handle after [36341]. Props dd32, ocean90. Fixes #35229. git-svn-id: https://develop.svn.wordpress.org/trunk@36550 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -166,4 +166,20 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase {
|
||||
$this->assertFalse( wp_register_script( 'duplicate-handler', 'http://example.com' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35229
|
||||
*/
|
||||
function test_wp_register_script_with_handle_without_source() {
|
||||
$expected = "<script type='text/javascript' src='http://example.com?ver=1'></script>\n";
|
||||
$expected .= "<script type='text/javascript' src='http://example.com?ver=2'></script>\n";
|
||||
|
||||
wp_register_script( 'handle-one', 'http://example.com', array(), 1 );
|
||||
wp_register_script( 'handle-two', 'http://example.com', array(), 2 );
|
||||
wp_register_script( 'handle-three', false, array( 'handle-one', 'handle-two' ) );
|
||||
|
||||
wp_enqueue_script( 'handle-three' );
|
||||
|
||||
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -234,9 +234,31 @@ CSS;
|
||||
*
|
||||
* @ticket 31126
|
||||
*/
|
||||
function test_wp_register_style(){
|
||||
function test_wp_register_style() {
|
||||
$this->assertTrue( wp_register_style( 'duplicate-handler', 'http://example.com' ) );
|
||||
$this->assertFalse( wp_register_style( 'duplicate-handler', 'http://example.com' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 35229
|
||||
*/
|
||||
function test_wp_add_inline_style_for_handle_without_source() {
|
||||
$style = "a { color: blue; }";
|
||||
|
||||
$expected = "<link rel='stylesheet' id='handle-one-css' href='http://example.com?ver=1' type='text/css' media='all' />\n";
|
||||
$expected .= "<link rel='stylesheet' id='handle-two-css' href='http://example.com?ver=1' type='text/css' media='all' />\n";
|
||||
$expected .= "<style id='handle-three-inline-css' type='text/css'>\n";
|
||||
$expected .= "$style\n";
|
||||
$expected .= "</style>\n";
|
||||
|
||||
wp_register_style( 'handle-one', 'http://example.com', array(), 1 );
|
||||
wp_register_style( 'handle-two', 'http://example.com', array(), 1 );
|
||||
wp_register_style( 'handle-three', false, array( 'handle-one', 'handle-two' ) );
|
||||
|
||||
wp_enqueue_style( 'handle-three' );
|
||||
wp_add_inline_style( 'handle-three', $style );
|
||||
|
||||
$this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user