diff --git a/src/wp-admin/includes/widgets.php b/src/wp-admin/includes/widgets.php index 6eae360c30..9f7dfb573f 100644 --- a/src/wp-admin/includes/widgets.php +++ b/src/wp-admin/includes/widgets.php @@ -51,13 +51,13 @@ function wp_list_widgets() { } } - $args = wp_list_widget_controls_dynamic_sidebar( - array( - 0 => $args, - 1 => $widget['params'][0], - ) + $control_args = array( + 0 => $args, + 1 => $widget['params'][0], ); - call_user_func_array( 'wp_widget_control', $args ); + $sidebar_args = wp_list_widget_controls_dynamic_sidebar( $control_args ); + + wp_widget_control( ...$sidebar_args ); } } @@ -144,6 +144,7 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) { $params[0]['after_widget'] = ''; $params[0]['before_title'] = '%BEG_OF_TITLE%'; // deprecated $params[0]['after_title'] = '%END_OF_TITLE%'; // deprecated + if ( is_callable( $wp_registered_widgets[ $widget_id ]['callback'] ) ) { $wp_registered_widgets[ $widget_id ]['_callback'] = $wp_registered_widgets[ $widget_id ]['callback']; $wp_registered_widgets[ $widget_id ]['callback'] = 'wp_widget_control'; diff --git a/tests/phpunit/tests/widgets.php b/tests/phpunit/tests/widgets.php index 8e38b30a60..9d5f547dc6 100644 --- a/tests/phpunit/tests/widgets.php +++ b/tests/phpunit/tests/widgets.php @@ -620,21 +620,20 @@ class Tests_Widgets extends WP_UnitTestCase { wp_widgets_init(); require_once ABSPATH . '/wp-admin/includes/widgets.php'; - $widget_id = 'search-2'; - $widget = $wp_registered_widgets[ $widget_id ]; - $params = array( + $widget_id = 'search-2'; + $widget = $wp_registered_widgets[ $widget_id ]; + $params = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], ); - $args = wp_list_widget_controls_dynamic_sidebar( - array( - 0 => $params, - 1 => $widget['params'][0], - ) + $control_args = array( + 0 => $params, + 1 => $widget['params'][0], ); + $sidebar_args = wp_list_widget_controls_dynamic_sidebar( $control_args ); ob_start(); - call_user_func_array( 'wp_widget_control', $args ); + wp_widget_control( ...$sidebar_args ); $control = ob_get_clean(); $this->assertNotEmpty( $control ); @@ -659,15 +658,14 @@ class Tests_Widgets extends WP_UnitTestCase { 'after_widget_content' => '', ); $params = array_merge( $params, $param_overrides ); - $args = wp_list_widget_controls_dynamic_sidebar( - array( - 0 => $params, - 1 => $widget['params'][0], - ) + $control_args = array( + 0 => $params, + 1 => $widget['params'][0], ); + $sidebar_args = wp_list_widget_controls_dynamic_sidebar( $control_args ); ob_start(); - call_user_func_array( 'wp_widget_control', $args ); + wp_widget_control( ...$sidebar_args ); $control = ob_get_clean(); $this->assertNotEmpty( $control ); $this->assertNotContains( '
', $control );