/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. return $results; 
  40.  
  41. /** 
  42. * Retrieve the link to a contributor's WordPress.org profile page. 
  43. * 
  44. * @access private 
  45. * @since 3.2.0 
  46. * 
  47. * @param string $display_name The contributor's display name, passed by reference. 
  48. * @param string $username The contributor's username. 
  49. * @param string $profiles URL to the contributor's WordPress.org profile page. 
  50. */ 
  51. function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) { 
  52. $display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>'; 
  53.  
  54. /** 
  55. * Retrieve the link to an external library used in WordPress. 
  56. * 
  57. * @access private 
  58. * @since 3.2.0 
  59. * 
  60. * @param string $data External library data, passed by reference. 
  61. */ 
  62. function _wp_credits_build_object_link( &$data ) { 
  63. $data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>'; 
.