mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-11 18:46:03 +09:00
Move user profile error to image validation class
This commit is contained in:
@@ -83,25 +83,7 @@ class Display_Featured_Image_Genesis_Author extends Display_Featured_Image_Genes
|
||||
$validator = new DisplayFeaturedImageGenesisSettingsValidateImage();
|
||||
$new_value = $validator->validate_image( $new_value, $old_value, $user_object->display_name, $medium );
|
||||
|
||||
//TODO: check if this is set to fire
|
||||
add_filter( 'user_profile_update_errors', array( $this, 'user_profile_error_message' ), 10, 3 );
|
||||
update_user_meta( $user_id, $this->name, $new_value );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* User profile error message
|
||||
*
|
||||
* @param object $errors error message depending on what's wrong
|
||||
* @param bool $update whether or not to update
|
||||
* @param object $user user being updated
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function user_profile_error_message( $errors, $update, $user ) {
|
||||
/* translators: the user display name */
|
||||
$reset = sprintf( __( ' The %s Featured Image has been reset to the last valid setting.', 'display-featured-image-genesis' ), $user->display_name );
|
||||
|
||||
$errors->add( 'profile_error', $reset );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ class DisplayFeaturedImageGenesisSettingsValidateImage {
|
||||
esc_attr( $message ),
|
||||
'error'
|
||||
);
|
||||
add_filter( 'user_profile_update_errors', array( $this, 'user_profile_error_message' ), 10, 3 );
|
||||
} elseif ( method_exists( 'WP_Customize_Setting', 'validate' ) ) {
|
||||
return new WP_Error( esc_attr( $class ), esc_attr( $message ) );
|
||||
}
|
||||
@@ -74,6 +75,22 @@ class DisplayFeaturedImageGenesisSettingsValidateImage {
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* User profile error message
|
||||
*
|
||||
* @param object $errors error message depending on what's wrong
|
||||
* @param bool $existing_user existing user
|
||||
* @param object $user user being updated
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function user_profile_error_message( $errors, $existing_user, $user ) {
|
||||
/* translators: the user display name */
|
||||
$reset = sprintf( __( ' The %s Featured Image has been reset to the last valid setting.', 'display-featured-image-genesis' ), $user->display_name );
|
||||
|
||||
$errors->add( 'profile_error', $reset );
|
||||
}
|
||||
|
||||
/**
|
||||
* check if file type is image. updated to use WP function.
|
||||
* @return bool
|
||||
|
||||
Reference in New Issue
Block a user