Make WordPress Core

Changeset 18162


Ignore:
Timestamp:
06/06/2011 06:38:29 AM (14 years ago)
Author:
nacin
Message:

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

File:
1 edited

Legend:

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

    r18149 r18162  
    2525function _wp_credits_add_css() { ?>
    2626<style type="text/css">
    27 h3.wp-people-group, h3.wp-props-group { clear: both; }
     27div.wrap { max-width: 750px }
     28h3.wp-people-group, p.wp-credits-list { clear: both; }
     29ul.compact { margin-bottom: 0 }
     30
    2831<?php if ( is_rtl() ) { ?>
    2932ul.wp-people-group { margin-bottom: 30px; float: right; clear: both; }
    3033li.wp-person { float: right; height: 70px; width: 220px; margin-left: 10px; }
    31 li.wp-person img.gravatar { float: right; margin-left: 10px; margin-bottom: 10px; width: 60px; height: 60px }
     34li.wp-person img.gravatar { float: right; margin-left: 10px; margin-bottom: 10px; }
    3235<?php } else { ?>
    33 ul.wp-people-group { margin-bottom: 30px; float: left; clear: both; }
    34 li.wp-person { float: left; height: 70px; width: 220px; margin-right: 10px; }
    35 li.wp-person img.gravatar { float: left; margin-right: 10px; margin-bottom: 10px; width: 60px; height: 60px }
     36li.wp-person { float: left; margin-right: 10px; }
     37li.wp-person img.gravatar { float: left; margin-right: 10px; margin-bottom: 10px; }
    3638<?php } ?>
     39li.wp-person img.gravatar { width: 60px; height: 60px; }
     40ul.compact li.wp-person img.gravatar { width: 30px; height: 30px; }
     41li.wp-person { height: 70px; width: 220px; }
     42ul.compact li.wp-person { height: 40px; width: auto; white-space: nowrap }
    3743li.wp-person a.web { font-size: 16px; text-decoration: none; }
    3844</style>
     
    4551    $results = get_site_transient( 'wordpress_credits_' . $locale );
    4652
    47     if ( ! is_array( $results ) || ! isset( $results['people'] ) || ! isset( $results['lists'] ) ) {
    48         $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.0/?version=$wp_version&locale=$locale" );
     53    if ( ! is_array( $results ) ) {
     54        $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale" );
    4955
    5056        if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
    5157            return false;
    5258
    53         $results = unserialize( wp_remote_retrieve_body( $response ) );
     59        $results = maybe_unserialize( wp_remote_retrieve_body( $response ) );
    5460
    5561        if ( ! is_array( $results ) )
     
    6268}
    6369
    64 function _wp_credits_add_profile_link( &$display_name, $username, $prefix ) {
    65     $display_name = '<a href="' . esc_url( $prefix . $username ) . '">' . esc_html( $display_name ) . '</a>';
     70function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
     71    $display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
     72}
     73
     74function _wp_credits_build_object_link( &$data ) {
     75    $data = '<a href="' . esc_url( $data[1] ) . '">' . $data[0] . '</a>';
    6676}
    6777
     
    7484<?php
    7585
    76 $results = wp_credits();
     86$credits = wp_credits();
    7787
    78 if ( ! $results ) {
     88if ( ! $credits ) {
    7989    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>.' ),
    8090        'http://wordpress.org/about/',
     
    8999$gravatar = is_ssl() ? 'https://secure.gravatar.com/avatar/' : 'http://0.gravatar.com/avatar/';
    90100
    91 foreach ( (array) $results['people'] as $group_slug => $members ) {
    92     echo '<h3 class="wp-people-group">' . translate( $results['groups'][ $group_slug ] ) . "</h3>\n";
    93     echo '<ul class="wp-people-group" id="wp-people-group-' . $group_slug . '">' . "\n";
    94     shuffle( $members ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
    95     foreach ( $members as $member_slug => $member ) {
    96         echo '<li class="wp-person" id="wp-person-' . $member_slug . '">' . "\n\t";
    97         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";
    98         echo '<a class="web" href="' . $results['data']['profile_prefix'] . $member[2] . '">' . $member[0] . "</a>\n\t";
    99         echo '<br /><span class="title">' . translate( $member[1] ) . "</span>\n</li>\n";
    100     }
    101     echo "</ul>\n";
    102 }
     101foreach ( $credits['groups'] as $group_slug => $group_data ) {
     102    if ( $group_data['name'] ) {
     103        if ( 'Translators' == $group_data['name'] ) {
     104            // Considered a special slug in the API response. (Also, will never be returned for en_US.)
     105            $title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
     106        } elseif ( isset( $group_data['placeholders'] ) ) {
     107            $title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
     108        } else {
     109            $title = $group_data['name'];
     110        }
    103111
    104 foreach ( (array) $results['lists'] as $group_slug => $members ) {
    105     if ( $group_slug === 'translators' ) {
    106         // Considered a special slug in the API response. (Also, will never be returned for en_US.)
    107         $title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
    108     } else {
    109         $title = translate( $results['groups'][ $group_slug ] );
    110         if ( isset( $results['data']['placeholders'][ $group_slug ] ) )
    111             $title = vsprintf( $title, $results['data']['placeholders'][ $group_slug ] );
     112        echo '<h3 class="wp-people-group">' . $title . "</h3>\n";
    112113    }
    113114
    114     echo '<h3 class="wp-props-group">' . $title . "</h3>\n\n";
    115     array_walk( $members, '_wp_credits_add_profile_link', $results['data']['profile_prefix'] );
    116     shuffle( $members );
    117     echo '<p>' . wp_sprintf( '%l.', $members ) . "</p>\n\n";
     115    if ( ! empty( $group_data['shuffle'] ) )
     116        shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
     117
     118    switch ( $group_data['type'] ) {
     119        case 'list' :
     120            array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits['data']['profiles'] );
     121            echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
     122            break;
     123        case 'libraries' :
     124            array_walk( $group_data['data'], '_wp_credits_build_object_link' );
     125            echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
     126            break;
     127        default:
     128            $compact = 'compact' == $group_data['type'];
     129            $classes = 'wp-people-group ' . ( $compact ? 'compact' : '' );
     130            echo '<ul class="' . $classes . '" id="wp-people-group-' . $group_slug . '">' . "\n";
     131            foreach ( $group_data['data'] as $person_data ) {
     132                echo '<li class="wp-person" id="wp-person-' . $person_data[2] . '">' . "\n\t";
     133                echo '<a href="' . sprintf( $credits['data']['profiles'], $person_data[2] ) . '">';
     134                $size = 'compact' == $group_data['type'] ? '30' : '60';
     135                echo '<img src="' . $gravatar . $person_data[1] . '?s=' . $size . '" class="gravatar" alt="' . esc_attr( $person_data[0] ) . '" /></a>' . "\n\t";
     136                echo '<a class="web" href="' . sprintf( $credits['data']['profiles'], $person_data[2] ) . '">' . $person_data[0] . "</a>\n\t";
     137                if ( ! $compact )
     138                    echo '<br /><span class="title">' . translate( $person_data[3] ) . "</span>\n";
     139                echo "</li>\n";
     140            }
     141            echo "</ul>\n";
     142        break;
     143    }
    118144}
    119145
     
    138164__( 'Lead Developer' );
    139165__( 'User Experience Lead' );
    140 __( 'Developer, Core Committer' );
     166__( 'Core Committer' );
     167__( 'Guest Committer' );
    141168__( 'Developer' );
    142169__( 'Designer' );
    143170__( 'XML-RPC Developer' );
    144171__( 'Internationalization' );
     172__( 'External Libraries' );
    145173
    146174?>
Note: See TracChangeset for help on using the changeset viewer.