Changeset 2621 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php
- Timestamp:
- 02/25/2016 10:49:24 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-screenshots.php
r2611 r2621 1 1 <?php 2 2 namespace WordPressdotorg\Plugin_Directory\Shortcodes; 3 3 4 use WordPressdotorg\Plugin_Directory\Template; 4 5 … … 6 7 * The [wporg-plugins-screenshots] shortcode handler to display a plugins screenshots. 7 8 * 8 * @package WordPressdotorg _Plugin_Directory9 * @package WordPressdotorg\Plugin_Directory\Shortcodes 9 10 */ 10 11 class Screenshots { 12 13 /** 14 * @return string 15 */ 11 16 static function display() { 12 17 $plugin = get_post(); 18 $output = ''; 13 19 14 // All indexed from 1 20 // All indexed from 1. 15 21 $screenshot_descriptions = get_post_meta( $plugin->ID, 'screenshots', true ); 16 $assets_screenshots = get_post_meta( $plugin->ID, 'assets_screenshots', true );22 $assets_screenshots = get_post_meta( $plugin->ID, 'assets_screenshots', true ); 17 23 18 $output = '';19 24 foreach ( $screenshot_descriptions as $index => $description ) { 20 // Find the image that corresponds with the text. 21 // The image numbers are stored within the 'resolution' key. 22 $found = false; 25 26 /* 27 * Find the image that corresponds with the text. 28 * The image numbers are stored within the 'resolution' key. 29 */ 23 30 foreach ( $assets_screenshots as $image ) { 24 31 if ( $index == $image['resolution'] ) { 25 $found = true; 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 ); 26 42 break; 27 43 } 28 44 } 29 if ( ! $found ) {30 continue;31 }32 33 $url = Template::get_asset_url( $plugin->post_name, $image );34 35 $output .= sprintf(36 '<li>37 <a href="%1$s" rel="nofollow">38 <img class="screenshot" src="%1$s">39 </a>40 <p>%2$s</p>41 </li>',42 $url,43 $description44 );45 45 } 46 46 47 47 return '<ol class="screenshots">' . $output . '</ol>'; 48 49 48 } 50 49 }
Note: See TracChangeset
for help on using the changeset viewer.