Make WordPress Core

Ticket #51390: 51390.2.patch

File 51390.2.patch, 1.1 KB (added by Mista-Flo, 5 years ago)

Patch with unit test

  • src/wp-includes/theme.php

    diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php
    index 5fa7a23146..b707990dcf 100644
    a b function add_theme_support( $feature, ...$args ) { 
    25172517                                unset( $post_formats['standard'] );
    25182518
    25192519                                $args[0] = array_intersect( $args[0], array_keys( $post_formats ) );
     2520                        } else {
     2521                                _doing_it_wrong( "add_theme_support( 'post-formats' )", __( 'You need to pass an array of types.' ), '5.6.0' );
     2522                                return false;
    25202523                        }
    25212524                        break;
    25222525
  • tests/phpunit/tests/post/formats.php

    diff --git a/tests/phpunit/tests/post/formats.php b/tests/phpunit/tests/post/formats.php
    index 44cedfc9a6..e9b0424ffb 100644
    a b class Tests_Post_Formats extends WP_UnitTestCase { 
    88                parent::setUp();
    99        }
    1010
     11        function test_post_format_doing_it_wrong() {
     12                $this->setExpectedIncorrectUsage( "add_theme_support( 'post-formats' )" );
     13
     14                // The second parameter should be an array
     15                $this->assertFalse( add_theme_support( 'post-formats' ) );
     16        }
     17
    1118        function test_set_get_post_format_for_post() {
    1219                $post_id = self::factory()->post->create();
    1320