]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/includes/credits.php
Wordpress 4.6
[autoinstalls/wordpress.git] / wp-admin / includes / credits.php
1 <?php
2 /**
3  * WordPress Credits Administration API.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  * @since 4.4.0
8  */
9
10 /**
11  * Retrieve the contributor credits.
12  *
13  * @global string $wp_version The current WordPress version.
14  *
15  * @since 3.2.0
16  *
17  * @return array|false A list of all of the contributors, or false on error.
18  */
19 function wp_credits() {
20         global $wp_version;
21         $locale = get_locale();
22
23         $results = get_site_transient( 'wordpress_credits_' . $locale );
24
25         if ( ! is_array( $results )
26                 || false !== strpos( $wp_version, '-' )
27                 || ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 )
28         ) {
29                 $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale" );
30
31                 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
32                         return false;
33
34                 $results = json_decode( wp_remote_retrieve_body( $response ), true );
35
36                 if ( ! is_array( $results ) )
37                         return false;
38
39                 set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
40         }
41
42         return $results;
43 }
44
45 /**
46  * Retrieve the link to a contributor's WordPress.org profile page.
47  *
48  * @access private
49  * @since 3.2.0
50  *
51  * @param string $display_name  The contributor's display name, passed by reference.
52  * @param string $username      The contributor's username.
53  * @param string $profiles      URL to the contributor's WordPress.org profile page.
54  */
55 function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
56         $display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
57 }
58
59 /**
60  * Retrieve the link to an external library used in WordPress.
61  *
62  * @access private
63  * @since 3.2.0
64  *
65  * @param string $data External library data, passed by reference.
66  */
67 function _wp_credits_build_object_link( &$data ) {
68         $data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
69 }