mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-04 17:20:07 +00:00
General: Introduce WP_Error::has_errors() method and use it where appropriate.
Props robdxw, DrewAPicture, SergeyBiryukov. Fixes #42742. git-svn-id: https://develop.svn.wordpress.org/trunk@42761 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -71,7 +71,7 @@ class WP_Error {
|
||||
* @return array List of error codes, if available.
|
||||
*/
|
||||
public function get_error_codes() {
|
||||
if ( empty( $this->errors ) ) {
|
||||
if ( ! $this->has_errors() ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
@@ -161,6 +161,20 @@ class WP_Error {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the instance contains errors.
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has_errors() {
|
||||
if ( ! empty( $this->errors ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an error or append additional message to an existing error.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user