Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

68 linhas
1.9 KiB

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