WordPress.org

Make WordPress Core

Ticket #27278: 27278.3.diff

File 27278.3.diff, 2.4 KB (added by jond3r, 6 years ago)
  • src/wp-includes/theme.php

     
    13791379 * The init hook may be too late for some features.
    13801380 *
    13811381 * @since 2.9.0
     1382 *
    13821383 * @param string $feature the feature being added
     1384 * @return void|bool False if trying to add html5 support and not passing an array as 2nd argument
    13831385 */
    13841386function add_theme_support( $feature ) {
    13851387        global $_wp_theme_features;
     
    13971399
    13981400                case 'html5' :
    13991401                        // You can't just pass 'html5', you need to pass an array of types.
    1400                         if ( empty( $args[0] ) ) {
    1401                                 $args = array( 0 => array( 'comment-list', 'comment-form', 'search-form' ) );
    1402                         } elseif ( ! is_array( $args[0] ) ) {
     1402                        // Note: as of 3.9.0 core supports the types 'comment-list', 'comment-form', 'search-form' and 'gallery'
     1403                        if ( ! is_array( $args[0] ) ) {
    14031404                                _doing_it_wrong( "add_theme_support( 'html5' )", 'You need to pass an array of types.', '3.6.1' );
    14041405                                return false;
    14051406                        }
  • tests/phpunit/tests/theme/support.php

     
    8080
    8181        /**
    8282         * @ticket 24932
     83         *
     84         * @expectedIncorrectUsage add_theme_support( 'html5' )
    8385         */
    8486        function test_supports_html5() {
    8587                remove_theme_support( 'html5' );
    8688                $this->assertFalse( current_theme_supports( 'html5' ) );
    8789                $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) );
    88                 $this->assertNotSame( false, add_theme_support( 'html5' ) );
    89                 $this->assertTrue( current_theme_supports( 'html5' ) );
    90                 $this->assertTrue( current_theme_supports( 'html5', 'comment-form' ) );
    91                 $this->assertTrue( current_theme_supports( 'html5', 'comment-list' ) );
    92                 $this->assertTrue( current_theme_supports( 'html5', 'search-form' ) );
     90                $this->assertFalse( add_theme_support( 'html5' ) );
     91                $this->assertFalse( current_theme_supports( 'html5' ) );
     92                $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) );
     93                $this->assertFalse( current_theme_supports( 'html5', 'comment-list' ) );
     94                $this->assertFalse( current_theme_supports( 'html5', 'search-form' ) );
     95                $this->assertFalse( current_theme_supports( 'html5', 'gallery' ) );
    9396                $this->assertFalse( current_theme_supports( 'html5', 'something-else' ) );
    9497        }
    9598