WordPress.org

Make WordPress Core


Ignore:
Timestamp:
08/14/2019 11:02:25 PM (2 months ago)
Author:
SergeyBiryukov
Message:

Widgets: Allow for short-circuiting widget output in the_widget() using the widget_display_callback filter, for consistency with output via a registered sidebar.

Props MarcGuay, donmhico.
Fixes #34226.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets.php

    r45607 r45798  
    714714
    715715    /**
     716     * @ticket 34226
     717     */
     718    public function test_the_widget_should_short_circuit_with_widget_display_callback() {
     719        add_filter( 'widget_display_callback', '__return_false' );
     720
     721        register_widget( 'WP_Widget_Text' );
     722
     723        ob_start();
     724        the_widget( 'WP_Widget_Text' );
     725        $widget_content = ob_get_clean();
     726        unregister_widget( 'WP_Widget_Text' );
     727
     728        $this->assertEmpty( $widget_content );
     729    }
     730
     731    /**
    716732     * Register nav menu sidebars.
    717733     *
Note: See TracChangeset for help on using the changeset viewer.