Code Modernisation: Introduce the spread operator in wp-admin/includes/class-*-upgrader-skin.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. Built from https://develop.svn.wordpress.org/trunk@46125 git-svn-id: http://core.svn.wordpress.org/trunk@45937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -78,9 +78,10 @@ class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin {
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @param string|WP_Error $errors Errors.
|
||||
* @param string|WP_Error $errors Errors.
|
||||
* @param mixed ...$args Optional text replacements.
|
||||
*/
|
||||
public function error( $errors ) {
|
||||
public function error( $errors, ...$args ) {
|
||||
if ( is_string( $errors ) ) {
|
||||
$string = $errors;
|
||||
if ( ! empty( $this->upgrader->strings[ $string ] ) ) {
|
||||
@@ -88,8 +89,6 @@ class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin {
|
||||
}
|
||||
|
||||
if ( false !== strpos( $string, '%' ) ) {
|
||||
$args = func_get_args();
|
||||
$args = array_splice( $args, 1 );
|
||||
if ( ! empty( $args ) ) {
|
||||
$string = vsprintf( $string, $args );
|
||||
}
|
||||
@@ -104,8 +103,7 @@ class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin {
|
||||
}
|
||||
}
|
||||
|
||||
$args = func_get_args();
|
||||
call_user_func_array( array( $this, 'parent::error' ), $args );
|
||||
parent::error( $errors, ...$args );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,16 +111,16 @@ class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin {
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @param string|array|WP_Error $data Log entry data.
|
||||
* @param string|array|WP_Error $data Log entry data.
|
||||
* @param mixed ...$args Optional text replacements.
|
||||
*/
|
||||
public function feedback( $data ) {
|
||||
public function feedback( $data, ...$args ) {
|
||||
if ( is_wp_error( $data ) ) {
|
||||
foreach ( $data->get_error_codes() as $error_code ) {
|
||||
$this->errors->add( $error_code, $data->get_error_message( $error_code ), $data->get_error_data( $error_code ) );
|
||||
}
|
||||
}
|
||||
|
||||
$args = func_get_args();
|
||||
call_user_func_array( array( $this, 'parent::feedback' ), $args );
|
||||
parent::feedback( $data, ...$args );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user