Post Thumbnails: Fix logic bug and tests from [37308] where post-thumbnails support wasn’t added if there were no previous post_types with support already.
See #22080 git-svn-id: https://develop.svn.wordpress.org/trunk@37313 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3518df091f
commit
1bee2ff07a
@ -1545,10 +1545,8 @@ function add_theme_support( $feature ) {
|
||||
* Merge post types with any that already declared their support
|
||||
* for post thumbnails.
|
||||
*/
|
||||
if ( is_array( $args[0] ) && is_array( $_wp_theme_features['post-thumbnails'][0] ) ) {
|
||||
$post_types = array_unique( array_merge( $args[0], $_wp_theme_features['post-thumbnails'][0] ) );
|
||||
|
||||
$args = array( $post_types );
|
||||
if ( is_array( $args[0] ) && isset( $_wp_theme_features['post-thumbnails'] ) ) {
|
||||
$args[0] = array_unique( array_merge( $_wp_theme_features['post-thumbnails'][0], $args[0] ) );
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -44,8 +44,9 @@ class Tests_Theme_Support extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_post_thumbnails_flat_array_of_post_types() {
|
||||
remove_theme_support( 'post-thumbnails' );
|
||||
|
||||
add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
|
||||
$this->assertTrue( current_theme_supports( 'post-thumbnails' ) );
|
||||
$this->assertTrue( current_theme_supports( 'post-thumbnails', 'post' ) );
|
||||
$this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) );
|
||||
remove_theme_support( 'post-thumbnails' );
|
||||
@ -67,6 +68,10 @@ class Tests_Theme_Support extends WP_UnitTestCase {
|
||||
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
$this->assertTrue( current_theme_supports( 'post-thumbnails', 'book' ) );
|
||||
|
||||
// Reset post-thumbnails theme support.
|
||||
remove_theme_support( 'post-thumbnails' );
|
||||
$this->assertFalse( current_theme_supports( 'post-thumbnails' ) );
|
||||
}
|
||||
|
||||
public function test_post_thumbnails_types_true() {
|
||||
|
Loading…
Reference in New Issue
Block a user