function get_settings_errors( $setting = '',
$sanitize = false
) { global $wp_settings_errors;
/*
* If $sanitize is true, manually re-run the sanitization for this option
* This allows the $sanitize_callback from register_setting() to run, adding
* any settings errors you want to show by default.
*/
if ( $sanitize ) { sanitize_option( $setting,
get_option( $setting ) );
} // If settings were passed back from options.php then use them.
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'
) );
delete_transient( 'settings_errors'
);
} // Check global in case errors have been added on this pageload.
if ( empty( $wp_settings_errors ) ) { return array
();
}