diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index 51ef24ada8..a16d8c5e14 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -1273,8 +1273,12 @@ function add_theme_support( $feature ) { case 'html5' : // You can't just pass 'html5', you need to pass an array of types. - if ( ! is_array( $args[0] ) ) + if ( empty( $args[0] ) ) { + $args = array( 0 => array( 'comment-list', 'comment-form', 'search-form' ) ); + } elseif ( ! is_array( $args[0] ) ) { + _doing_it_wrong( "add_theme_support( 'html5' )", 'You need to pass an array of types.', '3.6.1' ); return false; + } // Calling 'html5' again merges, rather than overwrites. if ( isset( $_wp_theme_features['html5'] ) ) diff --git a/tests/phpunit/tests/theme/support.php b/tests/phpunit/tests/theme/support.php index 08666145a2..47f3698525 100644 --- a/tests/phpunit/tests/theme/support.php +++ b/tests/phpunit/tests/theme/support.php @@ -85,9 +85,12 @@ class Tests_Theme_Support extends WP_UnitTestCase { remove_theme_support( 'html5' ); $this->assertFalse( current_theme_supports( 'html5' ) ); $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) ); - $this->assertFalse( add_theme_support( 'html5' ) ); - $this->assertFalse( current_theme_supports( 'html5' ) ); - $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) ); + $this->assertNotSame( false, add_theme_support( 'html5' ) ); + $this->assertTrue( current_theme_supports( 'html5' ) ); + $this->assertTrue( current_theme_supports( 'html5', 'comment-form' ) ); + $this->assertTrue( current_theme_supports( 'html5', 'comment-list' ) ); + $this->assertTrue( current_theme_supports( 'html5', 'search-form' ) ); + $this->assertFalse( current_theme_supports( 'html5', 'something-else' ) ); } /** @@ -106,19 +109,29 @@ class Tests_Theme_Support extends WP_UnitTestCase { $this->assertTrue( current_theme_supports( 'html5' ) ); // It appends, rather than replaces. - $this->assertFalse( current_theme_supports( 'html5', 'comments-list' ) ); - $this->assertNotSame( false, add_theme_support( 'html5', array( 'comments-list' ) ) ); + $this->assertFalse( current_theme_supports( 'html5', 'comment-list' ) ); + $this->assertNotSame( false, add_theme_support( 'html5', array( 'comment-list' ) ) ); $this->assertTrue( current_theme_supports( 'html5', 'comment-form' ) ); - $this->assertTrue( current_theme_supports( 'html5', 'comments-list' ) ); + $this->assertTrue( current_theme_supports( 'html5', 'comment-list' ) ); $this->assertFalse( current_theme_supports( 'html5', 'search-form' ) ); // Removal is all or nothing. $this->assertTrue( remove_theme_support( 'html5' ) ); - $this->assertFalse( current_theme_supports( 'html5', 'comments-list' ) ); - $this->assertFalse( current_theme_supports( 'html5', 'comments-form' ) ); + $this->assertFalse( current_theme_supports( 'html5', 'comment-list' ) ); + $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) ); $this->assertFalse( current_theme_supports( 'html5', 'search-form' ) ); } + /** + * @ticket 24932 + */ + function test_supports_html5_invalid() { + remove_theme_support( 'html5' ); + $this->assertFalse( add_theme_support( 'html5', 'comment-form' ) ); + $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) ); + $this->assertFalse( current_theme_supports( 'html5' ) ); + } + function supports_foobar( $yesno, $args, $feature ) { if ( $args[0] == $feature[0] ) return true;