Widgets: Add nudge for registered widgets

Informs developers that widgets need to be registered before they can be
displayed through `the_widget()`. Previously it would fail with an ambiguous
undefined index notice.

Props SeBsZ, mrasharirfan.
Fixes #41743.



git-svn-id: https://develop.svn.wordpress.org/trunk@41327 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Konstantin Obenland
2017-09-01 08:49:50 +00:00
parent f5f5359d56
commit 09182448e7
2 changed files with 16 additions and 0 deletions

View File

@@ -678,6 +678,17 @@ class Tests_Widgets extends WP_UnitTestCase {
}
/**
* Tests that no 'Undefined index' exception is thrown when trying to
* display an unregistered widget.
*
* @see \the_widget()
*/
function test_the_widget_with_unregistered_widget() {
$this->setExpectedIncorrectUsage( 'the_widget' );
the_widget( 'Widget_Class' );
}
/**
* Register nav menu sidebars.
*