WordPress.org

Make WordPress Core

Changeset 46122


Ignore:
Timestamp:
09/15/2019 10:30:16 AM (5 months ago)
Author:
SergeyBiryukov
Message:

Code Modernisation: Use the spread operator in wp_register_sidebar_widget().

Rather than relying func_get_args() to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable.

Missed in [45629].

Props jrf.
See #47678.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets.php

    r45932 r46122  
    355355 * @param mixed      ...$params       Optional additional parameters to pass to the callback function when it's called.
    356356 */
    357 function wp_register_sidebar_widget( $id, $name, $output_callback, $options = array() ) {
     357function wp_register_sidebar_widget( $id, $name, $output_callback, $options = array(), ...$params ) {
    358358    global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_widget_updates, $_wp_deprecated_widgets_callbacks;
    359359
     
    378378        'id'       => $id,
    379379        'callback' => $output_callback,
    380         'params'   => array_slice( func_get_args(), 4 ),
     380        'params'   => $params,
    381381    );
    382382    $widget   = array_merge( $widget, $options );
Note: See TracChangeset for help on using the changeset viewer.