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. Built from https://develop.svn.wordpress.org/trunk@41327 git-svn-id: http://core.svn.wordpress.org/trunk@41158 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1036,6 +1036,11 @@ function wp_convert_widget_settings($base_name, $option_name, $settings) {
|
||||
function the_widget( $widget, $instance = array(), $args = array() ) {
|
||||
global $wp_widget_factory;
|
||||
|
||||
if ( ! isset( $wp_widget_factory->widgets[ $widget ] ) ) {
|
||||
_doing_it_wrong( __FUNCTION__, __( 'Widgets need to be registered before they can be displayed.' ), '4.9.0' );
|
||||
return;
|
||||
}
|
||||
|
||||
$widget_obj = $wp_widget_factory->widgets[$widget];
|
||||
if ( ! ( $widget_obj instanceof WP_Widget ) ) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user