From f9027dace9c425838ed6ff6f2a5461feff752a47 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Mon, 25 Mar 2019 14:43:34 +0000 Subject: [PATCH] Fix: Bug Affecting Widgets without description (#14587) ## Description Fixes: https://github.com/WordPress/gutenberg/issues/14552 We were not checking in the widget description was set and on widgets, without description, an undefined notice was being thrown. ## How has this been tested? I installed the AnsPress Question Answer plugin: https://wordpress.org/plugins/anspress-question-answer. I created a new page and verified and checked Undefined notice was not being thrown in the PHP code. In master, a notice should appear. --- lib/widgets.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/widgets.php b/lib/widgets.php index b756cce99d5222..c2f9a08d90d698 100644 --- a/lib/widgets.php +++ b/lib/widgets.php @@ -95,7 +95,12 @@ function gutenberg_legacy_widget_settings( $settings ) { if ( ! in_array( $class, $core_widgets ) ) { $available_legacy_widgets[ $class ] = array( 'name' => html_entity_decode( $widget_obj->name ), - 'description' => html_entity_decode( $widget_obj->widget_options['description'] ), + // wp_widget_description is not being used because its input parameter is a Widget Id. + // Widgets id's reference to a specific widget instance. + // Here we are iterating on all the available widget classes even if no widget instance exists for them. + 'description' => isset( $widget_obj->widget_options['description'] ) ? + html_entity_decode( $widget_obj->widget_options['description'] ) : + null, 'isCallbackWidget' => false, ); }