WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/15/2017 10:35:41 PM (2 years ago)
Author:
westonruter
Message:

Widgets: Ensure return value of widget_text filter is not dropped but passed into widget_text_content filter for rendering.

Amends [40631].
Props vijustin, swissspidy, westonruter.
See #35243.
Fixes #40772.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets/text-widget.php

    r40640 r40673  
    7575        );
    7676
    77         add_filter( 'widget_text_content', array( $this, 'filter_widget_text_content' ), 10, 3 );
    78         add_filter( 'widget_text', array( $this, 'filter_widget_text' ), 10, 3 );
     77        add_filter( 'widget_text_content', array( $this, 'filter_widget_text_content' ), 5, 3 );
     78        add_filter( 'widget_text', array( $this, 'filter_widget_text' ), 5, 3 );
    7979
    8080        // Test with filter=false.
     
    8686        $this->assertEmpty( $this->widget_text_content_args );
    8787        $this->assertNotEmpty( $this->widget_text_args );
     88        $this->assertContains( '[filter:widget_text]', $output );
     89        $this->assertNotContains( '[filter:widget_text_content]', $output );
    8890
    8991        // Test with filter=true.
     
    99101        $this->assertEquals( $widget, $this->widget_text_args[2] );
    100102        $this->assertEmpty( $this->widget_text_content_args );
     103        $this->assertContains( '[filter:widget_text]', $output );
     104        $this->assertNotContains( '[filter:widget_text_content]', $output );
    101105
    102106        // Test with filter=content, the upgraded widget.
     
    112116        $this->assertEquals( $widget, $this->widget_text_args[2] );
    113117        $this->assertCount( 3, $this->widget_text_content_args );
    114         $this->assertEquals( wpautop( $instance['text'] ), $this->widget_text_content_args[0] );
     118        $this->assertEquals( $instance['text'] . '[filter:widget_text]', $this->widget_text_content_args[0] );
    115119        $this->assertEquals( $instance, $this->widget_text_content_args[1] );
    116120        $this->assertEquals( $widget, $this->widget_text_content_args[2] );
     121        $this->assertContains( wpautop( $instance['text'] . '[filter:widget_text][filter:widget_text_content]' ), $output );
    117122    }
    118123
     
    128133        $this->widget_text_args = func_get_args();
    129134
     135        $widget_text .= '[filter:widget_text]';
    130136        return $widget_text;
    131137    }
     
    142148        $this->widget_text_content_args = func_get_args();
    143149
     150        $widget_text .= '[filter:widget_text_content]';
    144151        return $widget_text;
    145152    }
Note: See TracChangeset for help on using the changeset viewer.