mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@45798 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -712,6 +712,22 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
the_widget( 'Widget_Class' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34226
|
||||
*/
|
||||
public function test_the_widget_should_short_circuit_with_widget_display_callback() {
|
||||
add_filter( 'widget_display_callback', '__return_false' );
|
||||
|
||||
register_widget( 'WP_Widget_Text' );
|
||||
|
||||
ob_start();
|
||||
the_widget( 'WP_Widget_Text' );
|
||||
$widget_content = ob_get_clean();
|
||||
unregister_widget( 'WP_Widget_Text' );
|
||||
|
||||
$this->assertEmpty( $widget_content );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register nav menu sidebars.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user