函数原型
add_settings_error( string $setting, string $code, string $message, string $type = ‘error’ )
函数描述
Registers a settings error to be displayed to the user.
是否弃用
未弃用
函数参数
-
$setting
string
Required - Slug title of the setting to which this error applies.
-
$code
string
Required - Slug-name to identify the error. Used as part of
'id'attribute in HTML output. -
$message
string
Required - The formatted message text to display to the user (will be shown inside styled
<div>and<p>tags). -
$type
string
Optional - Message type, controls HTML class. Possible values include
'error','success','warning','info'. Default'error'.Default:
'error'
函数返回值
无
函数位置
File: wp-admin/includes/template.php.
函数源码
function add_settings_error( $setting, $code, $message, $type = 'error' ) {
global $wp_settings_errors;
$wp_settings_errors[] = array(
'setting' => $setting,
'code' => $code,
'message' => $message,
'type' => $type,
);
}
源码链接
变更日志
| Version | Description |
|---|---|
| 5.3.0 | Added warning and info as possible values for $type. |
| 3.0.0 | Introduced. |

