Making WordPress.org


Ignore:
Timestamp:
02/25/2016 10:49:24 PM (9 years ago)
Author:
obenland
Message:

Plugins Directory: Formatting update.

  • Updates phpdocs throughout the plugin.
  • Breaks out classes into their own files.
  • Some minor namespace-related tweaks.

See #1584.

File:
1 edited

Legend:

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

    r2611 r2621  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Shortcodes;
     3
    34use WordPressdotorg\Plugin_Directory\Template;
    45
     
    67 * The [wporg-plugins-screenshots] shortcode handler to display a plugins screenshots.
    78 *
    8  * @package WordPressdotorg_Plugin_Directory
     9 * @package WordPressdotorg\Plugin_Directory\Shortcodes
    910 */
    1011class Screenshots {
     12
     13    /**
     14     * @return string
     15     */
    1116    static function display() {
    1217        $plugin = get_post();
     18        $output = '';
    1319
    14         // All indexed from 1
     20        // All indexed from 1.
    1521        $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 );
    1723
    18         $output = '';
    1924        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             */
    2330            foreach ( $assets_screenshots as $image ) {
    2431                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                    );
    2642                    break;
    2743                }
    2844            }
    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                 $description
    44             );
    4545        }
    4646
    4747        return '<ol class="screenshots">' . $output . '</ol>';
    48 
    4948    }
    5049}
Note: See TracChangeset for help on using the changeset viewer.