For get_settings_errors(), make sure errors from transient get added to the global variable and not unset when checking for an error of a specific setting. Also always return an array, as noted in the documentation. Props obenland. fixes #20833
git-svn-id: https://develop.svn.wordpress.org/trunk@21315 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
249a540660
commit
2c0f98fe49
|
@ -1224,27 +1224,30 @@ function get_settings_errors( $setting = '', $sanitize = false ) {
|
||||||
// This allows the $sanitize_callback from register_setting() to run, adding
|
// This allows the $sanitize_callback from register_setting() to run, adding
|
||||||
// any settings errors you want to show by default.
|
// any settings errors you want to show by default.
|
||||||
if ( $sanitize )
|
if ( $sanitize )
|
||||||
sanitize_option( $setting, get_option($setting));
|
sanitize_option( $setting, get_option( $setting ) );
|
||||||
|
|
||||||
// If settings were passed back from options.php then use them
|
// If settings were passed back from options.php then use them
|
||||||
// Ignore transients if $sanitize is true, we don't want the old values anyway
|
if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) {
|
||||||
if ( isset($_GET['settings-updated']) && $_GET['settings-updated'] && get_transient('settings_errors') ) {
|
$wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) );
|
||||||
$settings_errors = get_transient('settings_errors');
|
delete_transient( 'settings_errors' );
|
||||||
delete_transient('settings_errors');
|
}
|
||||||
// Otherwise check global in case validation has been run on this pageload
|
|
||||||
} elseif ( count( $wp_settings_errors ) ) {
|
// Check global in case errors have been added on this pageload
|
||||||
$settings_errors = $wp_settings_errors;
|
if ( ! count( $wp_settings_errors ) ) {
|
||||||
} else {
|
return array();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter the results to those of a specific setting if one was set
|
// Filter the results to those of a specific setting if one was set
|
||||||
if ( $setting ) {
|
if ( $setting ) {
|
||||||
foreach ( (array) $settings_errors as $key => $details )
|
foreach ( (array) $wp_settings_errors as $key => $details ) {
|
||||||
if ( $setting != $details['setting'] )
|
debug_log( $details['setting'] );
|
||||||
unset( $settings_errors[$key] );
|
if ( $setting == $details['setting'] )
|
||||||
|
$setting_errors[] = $wp_settings_errors[$key];
|
||||||
|
}
|
||||||
|
return $setting_errors;
|
||||||
}
|
}
|
||||||
return $settings_errors;
|
|
||||||
|
return $wp_settings_errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1276,7 +1279,7 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
|
||||||
|
|
||||||
$settings_errors = get_settings_errors( $setting, $sanitize );
|
$settings_errors = get_settings_errors( $setting, $sanitize );
|
||||||
|
|
||||||
if ( ! is_array( $settings_errors ) )
|
if ( empty( $settings_errors ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
Loading…
Reference in New Issue