I used the sanitize method to make the custom validation, in case of failure returned an error
public function sanitize($input) {
if(true) {
// There is an error
add_settings_error( 'general', 'settings_updated', __( "Message" ), 'error' );
set_transient( 'settings_errors', get_settings_errors(), 30 );
// Redirect back to the settings page that was submitted.
$goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() );
wp_redirect( $goback );
exit;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…