wpseek.com
WordPress开发者和主题制作者的搜索引擎
wp_credits › WordPress Function
Since3.2.0
已弃用n/a
› wp_credits ( $version = '', $locale = '' )
参数: (2) |
|
返回: |
|
定义在: |
|
文档: | |
Change Log: |
|
Retrieves the contributor credits.
源码
function wp_credits( $version = '', $locale = '' ) { if ( ! $version ) { $version = wp_get_wp_version(); } if ( ! $locale ) { $locale = get_user_locale(); } $results = get_site_transient( 'wordpress_credits_' . $locale ); if ( ! is_array( $results ) || str_contains( $version, '-' ) || ( isset( $results['data']['version'] ) && ! str_starts_with( $version, $results['data']['version'] ) ) ) { $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; }