Ticket #31126: 31126.3.diff
File 31126.3.diff, 4.0 KB (added by , 10 years ago) |
---|
-
src/wp-includes/functions.wp-scripts.php
94 94 * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts. 95 95 * 96 96 * @since 2.6.0 97 * @since 4.3.0 A return value was added. 97 98 * 98 99 * @param string $handle Name of the script. Should be unique. 99 100 * @param string $src Path to the script from the WordPress root directory. Example: '/js/myscript.js'. … … 105 106 * If set to null, no version is added. Default 'false'. Accepts 'false', 'null', or 'string'. 106 107 * @param bool $in_footer Optional. Whether to enqueue the script before </head> or before </body>. 107 108 * Default 'false'. Accepts 'false' or 'true'. 109 * @return bool Whether the script has been registered. True on success, false on failure. 108 110 */ 109 111 function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) { 110 112 $wp_scripts = wp_scripts(); 111 113 _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); 112 114 113 $ wp_scripts->add( $handle, $src, $deps, $ver );115 $add_result = $wp_scripts->add( $handle, $src, $deps, $ver ); 114 116 if ( $in_footer ) { 115 117 $wp_scripts->add_data( $handle, 'group', 1 ); 116 118 } 119 120 return $add_result; 117 121 } 118 122 119 123 /** -
src/wp-includes/functions.wp-styles.php
98 98 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types. 99 99 * 100 100 * @since 2.6.0 101 * @since 4.3.0 A return value was added. 101 102 * 102 103 * @param string $handle Name of the stylesheet. 103 104 * @param string|bool $src Path to the stylesheet from the WordPress root directory. Example: '/css/mystyle.css'. … … 107 108 * @param string $media Optional. The media for which this stylesheet has been defined. 108 109 * Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print', 109 110 * 'screen', 'tty', or 'tv'. 111 * @return bool Whether the style has been registered. True on success, false on failure. 110 112 */ 111 113 function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) { 112 114 _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); 113 115 114 wp_styles()->add( $handle, $src, $deps, $ver, $media );116 return wp_styles()->add( $handle, $src, $deps, $ver, $media ); 115 117 } 116 118 117 119 /** -
tests/phpunit/tests/dependencies/scripts.php
155 155 // No scripts left to print 156 156 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 157 157 } 158 159 /** 160 * Testing 'wp_register_script' return boolean success/failure value. 161 * 162 * @ticket 31126 163 */ 164 function test_wp_register_script() { 165 $this->assertTrue( wp_register_script( 'duplicate-handler', 'http://example.com' ) ); 166 $this->assertFalse( wp_register_script( 'duplicate-handler', 'http://example.com' ) ); 167 } 168 158 169 } -
tests/phpunit/tests/dependencies/styles.php
229 229 $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); 230 230 } 231 231 232 /** 233 * Testing 'wp_register_style' return boolean success/failure value. 234 * 235 * @ticket 31126 236 */ 237 function test_wp_register_style(){ 238 $this->assertTrue( wp_register_style( 'duplicate-handler', 'http://example.com' ) ); 239 $this->assertFalse( wp_register_style( 'duplicate-handler', 'http://example.com' ) ); 240 } 241 232 242 }