Skip to content

Commit

Permalink
Fix: Bug Affecting Widgets without description (#14587)
Browse files Browse the repository at this point in the history
## Description
Fixes: #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.
  • Loading branch information
jorgefilipecosta authored Mar 25, 2019
1 parent f779b93 commit f9027da
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
Expand Down

0 comments on commit f9027da

Please sign in to comment.