Making WordPress.org

Ticket #3935: 3935.diff

File 3935.diff, 2.7 KB (added by ck3lee, 6 years ago)
  • wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    diff --git wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php
    index d407c1295..7545b4df3 100644
    class Import { 
    362362                $svn_assets_folder = SVN::ls( self::PLUGIN_SVN_BASE . "/{$plugin_slug}/assets/", true /* verbose */ );
    363363                if ( $svn_assets_folder ) { // /assets/ may not exist.
    364364                        foreach ( $svn_assets_folder as $asset ) {
    365                                 // screenshot-0(-rtl).(png|jpg|jpeg|gif)  ||  icon.svg
    366                                 if ( ! preg_match( '!^(?P<type>screenshot|banner|icon)(-(?P<resolution>[\dx]+)(-rtl)?\.(png|jpg|jpeg|gif)|\.svg)$!i', $asset['filename'], $m ) ) {
     365                                // screenshot-0(-rtl)(-de_DE).(png|jpg|jpeg|gif)  ||  icon.svg
     366                                if ( ! preg_match( '!^(?P<type>screenshot|banner|icon)(-(?P<resolution>[\dx]+)(-rtl)?(-(?P<locale>[a-z]{2}\_[A-Z]{2}))?\.(png|jpg|jpeg|gif)|\.svg)$!i', $asset['filename'], $m ) ) {
    367367                                        continue;
    368368                                }
    369369
    class Import { 
    372372                                $revision   = $asset['revision'];
    373373                                $location   = 'assets';
    374374                                $resolution = isset( $m['resolution'] ) ? $m['resolution'] : false;
     375                                $locale     = isset( $m['locale'] ) ? $m['locale'] : false;
    375376
    376                                 $assets[ $type ][ $asset['filename'] ] = compact( 'filename', 'revision', 'resolution', 'location' );
     377                                $assets[ $type ][ $asset['filename'] ] = compact( 'filename', 'revision', 'resolution', 'location', 'locale' );
    377378                        }
    378379                }
    379380
  • wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php

    diff --git wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php
    index 4bfe1400a..edda95b9d 100644
    class Screenshots { 
    2828
    2929                ksort( $screen_shots, SORT_NATURAL );
    3030
     31                $displayed_keys = array();
     32
    3133                /*
    3234                 * Find the image that corresponds with the text.
    3335                 * The image numbers are stored within the 'resolution' key.
     36                 * The same key can have more than one screenshot with different locales.
    3437                 */
    3538                foreach ( $screen_shots as $image ) {
     39
     40                        if ( !empty($image['locale']) && $image['locale'] != get_locale() ){
     41                                continue;
     42                        }
     43
     44                        if ( in_array( $image['resolution'], $displayed_keys ) ){
     45                                continue;
     46                        }
     47
     48                        $displayed_keys[] = $image['resolution'];
     49                       
    3650                        $screen_shot = sprintf(
    3751                                '<a href="%1$s" rel="nofollow"><img class="screenshot" src="%1$s" alt="" /></a>',
    3852                                esc_url( Template::get_asset_url( $plugin, $image ) )