]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/includes/credits.php
WordPress 4.7.2
[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  * @since 3.2.0
14  *
15  * @return array|false A list of all of the contributors, or false on error.
16  */
17 function wp_credits() {
18         $wp_version = get_bloginfo( 'version' );
19         $locale = get_user_locale();
20
21         $results = get_site_transient( 'wordpress_credits_' . $locale );
22
23         if ( ! is_array( $results )
24                 || false !== strpos( $wp_version, '-' )
25                 || ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 )
26         ) {
27                 $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}" );
28
29                 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
30                         return false;
31
32                 $results = json_decode( wp_remote_retrieve_body( $response ), true );
33
34                 if ( ! is_array( $results ) )
35                         return false;
36
37                 set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
38         }
39
40         return $results;
41 }
42
43 /**
44  * Retrieve the link to a contributor's WordPress.org profile page.
45  *
46  * @access private
47  * @since 3.2.0
48  *
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.
52  */
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>';
55 }
56
57 /**
58  * Retrieve the link to an external library used in WordPress.
59  *
60  * @access private
61  * @since 3.2.0
62  *
63  * @param string $data External library data, passed by reference.
64  */
65 function _wp_credits_build_object_link( &$data ) {
66         $data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
67 }