From afdbf749d7b4e9a78d6cc030b024ef0a66685bdf Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 12 Jul 2019 00:10:56 +0000 Subject: [PATCH] Code Modernisation: Introduce the spread operator in `theme.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, pento. See #47678. Built from https://develop.svn.wordpress.org/trunk@45628 git-svn-id: http://core.svn.wordpress.org/trunk@45439 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/theme.php | 17 ++++++----------- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/wp-includes/theme.php b/wp-includes/theme.php index fe419ee08f..f7f061d351 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -2353,13 +2353,11 @@ function get_theme_starter_content() { * @param mixed ...$args Optional extra arguments to pass along with certain features. * @return void|bool False on failure, void otherwise. */ -function add_theme_support( $feature ) { +function add_theme_support( $feature, ...$args ) { global $_wp_theme_features; - if ( func_num_args() == 1 ) { + if ( ! $args ) { $args = true; - } else { - $args = array_slice( func_get_args(), 1 ); } switch ( $feature ) { @@ -2665,17 +2663,16 @@ function _custom_logo_header_styles() { * @param mixed ...$args Optional extra arguments to be checked against certain features. * @return mixed The array of extra arguments or the value for the registered feature. */ -function get_theme_support( $feature ) { +function get_theme_support( $feature, ...$args ) { global $_wp_theme_features; if ( ! isset( $_wp_theme_features[ $feature ] ) ) { return false; } - if ( func_num_args() <= 1 ) { + if ( ! $args ) { return $_wp_theme_features[ $feature ]; } - $args = array_slice( func_get_args(), 1 ); switch ( $feature ) { case 'custom-logo': case 'custom-header': @@ -2786,7 +2783,7 @@ function _remove_theme_support( $feature ) { * @param mixed ...$args Optional extra arguments to be checked against certain features. * @return bool True if the current theme supports the feature, false otherwise. */ -function current_theme_supports( $feature ) { +function current_theme_supports( $feature, ...$args ) { global $_wp_theme_features; if ( 'custom-header-uploads' == $feature ) { @@ -2798,12 +2795,10 @@ function current_theme_supports( $feature ) { } // If no args passed then no extra checks need be performed - if ( func_num_args() <= 1 ) { + if ( ! $args ) { return true; } - $args = array_slice( func_get_args(), 1 ); - switch ( $feature ) { case 'post-thumbnails': // post-thumbnails can be registered for only certain content/post types by passing diff --git a/wp-includes/version.php b/wp-includes/version.php index 924b4778ae..2ca75503ff 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45627'; +$wp_version = '5.3-alpha-45628'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.