WordPress.org

Make WordPress Core

Changeset 48715


Ignore:
Timestamp:
08/03/2020 12:51:22 PM (16 months ago)
Author:
SergeyBiryukov
Message:

Administration: Allow wp_credits() to accept $version and $locale parameters.

This can be helpful for plugin developers to get credits information for older versions or different locales.

Props ramiy.
Fixes #35910.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/credits.php

    r47198 r48715  
    1212 *
    1313 * @since 3.2.0
     14 * @since 5.6.0 Added the `$version` and `$locale` parameters.
    1415 *
     16 * @param string $version WordPress version. Defaults to the current version.
     17 * @param string $locale  WordPress locale. Defaults to the current user's locale.
    1518 * @return array|false A list of all of the contributors, or false on error.
    1619 */
    17 function wp_credits() {
    18     // Include an unmodified $wp_version.
    19     require ABSPATH . WPINC . '/version.php';
     20function wp_credits( $version = '', $locale = '' ) {
     21    if ( ! $version ) {
     22        // Include an unmodified $wp_version.
     23        require ABSPATH . WPINC . '/version.php';
    2024
    21     $locale = get_user_locale();
     25        $version = $wp_version;
     26    }
     27
     28    if ( ! $locale ) {
     29        $locale = get_user_locale();
     30    }
    2231
    2332    $results = get_site_transient( 'wordpress_credits_' . $locale );
    2433
    2534    if ( ! is_array( $results )
    26         || false !== strpos( $wp_version, '-' )
    27         || ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 )
     35        || false !== strpos( $version, '-' )
     36        || ( isset( $results['data']['version'] ) && strpos( $version, $results['data']['version'] ) !== 0 )
    2837    ) {
    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( '/' ) );
     38        $url     = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}";
     39        $options = array( 'user-agent' => 'WordPress/' . $version . '; ' . home_url( '/' ) );
    3140
    3241        if ( wp_http_supports( array( 'ssl' ) ) ) {
Note: See TracChangeset for help on using the changeset viewer.