Make WordPress Core

Changeset 52812


Ignore:
Timestamp:
03/01/2022 04:05:14 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Themes: Make sure the current_theme_supports-{$feature} filter is consistently applied.

Previously, the filter was not applied if there are no arguments passed to current_theme_supports().

Follow-up to [12350], [19682].

Props helgatheviking, azouamauriac, pavanpatil1, SergeyBiryukov.
Fixes #55219.

Location:
trunk
Files:
2 edited

Legend:

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

    r52610 r52812  
    30383038    }
    30393039
    3040     // If no args passed then no extra checks need be performed.
     3040    // If no args passed then no extra checks need to be performed.
    30413041    if ( ! $args ) {
    3042         return true;
     3042        /** This filter is documented in wp-includes/theme.php */
     3043        return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
    30433044    }
    30443045
  • trunk/tests/phpunit/tests/theme/support.php

    r52798 r52812  
    169169
    170170    /**
     171     * @ticket 55219
     172     */
     173    public function test_plugin_hook_with_no_args() {
     174        add_theme_support( 'foobar' );
     175
     176        add_filter( 'current_theme_supports-foobar', '__return_false' );
     177
     178        $this->assertFalse( current_theme_supports( 'foobar' ) );
     179    }
     180
     181    /**
    171182     * @ticket 26900
    172183     */
Note: See TracChangeset for help on using the changeset viewer.