wp_credits

函数
wp_credits ( $version = '', $locale = '' )
参数
  • (string) $version WordPress version. Defaults to the current version.
    Required:
    Default: (empty)
  • (string) $locale WordPress locale. Defaults to the current user's locale.
    Required:
    Default: (empty)
返回值
  • (array|false) A list of all of the contributors, or false on error.
定义位置
相关方法
wp_scriptswp_redirectwp_editorwp_script_iswp_register
引入
3.2.0
弃用
-

wp_credits: 这是一个显示帮助建立当前版本的WordPress的贡献者的函数。它可以用来给那些为WordPress的发展做出贡献的人以荣誉。

检索贡献者的信用。

function wp_credits( $version = '', $locale = '' ) {
	if ( ! $version ) {
		// Include an unmodified $wp_version.
		require ABSPATH . WPINC . '/version.php';

		$version = $wp_version;
	}

	if ( ! $locale ) {
		$locale = get_user_locale();
	}

	$results = get_site_transient( 'wordpress_credits_' . $locale );

	if ( ! is_array( $results )
		|| false !== strpos( $version, '-' )
		|| ( isset( $results['data']['version'] ) && strpos( $version, $results['data']['version'] ) !== 0 )
	) {
		$url     = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}";
		$options = array( 'user-agent' => 'WordPress/' . $version . '; ' . home_url( '/' ) );

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

		$response = wp_remote_get( $url, $options );

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

		$results = json_decode( wp_remote_retrieve_body( $response ), true );

		if ( ! is_array( $results ) ) {
			return false;
		}

		set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
	}

	return $results;
}

常见问题

FAQs
查看更多 >