3 * WordPress Credits Administration API.
6 * @subpackage Administration
11 * Retrieve the contributor credits.
15 * @return array|false A list of all of the contributors, or false on error.
17 function wp_credits() {
18 $wp_version = get_bloginfo( 'version' );
19 $locale = get_user_locale();
21 $results = get_site_transient( 'wordpress_credits_' . $locale );
23 if ( ! is_array( $results )
24 || false !== strpos( $wp_version, '-' )
25 || ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 )
27 $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}" );
29 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
32 $results = json_decode( wp_remote_retrieve_body( $response ), true );
34 if ( ! is_array( $results ) )
37 set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
44 * Retrieve the link to a contributor's WordPress.org profile page.
49 * @param string $display_name The contributor's display name, passed by reference.
50 * @param string $username The contributor's username.
51 * @param string $profiles URL to the contributor's WordPress.org profile page.
53 function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
54 $display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
58 * Retrieve the link to an external library used in WordPress.
63 * @param string $data External library data, passed by reference.
65 function _wp_credits_build_object_link( &$data ) {
66 $data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';