Making WordPress.org


Ignore:
Timestamp:
05/03/2019 07:03:20 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: Introduce localised screenshots, allowing plugins to have translated screenshots on the website and within the wp-admin plugin installer.

This works by allowing screenshots located in the /assets/ folder to define the locale of the image, eg. screenshot-1-de_DE.png or screenshot-1-ary.png.

Props ck3lee, dd32.
See #3935.

File:
1 edited

Legend:

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

    r6287 r8729  
    1616         */
    1717        static function display() {
    18                 $plugin = get_post();
    1918                $output = '';
    2019
    21                 // All indexed from 1.
    22                 $descriptions = get_post_meta( $plugin->ID, 'screenshots', true ) ?: array();
    23                 $screen_shots = get_post_meta( $plugin->ID, 'assets_screenshots', true ) ?: array();
     20                $screenshots = Template::get_screenshots();
    2421
    25                 if ( empty( $screen_shots ) ) {
     22                if ( ! $screenshots ) {
    2623                        return '';
    2724                }
    2825
    29                 ksort( $screen_shots, SORT_NATURAL );
    30 
    31                 /*
    32                  * Find the image that corresponds with the text.
    33                  * The image numbers are stored within the 'resolution' key.
    34                  */
    35                 foreach ( $screen_shots as $image ) {
     26                foreach ( $screenshots as $image ) {
    3627                        $screen_shot = sprintf(
    3728                                '<a href="%1$s" rel="nofollow"><img class="screenshot" src="%1$s" alt="" /></a>',
    38                                 esc_url( Template::get_asset_url( $plugin, $image ) )
     29                                esc_url( $image['src'] )
    3930                        );
    4031
    41                         if ( $descriptions && ! empty( $descriptions[ (int) $image['resolution'] ] ) ) {
    42                                 $caption = $descriptions[ (int) $image['resolution'] ];
    43                                 $caption = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $plugin->ID ] );
    44 
    45                                 $screen_shot .= '<figcaption>' . $caption . '</figcaption>';
     32                        if ( $image['caption'] ) {
     33                                $screen_shot .= '<figcaption>' . $image['caption'] . '</figcaption>';
    4634                        }
    4735
Note: See TracChangeset for help on using the changeset viewer.