Make WordPress Core


Ignore:
Timestamp:
03/07/2022 02:42:49 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Themes: Correct the logic for displaying a _doing_it_wrong() notice for add_theme_support( 'html5' ).

  • Calling add_theme_support( 'html5' ) without passing an array of supported types should throw a _doing_it_wrong() notice: "You need to pass an array of types".
  • If the second parameter is not specified, it should fall back to an array of comment-list, comment-form, and search-form for backward compatibility.
  • If the second parameter is not an array, the function should return false.

The latter two points are covered by existing unit tests. The first one is now addressed by @expectedIncorrectUsage.

Follow-up to [25193], [25235], [25785].

Props audrasjb, peterwilsoncc, SergeyBiryukov.
Fixes #51657.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/support.php

    r52812 r52828  
    7777    /**
    7878     * @ticket 24932
     79     *
     80     * @expectedIncorrectUsage add_theme_support( 'html5' )
    7981     */
    8082    public function test_supports_html5() {
     
    8284        $this->assertFalse( current_theme_supports( 'html5' ) );
    8385        $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) );
     86
     87        /*
     88         * If the second parameter is not specified, it should throw a _doing_it_wrong() notice
     89         * and fall back to `array( 'comment-list', 'comment-form', 'search-form' )` for back-compat.
     90         */
    8491        $this->assertNotFalse( add_theme_support( 'html5' ) );
    8592        $this->assertTrue( current_theme_supports( 'html5' ) );
     
    99106        $this->assertFalse( current_theme_supports( 'html5' ) );
    100107        $this->assertFalse( current_theme_supports( 'html5', 'comment-form' ) );
     108
     109        // The second parameter should be an array.
    101110        $this->assertFalse( add_theme_support( 'html5', 'comment-form' ) );
    102111        $this->assertNotFalse( add_theme_support( 'html5', array( 'comment-form' ) ) );
Note: See TracChangeset for help on using the changeset viewer.