Administration: Adjust [45814] to address a backward compatibility issue for plugins passing multiple CSS classes to add_settings_error().

Only add the `notice-` prefix for `error`, `success`, `warning`, `info` CSS classes, keep other classes as is.

Add unit tests for `settings_errors()`.

Props afercia, SergeyBiryukov.
Fixes #44941.
Built from https://develop.svn.wordpress.org/trunk@45873


git-svn-id: http://core.svn.wordpress.org/trunk@45684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-08-22 00:22:56 +00:00
parent 36b4debdb4
commit f6fc8025c4
2 changed files with 8 additions and 4 deletions

View File

@ -1814,13 +1814,17 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa
$details['type'] = 'success';
}
if ( in_array( $details['type'], array( 'error', 'success', 'warning', 'info' ) ) ) {
$details['type'] = 'notice-' . $details['type'];
}
$css_id = sprintf(
'setting-error-%s',
sanitize_html_class( $details['code'] )
esc_attr( $details['code'] )
);
$css_class = sprintf(
'notice notice-%s settings-error is-dismissible',
sanitize_html_class( $details['type'] )
'notice %s settings-error is-dismissible',
esc_attr( $details['type'] )
);
$output .= "<div id='$css_id' class='$css_class'> \n";

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.3-alpha-45872';
$wp_version = '5.3-alpha-45873';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.