<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[18162] trunk/wp-admin/credits.php: Credits screen redux.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/18162">18162</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2011-06-06 06:38:29 +0000 (Mon, 06 Jun 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Credits screen redux. Add external libraries, gravatars for language validators. Backed by a new API. fixes <a href="http://trac.wordpress.org/ticket/17518">#17518</a>, fixes <a href="http://trac.wordpress.org/ticket/17532">#17532</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincreditsphp">trunk/wp-admin/credits.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincreditsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/credits.php (18161 => 18162)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/credits.php        2011-06-06 06:25:55 UTC (rev 18161)
+++ trunk/wp-admin/credits.php        2011-06-06 06:38:29 UTC (rev 18162)
</span><span class="lines">@@ -24,16 +24,22 @@
</span><span class="cx"> add_action( 'admin_head', '_wp_credits_add_css' );
</span><span class="cx"> function _wp_credits_add_css() { ?>
</span><span class="cx"> <style type="text/css">
</span><del>-h3.wp-people-group, h3.wp-props-group { clear: both; }
</del><ins>+div.wrap { max-width: 750px }
+h3.wp-people-group, p.wp-credits-list { clear: both; }
+ul.compact { margin-bottom: 0 }
+
</ins><span class="cx"> <?php if ( is_rtl() ) { ?>
</span><span class="cx"> ul.wp-people-group { margin-bottom: 30px; float: right; clear: both; }
</span><span class="cx"> li.wp-person { float: right; height: 70px; width: 220px; margin-left: 10px; }
</span><del>-li.wp-person img.gravatar { float: right; margin-left: 10px; margin-bottom: 10px; width: 60px; height: 60px }
</del><ins>+li.wp-person img.gravatar { float: right; margin-left: 10px; margin-bottom: 10px; }
</ins><span class="cx"> <?php } else { ?>
</span><del>-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 }
</del><ins>+li.wp-person { float: left; margin-right: 10px; }
+li.wp-person img.gravatar { float: left; margin-right: 10px; margin-bottom: 10px; }
</ins><span class="cx"> <?php } ?>
</span><ins>+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 }
</ins><span class="cx"> li.wp-person a.web { font-size: 16px; text-decoration: none; }
</span><span class="cx"> </style>
</span><span class="cx"> <?php }
</span><span class="lines">@@ -44,13 +50,13 @@
</span><span class="cx">
</span><span class="cx">         $results = get_site_transient( 'wordpress_credits_' . $locale );
</span><span class="cx">
</span><del>-        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" );
</del><ins>+        if ( ! is_array( $results ) ) {
+                $response = wp_remote_get( "http://api.wordpress.org/core/credits/1.1/?version=$wp_version&locale=$locale" );
</ins><span class="cx">
</span><span class="cx">                 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
</span><span class="cx">                         return false;
</span><span class="cx">
</span><del>-                $results = unserialize( wp_remote_retrieve_body( $response ) );
</del><ins>+                $results = maybe_unserialize( wp_remote_retrieve_body( $response ) );
</ins><span class="cx">
</span><span class="cx">                 if ( ! is_array( $results ) )
</span><span class="cx">                         return false;
</span><span class="lines">@@ -61,10 +67,14 @@
</span><span class="cx">         return $results;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-function _wp_credits_add_profile_link( &$display_name, $username, $prefix ) {
-        $display_name = '<a href="' . esc_url( $prefix . $username ) . '">' . esc_html( $display_name ) . '</a>';
</del><ins>+function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
+        $display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+function _wp_credits_build_object_link( &$data ) {
+        $data = '<a href="' . esc_url( $data[1] ) . '">' . $data[0] . '</a>';
+}
+
</ins><span class="cx"> include( './admin-header.php' );
</span><span class="cx"> ?>
</span><span class="cx"> <div class="wrap">
</span><span class="lines">@@ -73,9 +83,9 @@
</span><span class="cx">
</span><span class="cx"> <?php
</span><span class="cx">
</span><del>-$results = wp_credits();
</del><ins>+$credits = wp_credits();
</ins><span class="cx">
</span><del>-if ( ! $results ) {
</del><ins>+if ( ! $credits ) {
</ins><span class="cx">         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>.' ),
</span><span class="cx">                 'http://wordpress.org/about/',
</span><span class="cx">                 /* translators: Url to the codex documentation on contributing to WordPress used on the credits page */
</span><span class="lines">@@ -88,33 +98,49 @@
</span><span class="cx">
</span><span class="cx"> $gravatar = is_ssl() ? 'https://secure.gravatar.com/avatar/' : 'http://0.gravatar.com/avatar/';
</span><span class="cx">
</span><del>-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";
</del><ins>+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'];
+                }
+
+                echo '<h3 class="wp-people-group">' . $title . "</h3>\n";
</ins><span class="cx">         }
</span><del>-        echo "</ul>\n";
-}
</del><span class="cx">
</span><del>-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 ] );
</del><ins>+        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;
</ins><span class="cx">         }
</span><del>-
-        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";
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ?>
</span><span class="lines">@@ -137,10 +163,12 @@
</span><span class="cx"> __( 'Cofounder, Project Lead' );
</span><span class="cx"> __( 'Lead Developer' );
</span><span class="cx"> __( 'User Experience Lead' );
</span><del>-__( 'Developer, Core Committer' );
</del><ins>+__( 'Core Committer' );
+__( 'Guest Committer' );
</ins><span class="cx"> __( 'Developer' );
</span><span class="cx"> __( 'Designer' );
</span><span class="cx"> __( 'XML-RPC Developer' );
</span><span class="cx"> __( 'Internationalization' );
</span><ins>+__( 'External Libraries' );
</ins><span class="cx">
</span><span class="cx"> ?>
</span></span></pre>
</div>
</div>
</body>
</html>