Make WordPress Core


Ignore:
Timestamp:
09/15/2019 11:40:08 AM (6 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets.php

    r45798 r46138  
    621621        wp_widgets_init();
    622622        require_once ABSPATH . '/wp-admin/includes/widgets.php';
    623         $widget_id = 'search-2';
    624         $widget    = $wp_registered_widgets[ $widget_id ];
    625         $params    = array(
     623        $widget_id    = 'search-2';
     624        $widget       = $wp_registered_widgets[ $widget_id ];
     625        $params       = array(
    626626            'widget_id'   => $widget['id'],
    627627            'widget_name' => $widget['name'],
    628628        );
    629         $args      = wp_list_widget_controls_dynamic_sidebar(
    630             array(
    631                 0 => $params,
    632                 1 => $widget['params'][0],
    633             )
    634         );
     629        $control_args = array(
     630            0 => $params,
     631            1 => $widget['params'][0],
     632        );
     633        $sidebar_args = wp_list_widget_controls_dynamic_sidebar( $control_args );
    635634
    636635        ob_start();
    637         call_user_func_array( 'wp_widget_control', $args );
     636        wp_widget_control( ...$sidebar_args );
    638637        $control = ob_get_clean();
    639638        $this->assertNotEmpty( $control );
     
    660659        );
    661660        $params          = array_merge( $params, $param_overrides );
    662         $args            = wp_list_widget_controls_dynamic_sidebar(
    663             array(
    664                 0 => $params,
    665                 1 => $widget['params'][0],
    666             )
    667         );
     661        $control_args    = array(
     662            0 => $params,
     663            1 => $widget['params'][0],
     664        );
     665        $sidebar_args    = wp_list_widget_controls_dynamic_sidebar( $control_args );
    668666
    669667        ob_start();
    670         call_user_func_array( 'wp_widget_control', $args );
     668        wp_widget_control( ...$sidebar_args );
    671669        $control = ob_get_clean();
    672670        $this->assertNotEmpty( $control );
Note: See TracChangeset for help on using the changeset viewer.