Make WordPress Core

Changeset 49344


Ignore:
Timestamp:
10/27/2020 07:58:10 PM (4 years ago)
Author:
helen
Message:

Post Formats: You have to pass an array of supported post formats.

This shows a _doing_it_wrong() message and also returns false instead of true if no array of formats is passed in add_theme_support(), avoiding a PHP error.

Post formats maintainership comes full circle. 🙃

Props Mista-Flo, sproutchris, garrett-eclipse.
Fixes #51390.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme.php

    r49214 r49344  
    24822482 * @since 5.5.0 The `core-block-patterns` feature was added and is enabled by default.
    24832483 * @since 5.5.0 The `custom-logo` feature now also accepts 'unlink-homepage-logo'.
     2484 * @since 5.6.0 The `post-formats` feature now returns doing it wrong if no array is passed
    24842485 *
    24852486 * @global array $_wp_theme_features
     
    25242525
    25252526                $args[0] = array_intersect( $args[0], array_keys( $post_formats ) );
     2527            } else {
     2528                _doing_it_wrong( "add_theme_support( 'post-formats' )", __( 'You need to pass an array of types.' ), '5.6.0' );
     2529                return false;
    25262530            }
    25272531            break;
  • trunk/tests/phpunit/tests/post/formats.php

    r48937 r49344  
    77    function setUp() {
    88        parent::setUp();
     9    }
     10
     11    /**
     12     * @ticket 51390
     13     */
     14    function test_post_format_doing_it_wrong() {
     15        $this->setExpectedIncorrectUsage( "add_theme_support( 'post-formats' )" );
     16
     17        // The second parameter should be an array.
     18        $this->assertFalse( add_theme_support( 'post-formats' ) );
    919    }
    1020
Note: See TracChangeset for help on using the changeset viewer.