WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/17/2016 05:10:53 PM (5 years ago)
Author:
ocean90
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/dependencies/styles.php

    r36547 r36550  
    235235     * @ticket 31126
    236236     */
    237     function test_wp_register_style(){
     237    function test_wp_register_style() {
    238238        $this->assertTrue( wp_register_style( 'duplicate-handler', 'http://example.com' ) );
    239239        $this->assertFalse( wp_register_style( 'duplicate-handler', 'http://example.com' ) );
    240240    }
    241241
     242    /**
     243     * @ticket 35229
     244     */
     245    function test_wp_add_inline_style_for_handle_without_source() {
     246        $style  = "a { color: blue; }";
     247
     248        $expected  = "<link rel='stylesheet' id='handle-one-css'  href='http://example.com?ver=1' type='text/css' media='all' />\n";
     249        $expected .= "<link rel='stylesheet' id='handle-two-css'  href='http://example.com?ver=1' type='text/css' media='all' />\n";
     250        $expected .= "<style id='handle-three-inline-css' type='text/css'>\n";
     251        $expected .= "$style\n";
     252        $expected .= "</style>\n";
     253
     254        wp_register_style( 'handle-one', 'http://example.com', array(), 1 );
     255        wp_register_style( 'handle-two', 'http://example.com', array(), 1 );
     256        wp_register_style( 'handle-three', false, array( 'handle-one', 'handle-two' ) );
     257
     258        wp_enqueue_style( 'handle-three' );
     259        wp_add_inline_style( 'handle-three', $style );
     260
     261        $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
     262    }
     263
    242264}
Note: See TracChangeset for help on using the changeset viewer.