Make WordPress Core


Ignore:
Timestamp:
02/27/2018 02:30:46 AM (9 years ago)
Author:
SergeyBiryukov
Message:

General: Introduce WP_Error::has_errors() method and use it where appropriate.

Props robdxw, DrewAPicture, SergeyBiryukov.
Fixes #42742.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-error.php

    r42343 r42761  
    7272         */
    7373        public function get_error_codes() {
    74                 if ( empty( $this->errors ) ) {
     74                if ( ! $this->has_errors() ) {
    7575                        return array();
    7676                }
    … …  
    163163
    164164        /**
     165         * Verify if the instance contains errors.
     166         *
     167         * @since 5.0.0
     168         *
     169         * @return bool
     170         */
     171        public function has_errors() {
     172                if ( ! empty( $this->errors ) ) {
     173                        return true;
     174                }
     175                return false;
     176        }
     177
     178        /**
    165179         * Add an error or append additional message to an existing error.
    166180         *
Note: See TracChangeset for help on using the changeset viewer.