settings_errors

Definition:
function settings_errors( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {}

Display settings errors registered by add_settings_error()
Part of the Settings API. Outputs a <div> for each error retrieved by get_settings_errors().

Parameters

  • string $setting: Optional slug title of a specific setting who’s errors you want.
  • boolean $sanitize: Whether to re-sanitize the setting value before returning errors.
  • boolean $hide_on_update: If set to true errors will not be shown if the settings page has already been submitted.

Source code

function settings_errors( $setting = '', $sanitize = FALSE, $hide_on_update = FALSE ) {



	if ($hide_on_update AND $_GET['settings-updated']) return;



	$settings_errors = get_settings_errors( $setting, $sanitize );



	if ( !is_array($settings_errors) ) return;



	$output = '';

	foreach ( $settings_errors as $key => $details ) {

		$css_id = 'setting-error-' . $details['code'];

		$css_class = $details['type'] . ' settings-error';

		$output .= "<div id='$css_id' class='$css_class'> \n";

		$output .= "<p><strong>{$details['message']}</strong></p>";

		$output .= "</div> \n";

	}

2833

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: