Changeset 8729 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
- Timestamp:
- 05/03/2019 07:03:20 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-plugin.php
r7282 r8729 155 155 $result['download_link'] = Template::download_link( $post ); 156 156 157 $result['screenshots'] = array(); 158 $descriptions = get_post_meta( $post->ID, 'screenshots', true ) ?: array(); 159 $screen_shots = get_post_meta( $post->ID, 'assets_screenshots', true ) ?: array(); 160 161 /* 162 * Find the image that corresponds with the text. 163 * The image numbers are stored within the 'resolution' key. 164 */ 165 foreach ( $screen_shots as $image ) { 166 $src = Template::get_asset_url( $post, $image ); 167 $caption = ''; 168 if ( $descriptions && ! empty( $descriptions[ (int) $image['resolution'] ] ) ) { 169 $caption = $descriptions[ (int) $image['resolution'] ]; 170 $caption = Plugin_I18n::instance()->translate( 'screenshot-' . $image['resolution'], $caption, [ 'post_id' => $post->ID ] ); 171 } 172 173 $result['screenshots'][ $image['resolution'] ] = compact( 'src', 'caption' ); 174 } 157 // Reduce images to caption + src 158 $result['screenshots'] = array_map( 159 function( $image ) { 160 return [ 161 'src' => $image['src'], 162 'caption' => $image['caption'], 163 ]; 164 }, 165 Template::get_screenshots( $post ) 166 ); 175 167 176 168 if ( $result['screenshots'] ) {
Note: See TracChangeset
for help on using the changeset viewer.