Credits screen redux. Add external libraries, gravatars for language validators. Backed by a new API. fixes #17518, fixes #17532.

git-svn-id: http://svn.automattic.com/wordpress/trunk@18162 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2011-06-06 06:38:29 +00:00
parent df4ec51f8a
commit cef8b6662f
1 changed files with 65 additions and 37 deletions

View File

@ -24,16 +24,22 @@ add_contextual_help($current_screen,
add_action( 'admin_head', '_wp_credits_add_css' );
function _wp_credits_add_css() { ?>
<style type="text/css">
h3.wp-people-group, h3.wp-props-group { clear: both; }
div.wrap { max-width: 750px }
h3.wp-people-group, p.wp-credits-list { clear: both; }
ul.compact { margin-bottom: 0 }
<?php if ( is_rtl() ) { ?>
ul.wp-people-group { margin-bottom: 30px; float: right; clear: both; }
li.wp-person { float: right; height: 70px; width: 220px; margin-left: 10px; }
li.wp-person img.gravatar { float: right; margin-left: 10px; margin-bottom: 10px; width: 60px; height: 60px }
li.wp-person img.gravatar { float: right; margin-left: 10px; margin-bottom: 10px; }
<?php } else { ?>
ul.wp-people-group { margin-bottom: 30px; float: left; clear: both; }
li.wp-person { float: left; height: 70px; width: 220px; margin-right: 10px; }
li.wp-person img.gravatar { float: left; margin-right: 10px; margin-bottom: 10px; width: 60px; height: 60px }
li.wp-person { float: left; margin-right: 10px; }
li.wp-person img.gravatar { float: left; margin-right: 10px; margin-bottom: 10px; }
<?php } ?>
li.wp-person img.gravatar { width: 60px; height: 60px; }
ul.compact li.wp-person img.gravatar { width: 30px; height: 30px; }
li.wp-person { height: 70px; width: 220px; }
ul.compact li.wp-person { height: 40px; width: auto; white-space: nowrap }
li.wp-person a.web { font-size: 16px; text-decoration: none; }
</style>
<?php }
@ -44,13 +50,13 @@ function wp_credits() {
$results = get_site_transient( 'wordpress_credits_' . $locale );
if ( ! is_array( $results ) || ! isset( $results['people'] ) || ! isset( $results['lists'] ) ) {
$response = wp_remote_get( "http://api.wordpress.org/core/credits/1.0/?version=$wp_version&locale=$locale" );
if ( ! is_array( $results ) ) {
$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 = unserialize( wp_remote_retrieve_body( $response ) );
$results = maybe_unserialize( wp_remote_retrieve_body( $response ) );
if ( ! is_array( $results ) )
return false;
@ -61,8 +67,12 @@ function wp_credits() {
return $results;
}
function _wp_credits_add_profile_link( &$display_name, $username, $prefix ) {
$display_name = '<a href="' . esc_url( $prefix . $username ) . '">' . esc_html( $display_name ) . '</a>';
function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
$display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
}
function _wp_credits_build_object_link( &$data ) {
$data = '<a href="' . esc_url( $data[1] ) . '">' . $data[0] . '</a>';
}
include( './admin-header.php' );
@ -73,9 +83,9 @@ include( './admin-header.php' );
<?php
$results = wp_credits();
$credits = wp_credits();
if ( ! $results ) {
if ( ! $credits ) {
echo '<p>' . sprintf( __( 'WordPress is created by a <a href="%1$s">worldwide team</a> of passionate individuals. <a href="%2$s">Get involved in WordPress</a>.' ),
'http://wordpress.org/about/',
/* translators: Url to the codex documentation on contributing to WordPress used on the credits page */
@ -88,33 +98,49 @@ echo '<p>' . __( 'WordPress is created by a worldwide team of passionate individ
$gravatar = is_ssl() ? 'https://secure.gravatar.com/avatar/' : 'http://0.gravatar.com/avatar/';
foreach ( (array) $results['people'] as $group_slug => $members ) {
echo '<h3 class="wp-people-group">' . translate( $results['groups'][ $group_slug ] ) . "</h3>\n";
echo '<ul class="wp-people-group" id="wp-people-group-' . $group_slug . '">' . "\n";
shuffle( $members ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
foreach ( $members as $member_slug => $member ) {
echo '<li class="wp-person" id="wp-person-' . $member_slug . '">' . "\n\t";
echo '<a href="' . $results['data']['profile_prefix'] . $member[2] . '"><img src="' . $gravatar . $member[3] . '?s=60" class="gravatar" alt="' . esc_attr( $member[0] ) . '" /></a>' . "\n\t";
echo '<a class="web" href="' . $results['data']['profile_prefix'] . $member[2] . '">' . $member[0] . "</a>\n\t";
echo '<br /><span class="title">' . translate( $member[1] ) . "</span>\n</li>\n";
}
echo "</ul>\n";
}
foreach ( $credits['groups'] as $group_slug => $group_data ) {
if ( $group_data['name'] ) {
if ( 'Translators' == $group_data['name'] ) {
// Considered a special slug in the API response. (Also, will never be returned for en_US.)
$title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
} elseif ( isset( $group_data['placeholders'] ) ) {
$title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
} else {
$title = $group_data['name'];
}
foreach ( (array) $results['lists'] as $group_slug => $members ) {
if ( $group_slug === 'translators' ) {
// Considered a special slug in the API response. (Also, will never be returned for en_US.)
$title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
} else {
$title = translate( $results['groups'][ $group_slug ] );
if ( isset( $results['data']['placeholders'][ $group_slug ] ) )
$title = vsprintf( $title, $results['data']['placeholders'][ $group_slug ] );
echo '<h3 class="wp-people-group">' . $title . "</h3>\n";
}
echo '<h3 class="wp-props-group">' . $title . "</h3>\n\n";
array_walk( $members, '_wp_credits_add_profile_link', $results['data']['profile_prefix'] );
shuffle( $members );
echo '<p>' . wp_sprintf( '%l.', $members ) . "</p>\n\n";
if ( ! empty( $group_data['shuffle'] ) )
shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
switch ( $group_data['type'] ) {
case 'list' :
array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits['data']['profiles'] );
echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
break;
case 'libraries' :
array_walk( $group_data['data'], '_wp_credits_build_object_link' );
echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
break;
default:
$compact = 'compact' == $group_data['type'];
$classes = 'wp-people-group ' . ( $compact ? 'compact' : '' );
echo '<ul class="' . $classes . '" id="wp-people-group-' . $group_slug . '">' . "\n";
foreach ( $group_data['data'] as $person_data ) {
echo '<li class="wp-person" id="wp-person-' . $person_data[2] . '">' . "\n\t";
echo '<a href="' . sprintf( $credits['data']['profiles'], $person_data[2] ) . '">';
$size = 'compact' == $group_data['type'] ? '30' : '60';
echo '<img src="' . $gravatar . $person_data[1] . '?s=' . $size . '" class="gravatar" alt="' . esc_attr( $person_data[0] ) . '" /></a>' . "\n\t";
echo '<a class="web" href="' . sprintf( $credits['data']['profiles'], $person_data[2] ) . '">' . $person_data[0] . "</a>\n\t";
if ( ! $compact )
echo '<br /><span class="title">' . translate( $person_data[3] ) . "</span>\n";
echo "</li>\n";
}
echo "</ul>\n";
break;
}
}
?>
@ -137,10 +163,12 @@ __( 'Core Contributors to WordPress %s' );
__( 'Cofounder, Project Lead' );
__( 'Lead Developer' );
__( 'User Experience Lead' );
__( 'Developer, Core Committer' );
__( 'Core Committer' );
__( 'Guest Committer' );
__( 'Developer' );
__( 'Designer' );
__( 'XML-RPC Developer' );
__( 'Internationalization' );
__( 'External Libraries' );
?>