On this page
wp_credits( string $version = '', string $locale = '' ): array|false
Retrieve the contributor credits.
Parameters
$versionstring Optional-
WordPress version. Defaults to the current version.
Default:
'' $localestring Optional-
WordPress locale. Defaults to the current user's locale.
Default:
''
Return
array|false A list of all of the contributors, or false on error.
Source
File: wp-admin/includes/credits.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| get_user_locale() wp-includes/l10n.php | Retrieves the locale of a user. |
| set_url_scheme() wp-includes/link-template.php | Sets the scheme for a URL. |
| wp_http_supports() wp-includes/http.php | Determines if there is an HTTP Transport that can process this request. |
| wp_remote_get() wp-includes/http.php | Performs an HTTP request using the GET method and returns its response. |
| wp_remote_retrieve_response_code() wp-includes/http.php | Retrieve only the response code from the raw response. |
| wp_remote_retrieve_body() wp-includes/http.php | Retrieve only the body from the raw response. |
| set_site_transient() wp-includes/option.php | Sets/updates the value of a site transient. |
| get_site_transient() wp-includes/option.php | Retrieves the value of a site transient. |
| home_url() wp-includes/link-template.php | Retrieves the URL for the current site where the front end is accessible. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_credits