Making WordPress.org

Changeset 5413


Ignore:
Timestamp:
04/25/2017 04:09:12 PM (9 years ago)
Author:
ocean90
Message:

Plugin Directory: Bail early if no locale sites are found.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-developers.php

    r5393 r5413  
    5555            ] );
    5656
    57             $locales_list = implode( ', ', array_map( function( $site ) use ( $slug, $locale_names ) {
    58                 return sprintf( '<a href="%1$s">%2$s</a>', esc_url( "{$site->home}/plugins/{$slug}/" ), $locale_names[ $site->locale ] );
    59             }, $sites ) );
     57            if ( $sites ) {
     58                $locales_list = implode( ', ', array_map( function( $site ) use ( $slug, $locale_names ) {
     59                    return sprintf( '<a href="%1$s">%2$s</a>', esc_url( "{$site->home}/plugins/{$slug}/" ), $locale_names[ $site->locale ] );
     60                }, $sites ) );
    6061
    61             $locales_count = count( $sites );
     62                $locales_count = count( $sites );
    6263
    63             if ( 1 === $locales_count ) {
     64                if ( 1 === $locales_count ) {
     65                    $output .= sprintf(
     66                        /* translators: 1: plugin name, 2: locale name */
     67                        __( '&#8220;%1$s&#8221; has been translated into %2$s.' ),
     68                        $title,
     69                        $locales_list
     70                    ) . ' ';
     71                } else {
     72                    $output .= sprintf(
     73                        /* translators: 1: plugin name, 2: number of locales, 3: list of locales */
     74                        _n(
     75                            '&#8220;%1$s&#8221; has been translated into these %2$d locales: %3$s.',
     76                            '&#8220;%1$s&#8221; has been translated into these %2$d locales: %3$s.',
     77                            $locales_count
     78                        ),
     79                        $title,
     80                        $locales_count,
     81                        $locales_list
     82                    ) . ' ';
     83                }
     84
    6485                $output .= sprintf(
    65                     /* translators: 1: plugin name, 2: locale name */
    66                     __( '&#8220;%1$s&#8221; has been translated into %2$s.' ),
    67                     $title,
    68                     $locales_list
    69                 ) . ' ';
    70             } else {
    71                 $output .= sprintf(
    72                     /* translators: 1: plugin name, 2: number of locales, 3: list of locales */
    73                     _n(
    74                         '&#8220;%1$s&#8221; has been translated into these %2$d locales: %3$s.',
    75                         '&#8220;%1$s&#8221; has been translated into these %2$d locales: %3$s.',
    76                         $locales_count
    77                     ),
    78                     $title,
    79                     $locales_count,
    80                     $locales_list
    81                 ) . ' ';
     86                    /* translators: URL to translator view */
     87                    __( 'Thank you to <a href="%s">the translators</a> for their contributions.', 'wporg-plugins' ),
     88                    esc_url( "https://translate.wordpress.org/projects/wp-plugins/{$slug}/contributors" )
     89                );
     90                $output .= '</p>';
    8291            }
    83 
    84             $output .= sprintf(
    85                 /* translators: URL to translator view */
    86                 __( 'Thank you to <a href="%s">the translators</a> for their contributions.', 'wporg-plugins' ),
    87                 esc_url( "https://translate.wordpress.org/projects/wp-plugins/{$slug}/contributors" )
    88             );
    89             $output .= '</p>';
    9092        }
    9193
Note: See TracChangeset for help on using the changeset viewer.