From 17ba89b662c45ca3dcdf96e5e323c062dfd38d5e Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 12 Jul 2019 00:01:19 +0000 Subject: [PATCH] Code Modernisation: Introduce the spread operator in `add_post_type_support()`. 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@45625 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 0f76da8cb1..209a8be645 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -1779,15 +1779,15 @@ function _add_post_type_submenus() { * feature strings or a single string. * @param mixed ...$args Optional extra arguments to pass along with certain features. */ -function add_post_type_support( $post_type, $feature ) { +function add_post_type_support( $post_type, $feature, ...$args ) { global $_wp_post_type_features; $features = (array) $feature; foreach ( $features as $feature ) { - if ( func_num_args() == 2 ) { - $_wp_post_type_features[ $post_type ][ $feature ] = true; + if ( $args ) { + $_wp_post_type_features[ $post_type ][ $feature ] = $args; } else { - $_wp_post_type_features[ $post_type ][ $feature ] = array_slice( func_get_args(), 2 ); + $_wp_post_type_features[ $post_type ][ $feature ] = true; } } }