Ticket #35229: 35229.7.diff
File 35229.7.diff, 5.0 KB (added by , 9 years ago) |
---|
-
src/wp-includes/class.wp-dependencies.php
98 98 99 99 foreach ( $this->to_do as $key => $handle ) { 100 100 if ( !in_array($handle, $this->done, true) && isset($this->registered[$handle]) ) { 101 102 101 /* 103 * A single item may alias a set of items, by having dependencies,104 * but no source. Queuing the item queues the dependencies.105 *106 * Example: The extending class WP_Scripts is used to register 'scriptaculous' as a set of registered handles:107 * <code>add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) );</code>108 *109 * The src property is false.110 */111 if ( ! $this->registered[$handle]->src ) {112 $this->done[] = $handle;113 continue;114 }115 116 /*117 102 * Attempt to process the item. If successful, 118 103 * add the handle to the done array. 119 104 * -
src/wp-includes/class.wp-scripts.php
177 177 echo $cond_after; 178 178 } 179 179 180 if ( ! $obj->src ) { 181 return true; 182 } 183 180 184 if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) { 181 185 $src = $this->base_url . $src; 182 186 } -
src/wp-includes/class.wp-styles.php
72 72 else 73 73 $media = 'all'; 74 74 75 $href = $this->_css_href( $obj->src, $ver, $handle ); 76 if ( empty( $href ) ) { 77 // Turns out there is nothing to print. 75 if ( ! $obj->src ) { 76 if ( $inline_style = $this->print_inline_style( $handle, false ) ) { 77 $inline_style = sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style ); 78 if ( $this->do_concat ) { 79 $this->print_html .= $inline_style; 80 } else { 81 echo $inline_style; 82 } 83 } 78 84 return true; 79 85 } 86 87 $href = $this->_css_href( $obj->src, $ver, $handle ); 80 88 $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; 81 89 $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : ''; 82 90 -
tests/phpunit/tests/dependencies/scripts.php
166 166 $this->assertFalse( wp_register_script( 'duplicate-handler', 'http://example.com' ) ); 167 167 } 168 168 169 /** 170 * @ticket 35229 171 */ 172 function test_wp_register_script_with_handle_without_source() { 173 $expected = "<script type='text/javascript' src='http://example.com?ver=1'></script>\n"; 174 $expected .= "<script type='text/javascript' src='http://example.com?ver=2'></script>\n"; 175 176 wp_register_script( 'handle-one', 'http://example.com', array(), 1 ); 177 wp_register_script( 'handle-two', 'http://example.com', array(), 2 ); 178 wp_register_script( 'handle-three', false, array( 'handle-one', 'handle-two' ) ); 179 180 wp_enqueue_script( 'handle-three' ); 181 182 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 183 } 184 169 185 } -
tests/phpunit/tests/dependencies/styles.php
234 234 * 235 235 * @ticket 31126 236 236 */ 237 function test_wp_register_style() {237 function test_wp_register_style() { 238 238 $this->assertTrue( wp_register_style( 'duplicate-handler', 'http://example.com' ) ); 239 239 $this->assertFalse( wp_register_style( 'duplicate-handler', 'http://example.com' ) ); 240 240 } 241 241 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 242 264 }