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. git-svn-id: https://develop.svn.wordpress.org/trunk@45628 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6e829a7b26
commit
e6cde1614b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user