WordPress.org

Making WordPress.org

Changeset 8781


Ignore:
Timestamp:
05/13/2019 05:49:46 AM (14 months ago)
Author:
tellyworth
Message:

Translation Teams: show current and past contributors separately.

See #2320.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/views/locale-details.php

    r5344 r8781  
    130130
    131131<?php if ( ! empty( $locale_data['translators'] ) ) : ?>
    132     <h2><?php printf( __( 'All Translation Contributors (%s)', 'wporg' ), number_format_i18n( count( $locale_data['translators'] ) ) ); ?></h2>
     132    <h2><?php printf( __( 'Current Translation Contributors (%s)', 'wporg' ), number_format_i18n( count( $locale_data['translators'] ) ) ); ?></h2>
    133133
    134134    <p>
     
    136136        $translators = array();
    137137        foreach ( $locale_data['translators'] as $translator ) {
     138            $translators[] = sprintf(
     139                '<a href="https://profiles.wordpress.org/%s">%s</a>',
     140                esc_attr( $translator['nice_name'] ),
     141                esc_html( $translator['display_name'] )
     142            );
     143        }
     144        echo wp_sprintf( '%l.', $translators );
     145        ?>
     146    </p>
     147<?php endif; ?>
     148
     149<?php if ( ! empty( $locale_data['translators_past'] ) ) : ?>
     150    <h2><?php printf( __( 'Past Translation Contributors (%s)', 'wporg' ), number_format_i18n( count( $locale_data['translators_past'] ) ) ); ?></h2>
     151
     152    <p>
     153        <?php
     154        $translators = array();
     155        foreach ( $locale_data['translators_past'] as $translator ) {
    138156            $translators[] = sprintf(
    139157                '<a href="https://profiles.wordpress.org/%s">%s</a>',
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wp-i18n-teams/wp-i18n-teams.php

    r7829 r8781  
    282282        $locale_data['project_validators'] = $contributors['project_validators'];
    283283        $locale_data['translators'] = $contributors['translators'];
     284        $locale_data['translators_past'] = $contributors['translators_past'];
    284285
    285286        return $locale_data;
     
    302303        $contributors['validators'] = $this->get_general_translation_editors( $locale );
    303304        $contributors['project_validators'] = $this->get_project_translation_editors( $locale );
    304         $contributors['translators'] = $this->get_translation_contributors( $locale );
     305        $contributors['translators'] = $this->get_translation_contributors( $locale, 365 ); // Contributors from the past year
     306        $contributors['translators_past'] = array_diff_key( $this->get_translation_contributors( $locale ), $contributors['translators'] );
    305307
    306308        wp_cache_set( 'contributors-data:' . $locale->wp_locale, $contributors, 'wp-i18n-teams', 2 * HOUR_IN_SECONDS );
     
    478480     * @return array
    479481     */
    480     private function get_translation_contributors( $locale ) {
     482    private function get_translation_contributors( $locale, $max_age_days = null ) {
    481483        global $wpdb;
    482484
    483485        $contributors = array();
     486
     487        $date_constraint = '';
     488        if ( !is_null( $max_age_days ) )
     489            $date_constraint = $wpdb->prepare( " AND date_modified >= CURRENT_DATE - INTERVAL %d DAY", $max_age_days );
    484490
    485491        $users = $wpdb->get_col( $wpdb->prepare(
    486492            "SELECT DISTINCT user_id FROM translate_user_translations_count WHERE accepted > 0 AND locale = %s",
    487493            $locale->slug
    488         ) );
     494        ) . $date_constraint );
    489495
    490496        if ( ! $users ) {
Note: See TracChangeset for help on using the changeset viewer.