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. git-svn-id: https://develop.svn.wordpress.org/trunk@48715 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
35a4b7bc24
commit
59ed4cbfc1
@ -11,23 +11,32 @@
|
||||
* Retrieve the contributor credits.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @since 5.6.0 Added the `$version` and `$locale` parameters.
|
||||
*
|
||||
* @param string $version WordPress version. Defaults to the current version.
|
||||
* @param string $locale WordPress locale. Defaults to the current user's locale.
|
||||
* @return array|false A list of all of the contributors, or false on error.
|
||||
*/
|
||||
function wp_credits() {
|
||||
// Include an unmodified $wp_version.
|
||||
require ABSPATH . WPINC . '/version.php';
|
||||
function wp_credits( $version = '', $locale = '' ) {
|
||||
if ( ! $version ) {
|
||||
// Include an unmodified $wp_version.
|
||||
require ABSPATH . WPINC . '/version.php';
|
||||
|
||||
$locale = get_user_locale();
|
||||
$version = $wp_version;
|
||||
}
|
||||
|
||||
if ( ! $locale ) {
|
||||
$locale = get_user_locale();
|
||||
}
|
||||
|
||||
$results = get_site_transient( 'wordpress_credits_' . $locale );
|
||||
|
||||
if ( ! is_array( $results )
|
||||
|| false !== strpos( $wp_version, '-' )
|
||||
|| ( isset( $results['data']['version'] ) && strpos( $wp_version, $results['data']['version'] ) !== 0 )
|
||||
|| false !== strpos( $version, '-' )
|
||||
|| ( isset( $results['data']['version'] ) && strpos( $version, $results['data']['version'] ) !== 0 )
|
||||
) {
|
||||
$url = "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}";
|
||||
$options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) );
|
||||
$url = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}";
|
||||
$options = array( 'user-agent' => 'WordPress/' . $version . '; ' . home_url( '/' ) );
|
||||
|
||||
if ( wp_http_supports( array( 'ssl' ) ) ) {
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
|
Loading…
Reference in New Issue
Block a user