Changeset 8729 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/fields/plugin/class-screenshots.php
- Timestamp:
- 05/03/2019 07:03:20 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/fields/plugin/class-screenshots.php
r6287 r8729 9 9 10 10 /** 11 * Banners constructor.11 * Screenshots constructor. 12 12 */ 13 13 public function __construct() { … … 28 28 */ 29 29 public function get_screenshots( $object ) { 30 $descriptions = get_post_meta( $object['id'], 'screenshots', true ) ?: []; 31 $screen_shots = get_post_meta( $object['id'], 'assets_screenshots', true ) ?: []; 32 $response = []; 33 34 foreach ( $screen_shots as $image ) { 35 $screen_shot = [ 36 'src' => esc_url( Template::get_asset_url( $object['id'], $image ) ), 37 ]; 38 39 if ( $descriptions && ! empty( $descriptions[ (int) $image['resolution'] ] ) ) { 40 $caption = $descriptions[ (int) $image['resolution'] ]; 41 $screen_shot['caption'] = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $object['id'] ] ); 42 } 43 44 $response[] = $screen_shot; 45 } 46 47 return $response; 30 // Reduce the Screenshots to the required fields. 31 return array_values( array_map( 32 function( $image ) { 33 return [ 34 'src' => $image['src'], 35 'caption' => $image['caption'], 36 ]; 37 }, 38 Template::get_screenshots( $object['id'] ) 39 ) ); 48 40 } 49 41 }
Note: See TracChangeset
for help on using the changeset viewer.