Code Modernisation: Introduce the spread operator in wp-admin/includes/dashboard.php.

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.

Props jrf.
See #47678.

git-svn-id: https://develop.svn.wordpress.org/trunk@46130 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-09-15 11:10:17 +00:00
parent 24a586b97f
commit 752c36bbf4

View File

@ -1062,7 +1062,7 @@ function wp_dashboard_rss_output( $widget_id ) {
* @param mixed ...$args Optional additional parameters to pass to the callback function when it's called.
* @return bool False on failure. True on success.
*/
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) {
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array(), ...$args ) {
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&hellip;' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
$doing_ajax = wp_doing_ajax();
@ -1089,7 +1089,6 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
}
if ( $callback && is_callable( $callback ) ) {
$args = array_slice( func_get_args(), 3 );
array_unshift( $args, $widget_id, $check_urls );
ob_start();
call_user_func_array( $callback, $args );