WordPress.org

Make WordPress Core

Ticket #47678: 47678-_Upgrader_Skin-feedback.patch

File 47678-_Upgrader_Skin-feedback.patch, 4.2 KB (added by jrf, 11 months ago)

Simplify & modernize *_Upgrader_Skin::feedback()

  • src/wp-admin/includes/class-automatic-upgrader-skin.php

    From 88b3c278ebde6bca90d033708f76926719cd7bc0 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Thu, 18 Jul 2019 02:50:51 +0200
    Subject: [PATCH] Simplify & modernize *_Upgrader_Skin::feedback()
    
    ---
     src/wp-admin/includes/class-automatic-upgrader-skin.php | 5 ++---
     src/wp-admin/includes/class-bulk-upgrader-skin.php      | 5 ++---
     src/wp-admin/includes/class-wp-ajax-upgrader-skin.php   | 8 ++++----
     src/wp-admin/includes/class-wp-upgrader-skin.php        | 5 ++---
     4 files changed, 10 insertions(+), 13 deletions(-)
    
    diff --git a/src/wp-admin/includes/class-automatic-upgrader-skin.php b/src/wp-admin/includes/class-automatic-upgrader-skin.php
    index 5f8360f066..3966e2a3db 100644
    a b class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { 
    5858
    5959        /**
    6060         * @param string|array|WP_Error $data
     61         * @param mixed                 ...$args Optional text replacements.
    6162         */
    62         public function feedback( $data ) {
     63        public function feedback( $data, ...$args ) {
    6364                if ( is_wp_error( $data ) ) {
    6465                        $string = $data->get_error_message();
    6566                } elseif ( is_array( $data ) ) {
    class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { 
    7273                }
    7374
    7475                if ( strpos( $string, '%' ) !== false ) {
    75                         $args = func_get_args();
    76                         $args = array_splice( $args, 1 );
    7776                        if ( ! empty( $args ) ) {
    7877                                $string = vsprintf( $string, $args );
    7978                        }
  • src/wp-admin/includes/class-bulk-upgrader-skin.php

    diff --git a/src/wp-admin/includes/class-bulk-upgrader-skin.php b/src/wp-admin/includes/class-bulk-upgrader-skin.php
    index c1454e62f1..6c4ede5614 100644
    a b class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { 
    5050
    5151        /**
    5252         * @param string $string
     53         * @param mixed  ...$args Optional text replacements.
    5354         */
    54         public function feedback( $string ) {
     55        public function feedback( $string, ...$args ) {
    5556                if ( isset( $this->upgrader->strings[ $string ] ) ) {
    5657                        $string = $this->upgrader->strings[ $string ];
    5758                }
    5859
    5960                if ( strpos( $string, '%' ) !== false ) {
    60                         $args = func_get_args();
    61                         $args = array_splice( $args, 1 );
    6261                        if ( $args ) {
    6362                                $args   = array_map( 'strip_tags', $args );
    6463                                $args   = array_map( 'esc_html', $args );
  • src/wp-admin/includes/class-wp-ajax-upgrader-skin.php

    diff --git a/src/wp-admin/includes/class-wp-ajax-upgrader-skin.php b/src/wp-admin/includes/class-wp-ajax-upgrader-skin.php
    index dbcc40f0d0..bb92eeef02 100644
    a b class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin { 
    113113         *
    114114         * @since 4.6.0
    115115         *
    116          * @param string|array|WP_Error $data Log entry data.
     116         * @param string|array|WP_Error $data    Log entry data.
     117         * @param mixed                 ...$args Optional text replacements.
    117118         */
    118         public function feedback( $data ) {
     119        public function feedback( $data, ...$args ) {
    119120                if ( is_wp_error( $data ) ) {
    120121                        foreach ( $data->get_error_codes() as $error_code ) {
    121122                                $this->errors->add( $error_code, $data->get_error_message( $error_code ), $data->get_error_data( $error_code ) );
    122123                        }
    123124                }
    124125
    125                 $args = func_get_args();
    126                 call_user_func_array( array( $this, 'parent::feedback' ), $args );
     126                parent::feedback( $data, ...$args );
    127127        }
    128128}
  • src/wp-admin/includes/class-wp-upgrader-skin.php

    diff --git a/src/wp-admin/includes/class-wp-upgrader-skin.php b/src/wp-admin/includes/class-wp-upgrader-skin.php
    index ddcfd19f18..aff625b59b 100644
    a b class WP_Upgrader_Skin { 
    140140
    141141        /**
    142142         * @param string $string
     143         * @param mixed  ...$args Optional text replacements.
    143144         */
    144         public function feedback( $string ) {
     145        public function feedback( $string, ...$args ) {
    145146                if ( isset( $this->upgrader->strings[ $string ] ) ) {
    146147                        $string = $this->upgrader->strings[ $string ];
    147148                }
    148149
    149150                if ( strpos( $string, '%' ) !== false ) {
    150                         $args = func_get_args();
    151                         $args = array_splice( $args, 1 );
    152151                        if ( $args ) {
    153152                                $args   = array_map( 'strip_tags', $args );
    154153                                $args   = array_map( 'esc_html', $args );