Making WordPress.org

Changeset 3401


Ignore:
Timestamp:
06/17/2016 09:11:50 AM (9 years ago)
Author:
obenland
Message:

Plugin Directory: More semantic screenshots markup.

See #1719.

File:
1 edited

Legend:

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

    r2621 r3401  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Shortcodes;
    3 
    43use WordPressdotorg\Plugin_Directory\Template;
    54
     
    1918
    2019        // All indexed from 1.
    21         $screenshot_descriptions = get_post_meta( $plugin->ID, 'screenshots', true );
    22         $assets_screenshots      = get_post_meta( $plugin->ID, 'assets_screenshots', true );
     20        $descriptions = get_post_meta( $plugin->ID, 'screenshots', true );
     21        $screen_shots = get_post_meta( $plugin->ID, 'assets_screenshots', true );
    2322
    24         foreach ( $screenshot_descriptions as $index => $description ) {
     23        /*
     24         * Find the image that corresponds with the text.
     25         * The image numbers are stored within the 'resolution' key.
     26         */
     27        foreach ( $screen_shots as $image ) {
     28            $screen_shot = sprintf( '<a href="%1$s" rel="nofollow"><img class="screenshot" src="%1$s" /></a>',
     29                Template::get_asset_url( $plugin->post_name, $image )
     30            );
    2531
    26             /*
    27              * Find the image that corresponds with the text.
    28              * The image numbers are stored within the 'resolution' key.
    29              */
    30             foreach ( $assets_screenshots as $image ) {
    31                 if ( $index == $image['resolution'] ) {
    32                     $output .= sprintf(
    33                         '<li>
    34                             <a href="%1$s" rel="nofollow">
    35                                 <img class="screenshot" src="%1$s">
    36                             </a>
    37                             <p>%2$s</p>
    38                         </li>',
    39                         Template::get_asset_url( $plugin->post_name, $image ),
    40                         $description
    41                     );
    42                     break;
    43                 }
     32            if ( array_key_exists( $image['resolution'], $descriptions ) ) {
     33                $screen_shot .= '<figcaption>' . esc_html( $descriptions[ $image['resolution'] ] ) . '</figcaption>';
    4434            }
     35
     36            $output .= '<li><figure>' . $screen_shot . '</figure></li>';
    4537        }
    4638
    47         return '<ol class="screenshots">' . $output . '</ol>';
     39        return '<ul class="plugin-screenshots">' . $output . '</ul>';
    4840    }
    4941}
Note: See TracChangeset for help on using the changeset viewer.