WordPress.org

Making WordPress.org

Changeset 5371


Ignore:
Timestamp:
04/19/2017 07:08:37 PM (4 years ago)
Author:
ocean90
Message:

Plugin Directory: Fix invalid subdomain links in translations list.

Our subdomains are not the same as locale slugs. To get the correct domains query the sites by WordPress locale.

See [5348].
Fixes #2690.

File:
1 edited

Legend:

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

    r5361 r5371  
    3131        $output .= '</div>';
    3232
     33        $output .= '<div class="plugin-development">';
     34
    3335        $locales = Plugin_I18n::instance()->get_locales();
    34         $output .= '<div class="plugin-development"><p>';
     36        if ( ! empty( $locales ) ) {
     37            $output .= '<p>';
    3538
    36         if ( ! empty( $locales ) ) {
    37             $locales_list = implode( ', ', array_map( function( $locale ) use ( $slug ) {
    38                 return sprintf( '<a href="%1$s">%2$s</a>', esc_url( "{$locale->locale}.wordpress.org/plugins/{$slug}/" ), $locale->name );
    39             }, $locales ) );
     39            $locale_names = wp_list_pluck( $locales, 'name', 'wp_locale' );
     40            $wp_locales = wp_list_pluck( $locales,'wp_locale' );
     41
     42            $sites = get_sites( [
     43                'network_id' => WPORG_GLOBAL_NETWORK_ID,
     44                'public'     => 1,
     45                'path'       => '/',
     46                'locale__in' => $wp_locales,
     47                'number'     => '',
     48            ] );
     49
     50            $locales_list = implode( ', ', array_map( function( $site ) use ( $slug, $locale_names ) {
     51                return sprintf( '<a href="%1$s">%2$s</a>', esc_url( "{$site->home}/plugins/{$slug}/" ), $locale_names[ $site->locale ] );
     52            }, $sites ) );
     53
    4054            /* Translators: 1: Plugin name; 2: Number of locales; 3: List of locales; */
    4155            $output .= sprintf( '%1$s has been translated into these %2$d locales: %3$s.', $title, count( $locales ), $locales_list ) . ' ';
     
    4559                esc_url( "https://translate.wordpress.org/projects/wp-plugins/{$slug}/contributors" )
    4660            );
    47             $output .= '<br />';
     61            $output .= '</p>';
    4862        }
    49         $output .= '</p>';
    5063
    5164        /* Translators: 1: GlotPress URL; 2: Plugin name; */
Note: See TracChangeset for help on using the changeset viewer.