返回介绍

get_core_checksums()

发布于 2017-09-10 23:10:09 字数 3115 浏览 1041 评论 0 收藏 0

get_core_checksums( string $version,  string $locale )

Gets and caches the checksums for the given version of WordPress.


description


参数

$version

(string) (Required) Version string to query.

$locale

(string) (Required) Locale to query.


返回值

(bool|array) False on failure. An array of checksums on success.


源代码

File: wp-admin/includes/update.php

function get_core_checksums( $version, $locale ) {
	$url = $http_url = 'http://api.wordpress.org/core/checksums/1.0/?' . http_build_query( compact( 'version', 'locale' ), null, '&' );

	if ( $ssl = wp_http_supports( array( 'ssl' ) ) )
		$url = set_url_scheme( $url, 'https' );

	$options = array(
		'timeout' => wp_doing_cron() ? 30 : 3,
	);

	$response = wp_remote_get( $url, $options );
	if ( $ssl && is_wp_error( $response ) ) {
		trigger_error(
			sprintf(
				/* translators: %s: support forums URL */
				__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
				__( 'https://wordpress.org/support/' )
			) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
			headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
		);
		$response = wp_remote_get( $http_url, $options );
	}

	if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
		return false;

	$body = trim( wp_remote_retrieve_body( $response ) );
	$body = json_decode( $body, true );

	if ( ! is_array( $body ) || ! isset( $body['checksums'] ) || ! is_array( $body['checksums'] ) )
		return false;

	return $body['checksums'];
}

更新日志

Versiondescription
3.7.0Introduced.

相关函数

Uses

  • wp-includes/load.php: wp_doing_cron()
  • wp-includes/compat.php: json_decode()
  • wp-includes/l10n.php: __()
  • wp-includes/link-template.php: set_url_scheme()
  • wp-includes/http.php: wp_http_supports()
  • wp-includes/http.php: wp_remote_get()
  • wp-includes/http.php: wp_remote_retrieve_response_code()
  • wp-includes/http.php: wp_remote_retrieve_body()
  • wp-includes/load.php: is_wp_error()
  • Show 4 more uses Hide more uses

Used By

  • wp-admin/includes/class-core-upgrader.php: Core_Upgrader::check_files()
  • wp-admin/includes/update-core.php: update_core()

User Contributed Notes

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

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

发布评论

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