Code Modernisation: Replace call_user_func_array() in wp-admin/includes/widgets.php and associated unit tests with a direct function call.

Props jrf.
See #47678.

git-svn-id: https://develop.svn.wordpress.org/trunk@46138 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-09-15 11:40:08 +00:00
parent 751f69be42
commit fd05ea0de9
2 changed files with 20 additions and 21 deletions

View File

@ -51,13 +51,13 @@ function wp_list_widgets() {
} }
} }
$args = wp_list_widget_controls_dynamic_sidebar( $control_args = array(
array(
0 => $args, 0 => $args,
1 => $widget['params'][0], 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'] = '</div>'; $params[0]['after_widget'] = '</div>';
$params[0]['before_title'] = '%BEG_OF_TITLE%'; // deprecated $params[0]['before_title'] = '%BEG_OF_TITLE%'; // deprecated
$params[0]['after_title'] = '%END_OF_TITLE%'; // deprecated $params[0]['after_title'] = '%END_OF_TITLE%'; // deprecated
if ( is_callable( $wp_registered_widgets[ $widget_id ]['callback'] ) ) { 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_registered_widgets[ $widget_id ]['callback'];
$wp_registered_widgets[ $widget_id ]['callback'] = 'wp_widget_control'; $wp_registered_widgets[ $widget_id ]['callback'] = 'wp_widget_control';

View File

@ -626,15 +626,14 @@ class Tests_Widgets extends WP_UnitTestCase {
'widget_id' => $widget['id'], 'widget_id' => $widget['id'],
'widget_name' => $widget['name'], 'widget_name' => $widget['name'],
); );
$args = wp_list_widget_controls_dynamic_sidebar( $control_args = array(
array(
0 => $params, 0 => $params,
1 => $widget['params'][0], 1 => $widget['params'][0],
)
); );
$sidebar_args = wp_list_widget_controls_dynamic_sidebar( $control_args );
ob_start(); ob_start();
call_user_func_array( 'wp_widget_control', $args ); wp_widget_control( ...$sidebar_args );
$control = ob_get_clean(); $control = ob_get_clean();
$this->assertNotEmpty( $control ); $this->assertNotEmpty( $control );
@ -659,15 +658,14 @@ class Tests_Widgets extends WP_UnitTestCase {
'after_widget_content' => '<!-- after_widget_content -->', 'after_widget_content' => '<!-- after_widget_content -->',
); );
$params = array_merge( $params, $param_overrides ); $params = array_merge( $params, $param_overrides );
$args = wp_list_widget_controls_dynamic_sidebar( $control_args = array(
array(
0 => $params, 0 => $params,
1 => $widget['params'][0], 1 => $widget['params'][0],
)
); );
$sidebar_args = wp_list_widget_controls_dynamic_sidebar( $control_args );
ob_start(); ob_start();
call_user_func_array( 'wp_widget_control', $args ); wp_widget_control( ...$sidebar_args );
$control = ob_get_clean(); $control = ob_get_clean();
$this->assertNotEmpty( $control ); $this->assertNotEmpty( $control );
$this->assertNotContains( '<form method="post">', $control ); $this->assertNotContains( '<form method="post">', $control );