Make WordPress Core

Ticket #47708: 47708-credits.diff

File 47708-credits.diff, 8.6 KB (added by ryelle, 5 years ago)

Fix for credits spacing, patch made against trunk.

  • src/wp-admin/credits.php

    diff --git src/wp-admin/credits.php src/wp-admin/credits.php
    index 529aac7fbb..af4792d2b4 100644
    if ( ! $credits ) { 
    8585        include( ABSPATH . 'wp-admin/admin-footer.php' );
    8686        exit;
    8787}
     88?>
    8889
    89 $previous_type = '';
     90        <hr />
    9091
    91 foreach ( $credits['groups'] as $group_slug => $group_data ) :
    92         ?>
    93         <?php
    94         if ( $previous_type !== $group_data['type'] ) {
    95                 echo '<hr />';
    96         }
    97         ?>
    9892        <div class="about__section">
    99                 <div class="column <?php echo 'titles' === $group_data['type'] ? 'has-subtle-background-color' : ''; ?>">
    100 
    101         <?php
    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                         // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
    108                         $title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
    109                 } else {
    110                         // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
    111                         $title = translate( $group_data['name'] );
    112                 }
    113 
    114                 echo '<h2 class="wp-people-group-title">' . esc_html( $title ) . "</h2>\n";
    115         }
    116 
    117         if ( ! empty( $group_data['shuffle'] ) ) {
    118                 shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
    119         }
    120 
    121         switch ( $group_data['type'] ) {
    122                 case 'list':
    123                         array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits['data']['profiles'] );
    124                         echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
    125                         break;
    126                 case 'libraries':
    127                         array_walk( $group_data['data'], '_wp_credits_build_object_link' );
    128                         echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
    129                         break;
    130                 default:
    131                         $compact = 'compact' == $group_data['type'];
    132                         $classes = 'wp-people-group ' . ( $compact ? 'compact' : '' );
    133                         echo '<ul class="' . $classes . '" id="wp-people-group-' . $group_slug . '">' . "\n";
    134                         foreach ( $group_data['data'] as $person_data ) {
    135                                 echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t";
    136                                 echo '<a href="' . esc_url( sprintf( $credits['data']['profiles'], $person_data[2] ) ) . '" class="web">';
    137                                 $size   = 'compact' == $group_data['type'] ? 40 : 80;
    138                                 $data   = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
    139                                 $size  *= 2;
    140                                 $data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
    141                                 echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n";
    142                                 echo esc_html( $person_data[0] ) . "</a>\n\t";
    143                                 if ( ! $compact ) {
    144                                         // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
    145                                         echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
    146                                 }
    147                                 echo "</li>\n";
    148                         }
    149                         echo "</ul>\n";
    150                         break;
    151         }
    152         $previous_type = $group_data['type'];
    153         ?>
     93                <div class="column has-subtle-background-color">
     94                        <?php wp_credits_section_title( $credits['groups']['core-developers'] ); ?>
     95                        <?php wp_credits_section_list( $credits, 'core-developers' ); ?>
     96                        <?php wp_credits_section_list( $credits, 'contributing-developers' ); ?>
     97                </div>
     98        </div>
     99
     100        <hr />
     101
     102        <div class="about__section">
     103                <div class="column">
     104                        <?php wp_credits_section_title( $credits['groups']['props'] ); ?>
     105                        <?php wp_credits_section_list( $credits, 'props' ); ?>
     106                </div>
     107        </div>
    154108
     109        <hr />
     110
     111        <?php if ( isset( $credits['groups']['translators'] ) || isset( $credits['groups']['validators'] ) ) : ?>
     112        <div class="about__section">
     113                <div class="column">
     114                        <?php wp_credits_section_title( $credits['groups']['validators'] ); ?>
     115                        <?php wp_credits_section_list( $credits, 'validators' ); ?>
     116                        <?php wp_credits_section_list( $credits, 'translators' ); ?>
     117                </div>
     118        </div>
     119
     120        <hr />
     121        <?php endif; ?>
     122
     123        <div class="about__section">
     124                <div class="column">
     125                        <?php wp_credits_section_title( $credits['groups']['libraries'] ); ?>
     126                        <?php wp_credits_section_list( $credits, 'libraries' ); ?>
    155127                </div>
    156128        </div>
    157 <?php endforeach; ?>
    158129</div>
    159130<?php
    160131
  • src/wp-admin/css/about.css

    diff --git src/wp-admin/css/about.css src/wp-admin/css/about.css
    index 3b11fb8fc6..053c0210de 100644
     
    550550  2.0 - Credits Page
    551551------------------------------------------------------------------------------*/
    552552
    553 .about__section .wp-people-group-title {
    554         margin-bottom: 2em;
    555         font-size: 1.4em;
    556 }
    557 
    558553.about__section .wp-people-group {
    559554        margin: 0;
    560555}
  • src/wp-admin/includes/credits.php

    diff --git src/wp-admin/includes/credits.php src/wp-admin/includes/credits.php
    index d558e9c812..78d8f3ecb9 100644
    function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) { 
    7676function _wp_credits_build_object_link( &$data ) {
    7777        $data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
    7878}
     79
     80/**
     81 * Display a the title for a given group of contributors.
     82 *
     83 * @since 5.3.0
     84 *
     85 * @param array $group_data The current contributor group.
     86 */
     87function wp_credits_section_title( $group_data = [] ) {
     88        if ( ! count( $group_data ) ) {
     89                return;
     90        }
     91
     92        if ( $group_data['name'] ) {
     93                if ( 'Translators' === $group_data['name'] ) {
     94                        // Considered a special slug in the API response. (Also, will never be returned for en_US.)
     95                        $title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
     96                } elseif ( isset( $group_data['placeholders'] ) ) {
     97                        // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
     98                        $title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
     99                } else {
     100                        // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
     101                        $title = translate( $group_data['name'] );
     102                }
     103
     104                echo '<h2 class="wp-people-group-title">' . esc_html( $title ) . "</h2>\n";
     105        }
     106}
     107
     108/**
     109 * Display a list of contributors for a given group.
     110 *
     111 * @since 5.3.0
     112 *
     113 * @param array  $credits The credits groups returned from the API.
     114 * @param string $slug    The current group to display.
     115 */
     116function wp_credits_section_list( $credits = [], $slug = '' ) {
     117        $group_data   = isset( $credits['groups'][ $slug ] ) ? $credits['groups'][ $slug ] : [];
     118        $credits_data = $credits['data'];
     119        if ( ! count( $group_data ) ) {
     120                return;
     121        }
     122
     123        if ( ! empty( $group_data['shuffle'] ) ) {
     124                shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
     125        }
     126
     127        switch ( $group_data['type'] ) {
     128                case 'list':
     129                        array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits_data['profiles'] );
     130                        echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
     131                        break;
     132                case 'libraries':
     133                        array_walk( $group_data['data'], '_wp_credits_build_object_link' );
     134                        echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
     135                        break;
     136                default:
     137                        $compact = 'compact' === $group_data['type'];
     138                        $classes = 'wp-people-group ' . ( $compact ? 'compact' : '' );
     139                        echo '<ul class="' . $classes . '" id="wp-people-group-' . $slug . '">' . "\n";
     140                        foreach ( $group_data['data'] as $person_data ) {
     141                                echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t";
     142                                echo '<a href="' . esc_url( sprintf( $credits_data['profiles'], $person_data[2] ) ) . '" class="web">';
     143                                $size   = $compact ? 40 : 80;
     144                                $data   = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
     145                                $data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size * 2 ) );
     146                                echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n";
     147                                echo esc_html( $person_data[0] ) . "</a>\n\t";
     148                                if ( ! $compact ) {
     149                                        // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
     150                                        echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
     151                                }
     152                                echo "</li>\n";
     153                        }
     154                        echo "</ul>\n";
     155                        break;
     156        }
     157}