mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 10:22:23 +01:00
4a88d55054
By enabling the user to select their preferred locale when editing the profile, we allow for greater personalization of the WordPress admin and therefore a better user experience. The back end will be displayed in the user's individual locale while the locale used on the front end equals the one set for the whole site. If the user didn't specify a locale, the site's locale will be used as a fallback. The new `locale` property of the `WP_User` class can be used to retrieve the user's locale setting. Props ocean90, ipm-frommen, swissspidy. Fixes #29783. Built from https://develop.svn.wordpress.org/trunk@38705 git-svn-id: http://core.svn.wordpress.org/trunk@38648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* WordPress Credits Administration API.
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Administration
|
|
* @since 4.4.0
|
|
*/
|
|
|
|
/**
|
|
* Retrieve the contributor credits.
|
|
*
|
|
* @since 3.2.0
|
|
*
|
|
* @return array|false A list of all of the contributors, or false on error.
|
|
*/
|
|
function wp_credits() {
|
|
$wp_version = get_bloginfo( 'version' );
|
|
$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 )
|
|
) {
|
|
$response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version={$wp_version}&locale={$locale}" );
|
|
|
|
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
|
|
return false;
|
|
|
|
$results = json_decode( wp_remote_retrieve_body( $response ), true );
|
|
|
|
if ( ! is_array( $results ) )
|
|
return false;
|
|
|
|
set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
/**
|
|
* Retrieve the link to a contributor's WordPress.org profile page.
|
|
*
|
|
* @access private
|
|
* @since 3.2.0
|
|
*
|
|
* @param string $display_name The contributor's display name, passed by reference.
|
|
* @param string $username The contributor's username.
|
|
* @param string $profiles URL to the contributor's WordPress.org profile page.
|
|
*/
|
|
function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
|
|
$display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
|
|
}
|
|
|
|
/**
|
|
* Retrieve the link to an external library used in WordPress.
|
|
*
|
|
* @access private
|
|
* @since 3.2.0
|
|
*
|
|
* @param string $data External library data, passed by reference.
|
|
*/
|
|
function _wp_credits_build_object_link( &$data ) {
|
|
$data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
|
|
}
|