Make WordPress Core

Ticket #31126: 31126.3.diff

File 31126.3.diff, 4.0 KB (added by DrewAPicture, 10 years ago)

Updated changelogs

  • src/wp-includes/functions.wp-scripts.php

     
    9494 * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
    9595 *
    9696 * @since 2.6.0
     97 * @since 4.3.0 A return value was added.
    9798 *
    9899 * @param string      $handle    Name of the script. Should be unique.
    99100 * @param string      $src       Path to the script from the WordPress root directory. Example: '/js/myscript.js'.
     
    105106 *                               If set to null, no version is added. Default 'false'. Accepts 'false', 'null', or 'string'.
    106107 * @param bool        $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
    107108 *                               Default 'false'. Accepts 'false' or 'true'.
     109 * @return bool Whether the script has been registered. True on success, false on failure.
    108110 */
    109111function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
    110112        $wp_scripts = wp_scripts();
    111113        _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
    112114
    113         $wp_scripts->add( $handle, $src, $deps, $ver );
     115        $add_result = $wp_scripts->add( $handle, $src, $deps, $ver );
    114116        if ( $in_footer ) {
    115117                $wp_scripts->add_data( $handle, 'group', 1 );
    116118        }
     119
     120        return $add_result;
    117121}
    118122
    119123/**
  • src/wp-includes/functions.wp-styles.php

     
    9898 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
    9999 *
    100100 * @since 2.6.0
     101 * @since 4.3.0 A return value was added.
    101102 *
    102103 * @param string      $handle Name of the stylesheet.
    103104 * @param string|bool $src    Path to the stylesheet from the WordPress root directory. Example: '/css/mystyle.css'.
     
    107108 * @param string      $media  Optional. The media for which this stylesheet has been defined.
    108109 *                            Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print',
    109110 *                            'screen', 'tty', or 'tv'.
     111 * @return bool Whether the style has been registered. True on success, false on failure.
    110112 */
    111113function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
    112114        _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
    113115
    114         wp_styles()->add( $handle, $src, $deps, $ver, $media );
     116        return wp_styles()->add( $handle, $src, $deps, $ver, $media );
    115117}
    116118
    117119/**
  • tests/phpunit/tests/dependencies/scripts.php

     
    155155                // No scripts left to print
    156156                $this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
    157157        }
     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
    158169}
  • tests/phpunit/tests/dependencies/styles.php

     
    229229                $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
    230230        }
    231231
     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
    232242}