General: Introduce `WP_Error::has_errors()` method and use it where appropriate.
Props robdxw, DrewAPicture, SergeyBiryukov. Fixes #42742. Built from https://develop.svn.wordpress.org/trunk@42761 git-svn-id: http://core.svn.wordpress.org/trunk@42591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
71f206839d
commit
0e802a627d
|
@ -3692,7 +3692,7 @@ function wp_ajax_install_theme() {
|
||||||
$status['errorCode'] = $skin->result->get_error_code();
|
$status['errorCode'] = $skin->result->get_error_code();
|
||||||
$status['errorMessage'] = $skin->result->get_error_message();
|
$status['errorMessage'] = $skin->result->get_error_message();
|
||||||
wp_send_json_error( $status );
|
wp_send_json_error( $status );
|
||||||
} elseif ( $skin->get_errors()->get_error_code() ) {
|
} elseif ( $skin->get_errors()->has_errors() ) {
|
||||||
$status['errorMessage'] = $skin->get_error_messages();
|
$status['errorMessage'] = $skin->get_error_messages();
|
||||||
wp_send_json_error( $status );
|
wp_send_json_error( $status );
|
||||||
} elseif ( is_null( $result ) ) {
|
} elseif ( is_null( $result ) ) {
|
||||||
|
@ -3702,7 +3702,7 @@ function wp_ajax_install_theme() {
|
||||||
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
||||||
|
|
||||||
// Pass through the error from WP_Filesystem if one was raised.
|
// Pass through the error from WP_Filesystem if one was raised.
|
||||||
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3805,7 +3805,7 @@ function wp_ajax_update_theme() {
|
||||||
$status['errorCode'] = $skin->result->get_error_code();
|
$status['errorCode'] = $skin->result->get_error_code();
|
||||||
$status['errorMessage'] = $skin->result->get_error_message();
|
$status['errorMessage'] = $skin->result->get_error_message();
|
||||||
wp_send_json_error( $status );
|
wp_send_json_error( $status );
|
||||||
} elseif ( $skin->get_errors()->get_error_code() ) {
|
} elseif ( $skin->get_errors()->has_errors() ) {
|
||||||
$status['errorMessage'] = $skin->get_error_messages();
|
$status['errorMessage'] = $skin->get_error_messages();
|
||||||
wp_send_json_error( $status );
|
wp_send_json_error( $status );
|
||||||
} elseif ( is_array( $result ) && ! empty( $result[ $stylesheet ] ) ) {
|
} elseif ( is_array( $result ) && ! empty( $result[ $stylesheet ] ) ) {
|
||||||
|
@ -3829,7 +3829,7 @@ function wp_ajax_update_theme() {
|
||||||
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
||||||
|
|
||||||
// Pass through the error from WP_Filesystem if one was raised.
|
// Pass through the error from WP_Filesystem if one was raised.
|
||||||
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3891,7 +3891,7 @@ function wp_ajax_delete_theme() {
|
||||||
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
||||||
|
|
||||||
// Pass through the error from WP_Filesystem if one was raised.
|
// Pass through the error from WP_Filesystem if one was raised.
|
||||||
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3980,7 +3980,7 @@ function wp_ajax_install_plugin() {
|
||||||
$status['errorCode'] = $skin->result->get_error_code();
|
$status['errorCode'] = $skin->result->get_error_code();
|
||||||
$status['errorMessage'] = $skin->result->get_error_message();
|
$status['errorMessage'] = $skin->result->get_error_message();
|
||||||
wp_send_json_error( $status );
|
wp_send_json_error( $status );
|
||||||
} elseif ( $skin->get_errors()->get_error_code() ) {
|
} elseif ( $skin->get_errors()->has_errors() ) {
|
||||||
$status['errorMessage'] = $skin->get_error_messages();
|
$status['errorMessage'] = $skin->get_error_messages();
|
||||||
wp_send_json_error( $status );
|
wp_send_json_error( $status );
|
||||||
} elseif ( is_null( $result ) ) {
|
} elseif ( is_null( $result ) ) {
|
||||||
|
@ -3990,7 +3990,7 @@ function wp_ajax_install_plugin() {
|
||||||
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
||||||
|
|
||||||
// Pass through the error from WP_Filesystem if one was raised.
|
// Pass through the error from WP_Filesystem if one was raised.
|
||||||
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4081,7 +4081,7 @@ function wp_ajax_update_plugin() {
|
||||||
$status['errorCode'] = $skin->result->get_error_code();
|
$status['errorCode'] = $skin->result->get_error_code();
|
||||||
$status['errorMessage'] = $skin->result->get_error_message();
|
$status['errorMessage'] = $skin->result->get_error_message();
|
||||||
wp_send_json_error( $status );
|
wp_send_json_error( $status );
|
||||||
} elseif ( $skin->get_errors()->get_error_code() ) {
|
} elseif ( $skin->get_errors()->has_errors() ) {
|
||||||
$status['errorMessage'] = $skin->get_error_messages();
|
$status['errorMessage'] = $skin->get_error_messages();
|
||||||
wp_send_json_error( $status );
|
wp_send_json_error( $status );
|
||||||
} elseif ( is_array( $result ) && ! empty( $result[ $plugin ] ) ) {
|
} elseif ( is_array( $result ) && ! empty( $result[ $plugin ] ) ) {
|
||||||
|
@ -4115,7 +4115,7 @@ function wp_ajax_update_plugin() {
|
||||||
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
||||||
|
|
||||||
// Pass through the error from WP_Filesystem if one was raised.
|
// Pass through the error from WP_Filesystem if one was raised.
|
||||||
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4182,7 +4182,7 @@ function wp_ajax_delete_plugin() {
|
||||||
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
$status['errorMessage'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
||||||
|
|
||||||
// Pass through the error from WP_Filesystem if one was raised.
|
// Pass through the error from WP_Filesystem if one was raised.
|
||||||
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( $wp_filesystem instanceof WP_Filesystem_Base && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
$status['errorMessage'] = esc_html( $wp_filesystem->errors->get_error_message() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,10 @@ class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin {
|
||||||
$messages = array();
|
$messages = array();
|
||||||
|
|
||||||
foreach ( $this->errors->get_error_codes() as $error_code ) {
|
foreach ( $this->errors->get_error_codes() as $error_code ) {
|
||||||
if ( $this->errors->get_error_data( $error_code ) && is_string( $this->errors->get_error_data( $error_code ) ) ) {
|
$error_data = $this->errors->get_error_data( $error_code );
|
||||||
$messages[] = $this->errors->get_error_message( $error_code ) . ' ' . esc_html( strip_tags( $this->errors->get_error_data( $error_code ) ) );
|
|
||||||
|
if ( $error_data && is_string( $error_data ) ) {
|
||||||
|
$messages[] = $this->errors->get_error_message( $error_code ) . ' ' . esc_html( strip_tags( $error_data ) );
|
||||||
} else {
|
} else {
|
||||||
$messages[] = $this->errors->get_error_message( $error_code );
|
$messages[] = $this->errors->get_error_message( $error_code );
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@ class WP_Upgrader_Skin {
|
||||||
}
|
}
|
||||||
if ( is_string( $errors ) ) {
|
if ( is_string( $errors ) ) {
|
||||||
$this->feedback( $errors );
|
$this->feedback( $errors );
|
||||||
} elseif ( is_wp_error( $errors ) && $errors->get_error_code() ) {
|
} elseif ( is_wp_error( $errors ) && $errors->has_errors() ) {
|
||||||
foreach ( $errors->get_error_messages() as $message ) {
|
foreach ( $errors->get_error_messages() as $message ) {
|
||||||
if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
|
if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) ) {
|
||||||
$this->feedback( $message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
|
$this->feedback( $message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
|
||||||
|
|
|
@ -191,7 +191,7 @@ class WP_Upgrader {
|
||||||
|
|
||||||
if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) {
|
if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) {
|
||||||
$error = true;
|
$error = true;
|
||||||
if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
$error = $wp_filesystem->errors;
|
$error = $wp_filesystem->errors;
|
||||||
}
|
}
|
||||||
// Failed to connect, Error and request again
|
// Failed to connect, Error and request again
|
||||||
|
@ -203,7 +203,7 @@ class WP_Upgrader {
|
||||||
return new WP_Error( 'fs_unavailable', $this->strings['fs_unavailable'] );
|
return new WP_Error( 'fs_unavailable', $this->strings['fs_unavailable'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
return new WP_Error( 'fs_error', $this->strings['fs_error'], $wp_filesystem->errors );
|
return new WP_Error( 'fs_error', $this->strings['fs_error'], $wp_filesystem->errors );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1460,7 +1460,7 @@ function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_own
|
||||||
define( 'FS_TIMEOUT', 30 );
|
define( 'FS_TIMEOUT', 30 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -865,7 +865,7 @@ function delete_plugins( $plugins, $deprecated = '' ) {
|
||||||
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
|
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
|
return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -980,7 +980,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||||
$errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) );
|
$errors->add( 'invalid_email', __( 'You must provide a valid email address.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $errors->get_error_code() ) {
|
if ( $errors->has_errors() ) {
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ function delete_theme( $stylesheet, $redirect = '' ) {
|
||||||
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
|
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
|
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
|
||||||
return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
|
return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ function edit_user( $user_id = 0 ) {
|
||||||
*/
|
*/
|
||||||
do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) );
|
do_action_ref_array( 'user_profile_update_errors', array( &$errors, $update, &$user ) );
|
||||||
|
|
||||||
if ( $errors->get_error_codes() ) {
|
if ( $errors->has_errors() ) {
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-user' == $_REQUEST['action'] ) {
|
||||||
$user = wp_unslash( $_POST['user'] );
|
$user = wp_unslash( $_POST['user'] );
|
||||||
|
|
||||||
$user_details = wpmu_validate_user_signup( $user['username'], $user['email'] );
|
$user_details = wpmu_validate_user_signup( $user['username'], $user['email'] );
|
||||||
if ( is_wp_error( $user_details['errors'] ) && ! empty( $user_details['errors']->errors ) ) {
|
if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
|
||||||
$add_user_errors = $user_details['errors'];
|
$add_user_errors = $user_details['errors'];
|
||||||
} else {
|
} else {
|
||||||
$password = wp_generate_password( 12, false );
|
$password = wp_generate_password( 12, false );
|
||||||
|
|
|
@ -499,7 +499,7 @@ if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $wp_filesystem->errors->get_error_code() ) {
|
if ( $wp_filesystem->errors->has_errors() ) {
|
||||||
foreach ( $wp_filesystem->errors->get_error_messages() as $message ) {
|
foreach ( $wp_filesystem->errors->get_error_messages() as $message ) {
|
||||||
show_message( $message );
|
show_message( $message );
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ Please click the following link to confirm the invite:
|
||||||
// Adding a new user to this site
|
// Adding a new user to this site
|
||||||
$new_user_email = wp_unslash( $_REQUEST['email'] );
|
$new_user_email = wp_unslash( $_REQUEST['email'] );
|
||||||
$user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
|
$user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
|
||||||
if ( is_wp_error( $user_details['errors'] ) && ! empty( $user_details['errors']->errors ) ) {
|
if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
|
||||||
$add_user_errors = $user_details['errors'];
|
$add_user_errors = $user_details['errors'];
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2302,7 +2302,7 @@ final class WP_Customize_Manager {
|
||||||
if ( ! is_wp_error( $validity ) ) {
|
if ( ! is_wp_error( $validity ) ) {
|
||||||
/** This filter is documented in wp-includes/class-wp-customize-setting.php */
|
/** This filter is documented in wp-includes/class-wp-customize-setting.php */
|
||||||
$late_validity = apply_filters( "customize_validate_{$setting->id}", new WP_Error(), $unsanitized_value, $setting );
|
$late_validity = apply_filters( "customize_validate_{$setting->id}", new WP_Error(), $unsanitized_value, $setting );
|
||||||
if ( ! empty( $late_validity->errors ) ) {
|
if ( $late_validity->has_errors() ) {
|
||||||
$validity = $late_validity;
|
$validity = $late_validity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -594,7 +594,7 @@ class WP_Customize_Setting {
|
||||||
*/
|
*/
|
||||||
$validity = apply_filters( "customize_validate_{$this->id}", $validity, $value, $this );
|
$validity = apply_filters( "customize_validate_{$this->id}", $validity, $value, $this );
|
||||||
|
|
||||||
if ( is_wp_error( $validity ) && empty( $validity->errors ) ) {
|
if ( is_wp_error( $validity ) && ! $validity->has_errors() ) {
|
||||||
$validity = true;
|
$validity = true;
|
||||||
}
|
}
|
||||||
return $validity;
|
return $validity;
|
||||||
|
|
|
@ -71,7 +71,7 @@ class WP_Error {
|
||||||
* @return array List of error codes, if available.
|
* @return array List of error codes, if available.
|
||||||
*/
|
*/
|
||||||
public function get_error_codes() {
|
public function get_error_codes() {
|
||||||
if ( empty( $this->errors ) ) {
|
if ( ! $this->has_errors() ) {
|
||||||
return array();
|
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.
|
* Add an error or append additional message to an existing error.
|
||||||
*
|
*
|
||||||
|
|
|
@ -161,7 +161,7 @@ final class WP_Customize_Custom_CSS_Setting extends WP_Customize_Setting {
|
||||||
$validity->add( 'illegal_markup', __( 'Markup is not allowed in CSS.' ) );
|
$validity->add( 'illegal_markup', __( 'Markup is not allowed in CSS.' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $validity->errors ) ) {
|
if ( ! $validity->has_errors() ) {
|
||||||
$validity = parent::validate( $css );
|
$validity = parent::validate( $css );
|
||||||
}
|
}
|
||||||
return $validity;
|
return $validity;
|
||||||
|
|
|
@ -470,7 +470,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller {
|
||||||
if ( is_multisite() ) {
|
if ( is_multisite() ) {
|
||||||
$ret = wpmu_validate_user_signup( $user->user_login, $user->user_email );
|
$ret = wpmu_validate_user_signup( $user->user_login, $user->user_email );
|
||||||
|
|
||||||
if ( is_wp_error( $ret['errors'] ) && ! empty( $ret['errors']->errors ) ) {
|
if ( is_wp_error( $ret['errors'] ) && $ret['errors']->has_errors() ) {
|
||||||
$error = new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
|
$error = new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) );
|
||||||
foreach ( $ret['errors']->errors as $code => $messages ) {
|
foreach ( $ret['errors']->errors as $code => $messages ) {
|
||||||
foreach ( $messages as $message ) {
|
foreach ( $messages as $message ) {
|
||||||
|
|
|
@ -2469,7 +2469,7 @@ function register_new_user( $user_login, $user_email ) {
|
||||||
*/
|
*/
|
||||||
$errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
|
$errors = apply_filters( 'registration_errors', $errors, $sanitized_user_login, $user_email );
|
||||||
|
|
||||||
if ( $errors->get_error_code() ) {
|
if ( $errors->has_errors() ) {
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.0-alpha-42760';
|
$wp_version = '5.0-alpha-42761';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
12
wp-login.php
12
wp-login.php
|
@ -53,7 +53,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = '' ) {
|
||||||
*/
|
*/
|
||||||
$shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
|
$shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
|
||||||
|
|
||||||
if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) {
|
if ( $shake_error_codes && $wp_error->has_errors() && in_array( $wp_error->get_error_code(), $shake_error_codes ) ) {
|
||||||
add_action( 'login_head', 'wp_shake_js', 12 );
|
add_action( 'login_head', 'wp_shake_js', 12 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = '' ) {
|
||||||
unset( $error );
|
unset( $error );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $wp_error->get_error_code() ) {
|
if ( $wp_error->has_errors() ) {
|
||||||
$errors = '';
|
$errors = '';
|
||||||
$messages = '';
|
$messages = '';
|
||||||
foreach ( $wp_error->get_error_codes() as $code ) {
|
foreach ( $wp_error->get_error_codes() as $code ) {
|
||||||
|
@ -341,7 +341,7 @@ function retrieve_password() {
|
||||||
*/
|
*/
|
||||||
do_action( 'lostpassword_post', $errors );
|
do_action( 'lostpassword_post', $errors );
|
||||||
|
|
||||||
if ( $errors->get_error_code() ) {
|
if ( $errors->has_errors() ) {
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ switch ( $action ) {
|
||||||
*/
|
*/
|
||||||
do_action( 'validate_password_reset', $errors, $user );
|
do_action( 'validate_password_reset', $errors, $user );
|
||||||
|
|
||||||
if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
|
if ( ( ! $errors->has_errors() ) && isset( $_POST['pass1'] ) && ! empty( $_POST['pass1'] ) ) {
|
||||||
reset_password( $user, $_POST['pass1'] );
|
reset_password( $user, $_POST['pass1'] );
|
||||||
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
|
setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );
|
||||||
login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' );
|
login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' );
|
||||||
|
@ -973,7 +973,7 @@ switch ( $action ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $interim_login ) {
|
if ( $interim_login ) {
|
||||||
if ( ! $errors->get_error_code() ) {
|
if ( ! $errors->has_errors() ) {
|
||||||
$errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' );
|
$errors->add( 'expired', __( 'Your session has expired. Please log in to continue where you left off.' ), 'message' );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1015,7 +1015,7 @@ switch ( $action ) {
|
||||||
}
|
}
|
||||||
$rememberme = ! empty( $_POST['rememberme'] );
|
$rememberme = ! empty( $_POST['rememberme'] );
|
||||||
|
|
||||||
if ( ! empty( $errors->errors ) ) {
|
if ( $errors->has_errors() ) {
|
||||||
$aria_describedby_error = ' aria-describedby="login_error"';
|
$aria_describedby_error = ' aria-describedby="login_error"';
|
||||||
} else {
|
} else {
|
||||||
$aria_describedby_error = '';
|
$aria_describedby_error = '';
|
||||||
|
|
|
@ -323,7 +323,7 @@ function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
|
||||||
|
|
||||||
echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>';
|
echo '<h2>' . sprintf( __( 'Get <em>another</em> %s site in seconds' ), get_network()->site_name ) . '</h2>';
|
||||||
|
|
||||||
if ( $errors->get_error_code() ) {
|
if ( $errors->has_errors() ) {
|
||||||
echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
|
echo '<p>' . __( 'There was a problem, please correct the form below and try again.' ) . '</p>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -389,7 +389,7 @@ function validate_another_blog_signup() {
|
||||||
$blog_title = $result['blog_title'];
|
$blog_title = $result['blog_title'];
|
||||||
$errors = $result['errors'];
|
$errors = $result['errors'];
|
||||||
|
|
||||||
if ( $errors->get_error_code() ) {
|
if ( $errors->has_errors() ) {
|
||||||
signup_another_blog( $blogname, $blog_title, $errors );
|
signup_another_blog( $blogname, $blog_title, $errors );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@ function validate_user_signup() {
|
||||||
$user_email = $result['user_email'];
|
$user_email = $result['user_email'];
|
||||||
$errors = $result['errors'];
|
$errors = $result['errors'];
|
||||||
|
|
||||||
if ( $errors->get_error_code() ) {
|
if ( $errors->has_errors() ) {
|
||||||
signup_user( $user_name, $user_email, $errors );
|
signup_user( $user_name, $user_email, $errors );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -729,7 +729,7 @@ function validate_blog_signup() {
|
||||||
$user_email = $user_result['user_email'];
|
$user_email = $user_result['user_email'];
|
||||||
$user_errors = $user_result['errors'];
|
$user_errors = $user_result['errors'];
|
||||||
|
|
||||||
if ( $user_errors->get_error_code() ) {
|
if ( $user_errors->has_errors() ) {
|
||||||
signup_user( $user_name, $user_email, $user_errors );
|
signup_user( $user_name, $user_email, $user_errors );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -741,7 +741,7 @@ function validate_blog_signup() {
|
||||||
$blog_title = $result['blog_title'];
|
$blog_title = $result['blog_title'];
|
||||||
$errors = $result['errors'];
|
$errors = $result['errors'];
|
||||||
|
|
||||||
if ( $errors->get_error_code() ) {
|
if ( $errors->has_errors() ) {
|
||||||
signup_blog( $user_name, $user_email, $blogname, $blog_title, $errors );
|
signup_blog( $user_name, $user_email, $blogname, $blog_title, $errors );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue