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. git-svn-id: https://develop.svn.wordpress.org/trunk@49344 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
cf4a274466
commit
357c1c0b86
@ -2481,6 +2481,7 @@ function get_theme_starter_content() {
|
|||||||
* by adding it to the function signature.
|
* by adding it to the function signature.
|
||||||
* @since 5.5.0 The `core-block-patterns` feature was added and is enabled by default.
|
* @since 5.5.0 The `core-block-patterns` feature was added and is enabled by default.
|
||||||
* @since 5.5.0 The `custom-logo` feature now also accepts 'unlink-homepage-logo'.
|
* @since 5.5.0 The `custom-logo` feature now also accepts 'unlink-homepage-logo'.
|
||||||
|
* @since 5.6.0 The `post-formats` feature now returns doing it wrong if no array is passed
|
||||||
*
|
*
|
||||||
* @global array $_wp_theme_features
|
* @global array $_wp_theme_features
|
||||||
*
|
*
|
||||||
@ -2523,6 +2524,9 @@ function add_theme_support( $feature, ...$args ) {
|
|||||||
unset( $post_formats['standard'] );
|
unset( $post_formats['standard'] );
|
||||||
|
|
||||||
$args[0] = array_intersect( $args[0], array_keys( $post_formats ) );
|
$args[0] = array_intersect( $args[0], array_keys( $post_formats ) );
|
||||||
|
} else {
|
||||||
|
_doing_it_wrong( "add_theme_support( 'post-formats' )", __( 'You need to pass an array of types.' ), '5.6.0' );
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -8,6 +8,16 @@ class Tests_Post_Formats extends WP_UnitTestCase {
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 51390
|
||||||
|
*/
|
||||||
|
function test_post_format_doing_it_wrong() {
|
||||||
|
$this->setExpectedIncorrectUsage( "add_theme_support( 'post-formats' )" );
|
||||||
|
|
||||||
|
// The second parameter should be an array.
|
||||||
|
$this->assertFalse( add_theme_support( 'post-formats' ) );
|
||||||
|
}
|
||||||
|
|
||||||
function test_set_get_post_format_for_post() {
|
function test_set_get_post_format_for_post() {
|
||||||
$post_id = self::factory()->post->create();
|
$post_id = self::factory()->post->create();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user