WordPress.org

Make WordPress Core

Ticket #22080: 22080.4.diff

File 22080.4.diff, 2.0 KB (added by jmichaelward, 2 years ago)
  • src/wp-includes/theme.php

     
    15351535                $args = array_slice( func_get_args(), 1 );
    15361536
    15371537        switch ( $feature ) {
     1538                case 'post-thumbnails':
     1539                        // Support has already been added for all post types and has a boolean value of true.
     1540                        if ( true === get_theme_support( 'post-thumbnails' ) ) {
     1541                                return;
     1542                        }
     1543
     1544                        // Get previously added post types and merge unique values into new array as args.
     1545                        if ( is_array( $args[0] ) && is_array( $_wp_theme_features['post-thumbnails'][0] ) ) {
     1546                                $values = array_unique( array_merge( $args[0], $_wp_theme_features['post-thumbnails'][0] ) );
     1547                                $args   = array( $values );
     1548                        }
     1549
     1550                        break;
     1551
    15381552                case 'post-formats' :
    15391553                        if ( is_array( $args[0] ) ) {
    15401554                                $post_formats = get_post_format_slugs();
  • tests/phpunit/tests/theme/support.php

     
    5252                $this->assertFalse( current_theme_supports( 'post-thumbnails' ) );
    5353        }
    5454
     55        /**
     56         * @ticket 22080
     57         */
     58        public function test_post_thumbnails_mixed_args() {
     59                add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
     60                add_theme_support( 'post-thumbnails', array( 'page' ) );
     61                $this->assertTrue( current_theme_support( 'post-thumbnails', 'post' ) );
     62                $this->assertFalse( current_theme_supports( 'post-thumbnails', 'book' ) );
     63                $this->assertEquals(
     64                        array( 0 => array( 'post', 'page' ) ),
     65                        get_theme_support( 'post-thumbnails' )
     66                );
     67                add_theme_support( 'post-thumbnails' );
     68                $this->assertTrue( current_theme_supports( 'post-thumbnails', 'book' ) );
     69        }
     70
    5571        public function test_post_thumbnails_types_true() {
    5672                // array of arguments, with the key of 'types' holding the post types.
    5773                add_theme_support( 'post-thumbnails', array( 'types' => true ) );