GC_Error::get_error_messages()
最后更新于:2021-11-27 14:44:10
GC_Error::get_error_messages( string|int$code=”)Retrieves all error messages, or the error messages for the given error code.
参数
- $code
-
(string|int) (Optional) Retrieve messages matching code, if exists.
Default value: ”
响应
(array) Error strings on success, or empty array if there are none.
源文件
文件: gc-includes/class-gc-error.php
public function get_error_messages( $code = '' ) {
// 响应 all messages if no code specified.
if ( empty( $code ) ) {
$all_messages = array();
foreach ( (array) $this->errors as $code => $messages ) {
$all_messages = array_merge( $all_messages, $messages );
}
return $all_messages;
}
if ( isset( $this->errors[ $code ] ) ) {
return $this->errors[ $code ];
} else {
return array();
}
}