[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/includes/ -> credits.php (source)

   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      // include an unmodified $wp_version
  19      include ( ABSPATH . WPINC . '/version.php' );
  20  
  21      $locale = get_user_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          $url     = "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}";
  30          $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
  31  
  32          if ( wp_http_supports( array( 'ssl' ) ) ) {
  33              $url = set_url_scheme( $url, 'https' );
  34          }
  35  
  36          $response = wp_remote_get( $url, $options );
  37  
  38          if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
  39              return false;
  40          }
  41  
  42          $results = json_decode( wp_remote_retrieve_body( $response ), true );
  43  
  44          if ( ! is_array( $results ) ) {
  45              return false;
  46          }
  47  
  48          set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
  49      }
  50  
  51      return $results;
  52  }
  53  
  54  /**
  55   * Retrieve the link to a contributor's WordPress.org profile page.
  56   *
  57   * @access private
  58   * @since 3.2.0
  59   *
  60   * @param string $display_name  The contributor's display name (passed by reference).
  61   * @param string $username      The contributor's username.
  62   * @param string $profiles      URL to the contributor's WordPress.org profile page.
  63   */
  64  function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
  65      $display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
  66  }
  67  
  68  /**
  69   * Retrieve the link to an external library used in WordPress.
  70   *
  71   * @access private
  72   * @since 3.2.0
  73   *
  74   * @param string $data External library data (passed by reference).
  75   */
  76  function _wp_credits_build_object_link( &$data ) {
  77      $data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
  78  }


Generated: Fri Oct 25 08:20:01 2019 Cross-referenced by PHPXref 0.7