Help/About: Update the 5.3 About page.

* Remove extra padding on the Credits tab.

Previously [46556], [46572], [46616], [46705].
Props ryelle.
See #47708.

git-svn-id: https://develop.svn.wordpress.org/trunk@46709 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-11-11 20:43:48 +00:00
parent 91312ab695
commit 895ec7224b
3 changed files with 115 additions and 70 deletions

View File

@ -85,76 +85,47 @@ if ( ! $credits ) {
include( ABSPATH . 'wp-admin/admin-footer.php' );
exit;
}
?>
$previous_type = '';
<hr />
foreach ( $credits['groups'] as $group_slug => $group_data ) :
?>
<?php
if ( $previous_type !== $group_data['type'] ) {
echo '<hr />';
}
?>
<div class="about__section">
<div class="column <?php echo 'titles' === $group_data['type'] ? 'has-subtle-background-color' : ''; ?>">
<?php
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'] ) ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
} else {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$title = translate( $group_data['name'] );
}
echo '<h2 class="wp-people-group-title">' . esc_html( $title ) . "</h2>\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-' . esc_attr( $person_data[2] ) . '">' . "\n\t";
echo '<a href="' . esc_url( sprintf( $credits['data']['profiles'], $person_data[2] ) ) . '" class="web">';
$size = 'compact' == $group_data['type'] ? 40 : 80;
$data = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
$size *= 2;
$data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n";
echo esc_html( $person_data[0] ) . "</a>\n\t";
if ( ! $compact ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
}
echo "</li>\n";
}
echo "</ul>\n";
break;
}
$previous_type = $group_data['type'];
?>
<div class="column has-subtle-background-color">
<?php wp_credits_section_title( $credits['groups']['core-developers'] ); ?>
<?php wp_credits_section_list( $credits, 'core-developers' ); ?>
<?php wp_credits_section_list( $credits, 'contributing-developers' ); ?>
</div>
</div>
<hr />
<div class="about__section">
<div class="column">
<?php wp_credits_section_title( $credits['groups']['props'] ); ?>
<?php wp_credits_section_list( $credits, 'props' ); ?>
</div>
</div>
<hr />
<?php if ( isset( $credits['groups']['translators'] ) || isset( $credits['groups']['validators'] ) ) : ?>
<div class="about__section">
<div class="column">
<?php wp_credits_section_title( $credits['groups']['validators'] ); ?>
<?php wp_credits_section_list( $credits, 'validators' ); ?>
<?php wp_credits_section_list( $credits, 'translators' ); ?>
</div>
</div>
<hr />
<?php endif; ?>
<div class="about__section">
<div class="column">
<?php wp_credits_section_title( $credits['groups']['libraries'] ); ?>
<?php wp_credits_section_list( $credits, 'libraries' ); ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php

View File

@ -550,11 +550,6 @@
2.0 - Credits Page
------------------------------------------------------------------------------*/
.about__section .wp-people-group-title {
margin-bottom: 2em;
font-size: 1.4em;
}
.about__section .wp-people-group {
margin: 0;
}

View File

@ -76,3 +76,82 @@ function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
function _wp_credits_build_object_link( &$data ) {
$data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
}
/**
* Display a the title for a given group of contributors.
*
* @since 5.3.0
*
* @param array $group_data The current contributor group.
*/
function wp_credits_section_title( $group_data = array() ) {
if ( ! count( $group_data ) ) {
return;
}
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'] ) ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
} else {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
$title = translate( $group_data['name'] );
}
echo '<h2 class="wp-people-group-title">' . esc_html( $title ) . "</h2>\n";
}
}
/**
* Display a list of contributors for a given group.
*
* @since 5.3.0
*
* @param array $credits The credits groups returned from the API.
* @param string $slug The current group to display.
*/
function wp_credits_section_list( $credits = array(), $slug = '' ) {
$group_data = isset( $credits['groups'][ $slug ] ) ? $credits['groups'][ $slug ] : array();
$credits_data = $credits['data'];
if ( ! count( $group_data ) ) {
return;
}
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-' . $slug . '">' . "\n";
foreach ( $group_data['data'] as $person_data ) {
echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t";
echo '<a href="' . esc_url( sprintf( $credits_data['profiles'], $person_data[2] ) ) . '" class="web">';
$size = $compact ? 40 : 80;
$data = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
$data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size * 2 ) );
echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n";
echo esc_html( $person_data[0] ) . "</a>\n\t";
if ( ! $compact ) {
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
}
echo "</li>\n";
}
echo "</ul>\n";
break;
}
}