WordPress.org

Making WordPress.org

Changeset 3888


Ignore:
Timestamp:
08/31/16 03:41:43 (16 months ago)
Author:
obenland
Message:

Plugin Directory: Add screenshots to API response.

Allows us to build the screenshots section in JS.

See #1828, #1579.

File:
1 edited

Legend:

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

    r3864 r3888  
    107107        $result['download_link'] = Template::download_link( $post ); 
    108108 
     109        $result['screenshots'] = array(); 
     110        $descriptions = get_post_meta( $post->ID, 'screenshots', true ); 
     111        $screen_shots = get_post_meta( $post->ID, 'assets_screenshots', true ) ?: array(); 
     112 
     113        /* 
     114         * Find the image that corresponds with the text. 
     115         * The image numbers are stored within the 'resolution' key. 
     116         */ 
     117        foreach ( $screen_shots as $image ) { 
     118            $result['screenshots'][ $image['resolution'] ] = array( 
     119                'src'     => Template::get_asset_url( $post->post_name, $image ), 
     120                'caption' => array_key_exists( $image['resolution'], $descriptions ) ? $descriptions[ $image['resolution'] ] : '' 
     121            ); 
     122        } 
     123 
    109124        $result['tags'] = array(); 
    110125        if ( $terms = get_the_terms( $post->ID, 'plugin_category' ) ) { 
     
    121136                array_push( $versions, 'trunk' ); 
    122137            } 
    123             foreach ( $versions as $version ) {  
     138            foreach ( $versions as $version ) { 
    124139                $result['versions'][ $version ] = Template::download_link( $post, $version ); 
    125140            } 
     
    223238                <a href="https://profiles.wordpress.org/<?php echo $reviewer->user_nicename; ?>" class="reviewer-name"><?php 
    224239                    echo $reviewer->display_name; 
    225      
     240 
    226241                    if ( $reviewer->display_name != $reviewer->user_login ) { 
    227242                        echo " <small>({$reviewer->user_login})</small>"; 
Note: See TracChangeset for help on using the changeset viewer.