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. Built from https://develop.svn.wordpress.org/trunk@45625 git-svn-id: http://core.svn.wordpress.org/trunk@45436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
41ea1f106d
commit
5fb46ff14b
|
@ -1779,15 +1779,15 @@ function _add_post_type_submenus() {
|
||||||
* feature strings or a single string.
|
* feature strings or a single string.
|
||||||
* @param mixed ...$args Optional extra arguments to pass along with certain features.
|
* @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;
|
global $_wp_post_type_features;
|
||||||
|
|
||||||
$features = (array) $feature;
|
$features = (array) $feature;
|
||||||
foreach ( $features as $feature ) {
|
foreach ( $features as $feature ) {
|
||||||
if ( func_num_args() == 2 ) {
|
if ( $args ) {
|
||||||
$_wp_post_type_features[ $post_type ][ $feature ] = true;
|
$_wp_post_type_features[ $post_type ][ $feature ] = $args;
|
||||||
} else {
|
} else {
|
||||||
$_wp_post_type_features[ $post_type ][ $feature ] = array_slice( func_get_args(), 2 );
|
$_wp_post_type_features[ $post_type ][ $feature ] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3-alpha-45624';
|
$wp_version = '5.3-alpha-45625';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue