WordPress.org

Make WordPress Core

Ticket #20920: 20920.diff

File 20920.diff, 1.3 KB (added by valendesigns, 5 years ago)
  • src/wp-includes/plugin.php

    diff --git src/wp-includes/plugin.php src/wp-includes/plugin.php
    index 27a65ee..ca3c610 100644
    function remove_all_filters( $tag, $priority = false ) { 
    325325        global $wp_filter, $merged_filters;
    326326
    327327        if ( isset( $wp_filter[ $tag ]) ) {
    328                 if ( false !== $priority && isset( $wp_filter[ $tag ][ $priority ] ) ) {
    329                         $wp_filter[ $tag ][ $priority ] = array();
     328                if ( false !== $priority ) {
     329                        if ( isset( $wp_filter[ $tag ][ $priority ] ) ) {
     330                                $wp_filter[ $tag ][ $priority ] = array();
     331                        }
    330332                } else {
    331333                        $wp_filter[ $tag ] = array();
    332334                }
  • tests/phpunit/tests/filters.php

    diff --git tests/phpunit/tests/filters.php tests/phpunit/tests/filters.php
    index c0eb125..11a99f1 100644
    class Tests_Filters extends WP_UnitTestCase { 
    251251        }
    252252
    253253        /**
     254         * @ticket 20920
     255         */
     256        function test_has_filter_after_remove_filters_on_unused_priority() {
     257                $a = new MockAction();
     258                $tag = rand_str();
     259                $val = rand_str();
     260
     261                // Should not be removed
     262                add_filter( $tag, array( $a, 'filter' ), 12 );
     263                $this->assertTrue( has_filter( $tag ) );
     264
     265                remove_all_filters( $tag, 11 );
     266                $this->assertTrue( has_filter( $tag ) );
     267        }
     268
     269        /**
    254270         * @ticket 29070
    255271         */
    256272        function test_has_filter_after_remove_all_filters() {