WordPress.org

Make WordPress Core

Ticket #28319: 28319.4.diff

File 28319.4.diff, 905 bytes (added by ebinnion, 7 years ago)

Updated patch with action added to add method.

  • wp-includes/class-wp-error.php

    diff --git a/wp-includes/class-wp-error.php b/wp-includes/class-wp-error.php
    index 6f07a8b..bdd93e6 100644
    a b public function __construct( $code = '', $message = '', $data = '' ) { 
    5959                if ( empty($code) )
    6060                        return;
    6161
    62                 $this->errors[$code][] = $message;
    63 
    64                 if ( ! empty($data) )
    65                         $this->error_data[$code] = $data;
     62                $this->add( $code, $message, $data );
    6663        }
    6764
    6865        /**
    public function get_error_data($code = '') { 
    222219         */
    223220        public function add($code, $message, $data = '') {
    224221                $this->errors[$code][] = $message;
     222
    225223                if ( ! empty($data) )
    226224                        $this->error_data[$code] = $data;
     225
     226                /**
     227                 * Fires when an error is added to a WP_Error object.
     228                 *
     229                 * @since 4.0.0
     230                 *
     231                 * @param WP_Error $this The WP_Error instance.
     232                 */
     233                do_action( 'add_wp_error', $this );
    227234        }
    228235
    229236        /**