返回介绍

wp_remote_retrieve_response_code()

发布于 2017-09-11 12:45:23 字数 3026 浏览 1245 评论 0 收藏 0

wp_remote_retrieve_response_code( array $response )

Retrieve only the response code from the raw response.


description

Will return an empty array if incorrect parameter value is given.


参数

$response

(array) (Required) HTTP response.


返回值

(int|string) The response code as an integer. Empty string on incorrect parameter given.


源代码

File: wp-includes/http.php

function wp_remote_retrieve_response_code( $response ) {
	if ( is_wp_error($response) || ! isset($response['response']) || ! is_array($response['response']))
		return '';

	return $response['response']['code'];
}

更新日志

Versiondescription
2.7.0Introduced.

相关函数

Uses

  • wp-includes/load.php: is_wp_error()

Used By

  • wp-admin/includes/class-wp-community-events.php: WP_Community_Events::get_events()
  • wp-admin/includes/schema.php: populate_network()
  • wp-admin/includes/update.php: get_core_checksums()
  • wp-admin/includes/dashboard.php: wp_check_browser_version()
  • wp-admin/includes/file.php: download_url()
  • wp-admin/includes/credits.php: wp_credits()
  • wp-includes/deprecated.php: url_is_accessable_via_ssl()
  • wp-includes/deprecated.php: wp_get_http()
  • wp-includes/class-wp-simplepie-file.php: WP_SimplePie_File::__construct()
  • wp-includes/update.php: wp_version_check()
  • wp-includes/update.php: wp_update_plugins()
  • wp-includes/update.php: wp_update_themes()
  • wp-includes/class-oembed.php: WP_oEmbed::_fetch_with_format()
  • wp-includes/class-wp-http-ixr-client.php: WP_HTTP_IXR_Client::query()
  • wp-includes/rss.php: _fetch_remote_file()
  • Show 10 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    Examples

    
    $response = wp_remote_get( 'http://www.foo.com/file.txt' );
    $response_code = wp_remote_retrieve_response_code( $response );
    

    $response code will contain a string representing the numeric response code sent from the server

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文