WordPress函数:get_status_header_desc
WordPress提供了很多方便函数。比如,get_status_header_desc,其作用就是根据 http 状态码,返回对应的状态描述。
函数原型:
get_status_header_desc( int $code )
函数源码:
function get_status_header_desc( $code ) {
global $wp_header_to_desc;
$code = absint( $code );
if ( ! isset( $wp_header_to_desc ) ) {
$wp_header_to_desc = array(
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing',
103 => 'Early Hints',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
207 => 'Multi-Status',
226 => 'IM Used',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
306 => 'Reserved',
307 => 'Temporary Redirect',
308 => 'Permanent Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
418 => 'I\'m a teapot',
421 => 'Misdirected Request',
422 => 'Unprocessable Entity',
423 => 'Locked',
424 => 'Failed Dependency',
426 => 'Upgrade Required',
428 => 'Precondition Required',
429 => 'Too Many Requests',
431 => 'Request Header Fields Too Large',
451 => 'Unavailable For Legal Reasons',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported',
506 => 'Variant Also Negotiates',
507 => 'Insufficient Storage',
510 => 'Not Extended',
511 => 'Network Authentication Required',
);
}
if ( isset( $wp_header_to_desc[ $code ] ) ) {
return $wp_header_to_desc[ $code ];
} else {
return '';
}
}
get_status_header_desc 函数使用起来很简单,源码实现也很简单。不过,也很有用,避免用到的时候还要百度,重复造轮子。
-
WordPress技巧:修改评论显示顺序的方法WordPress默认评论信息为老的在前新的在后,若我们想按降序显示,即新的显示在前应如何操作?其实我们只需使用array_reverse()函数即可解决,函数返回数组的逆序。
-
WordPress用户头像和后台管理员头像不显示的解决办法常有小伙伴问追格小编,说WordPress用户头像和后台管理员头像不显示,是否有啥解决办法。若使用的WordPress主题没有自定义头像功能的话,有可能会出现上述所说问题。
-
WordPress小程序直播之追格小程序微信直播模块追格“直播”插件(模块)基于追格小程序(基于WordPress)和微信小程序直播组件开发,人生如戏,每个人都是生活的导演。
-
chatGPT火了,我们却依旧在坚持 WordPress把 WordPress 小程序做的更好一点
-
WordPress函数:get_post_field 获取文章字段直接获取文章的字段
-
访问量不大的 WordPress 站点,wp-cron还有效吗?wp-cron 能够正确运行的场景
暂无评论,抢个沙发...