Making WordPress.org

Changeset 2621


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.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
Files:
2 added
10 edited
1 moved

Legend:

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

    r2612 r2621  
    55 * All functionality related to the Administration interface.
    66 *
    7  * @package WordPressdotorg_Plugin_Directory
     7 * @package WordPressdotorg\Plugin_Directory\Admin
    88 */
    9 class Admin_Customizations {
     9class Customizations {
     10
    1011    /**
    1112     * Fetch the instance of the Plugin_Directory class.
     
    1314    public static function instance() {
    1415        static $instance = null;
    15         return ! is_null( $instance ) ? $instance : $instance = new Admin_Customizations();
     16
     17        return ! is_null( $instance ) ? $instance : $instance = new Customizations();
    1618    }
    1719
     20    /**
     21     *
     22     */
    1823    private function __construct() {
    1924        add_action( 'add_meta_boxes', array( $this, 'register_admin_metaboxes' ) );
     
    3136        );
    3237    }
    33 
    3438}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php

    r2611 r2621  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\Admin\Metabox;
     3
    34use WordPressdotorg\Plugin_Directory\Tools;
    45
     
    67 * The Plugin Committers admin metabox.
    78 *
    8  * @package WordPressdotorg_Plugin_Directory
     9 * @package WordPressdotorg\Plugin_Directory\Admin\Metabox
    910 */
    1011class Committers {
     12
     13    /**
     14     *
     15     */
    1116    static function display() {
    12         $plugin_slug = get_post()->post_name;
     17        $plugin_slug         = get_post()->post_name;
    1318        $existing_committers = Tools::get_plugin_committers( $plugin_slug );
    14         $existing_committers = array_map( function( $user ) { return new \WP_User( $user ); }, $existing_committers );
     19        $existing_committers = array_map( function ( $user ) {
     20            return new \WP_User( $user );
     21        }, $existing_committers );
    1522
    1623        $output = '';
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-autoloader.php

    r2611 r2621  
    55 * An Autoloader which respects WordPress's filename standards.
    66 *
    7  * @package WordPressdotorg_Plugin_Directory
     7 * @package WordPressdotorg\Plugin_Directory\Autoloader
    88 */
    99class Autoloader {
     
    2727        $class = substr( $class, $this->prefix_length + 1 );
    2828        $class = strtolower( $class );
    29         $file = '';
     29        $file  = '';
    3030
    3131        if ( false !== ( $last_ns_pos = strripos( $class, self::NS_SEPARATOR ) ) ) {
     
    4343        }
    4444    }
    45 
    4645}
    4746
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r2611 r2621  
    55 * The main Plugin Directory class, it handles most of the bootstrap and basic operations of the plugin.
    66 *
    7  * @package WordPressdotorg_Plugin_Directory
     7 * @package WordPressdotorg\Plugin_Directory
    88 */
    99class Plugin_Directory {
     
    1414    public static function instance( $plugin_file = null ) {
    1515        static $instance = null;
     16
    1617        return ! is_null( $instance ) ? $instance : $instance = new Plugin_Directory( $plugin_file );
    1718    }
    1819
     20    /**
     21     * @param string $plugin_file
     22     */
    1923    private function __construct( $plugin_file ) {
    2024        add_action( 'init', array( $this, 'init' ) );
     
    2529        add_filter( 'the_content', array( $this, 'filter_post_content_to_correct_page' ), 1 );
    2630
    27         // Load all Admin-specific items
    28         add_action( 'admin_init', array( __NAMESPACE__ . '\\Admin\\Admin_Customizations', 'instance' ) );
     31        // Load all Admin-specific items.
     32        add_action( 'admin_init', array( __NAMESPACE__ . '\\Admin\\Customizations', 'instance' ) );
    2933
    3034        register_activation_hook( $plugin_file, array( $this, 'activate' ) );
     
    9599        // When this plugin is used in the context of a Rosetta site, handle it gracefully
    96100        if ( 'wordpress.org' != $_SERVER['HTTP_HOST'] && defined( 'WPORG_PLUGIN_DIRECTORY_BLOGID' ) ) {
    97             $this->add_rosetta_network_filters();   
     101            add_filter( 'option_home',    array( $this, 'rosetta_network_localize_url' ) );
     102            add_filter( 'option_siteurl', array( $this, 'rosetta_network_localize_url' ) );
    98103        }
    99104    }
     
    109114
    110115    /**
    111      * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
     116     * @global \WP_Rewrite $wp_rewrite WordPress rewrite component.
    112117     */
    113118    public function activate() {
     
    151156
    152157    /**
     158     * Filter the URLs to use the current localized domain name, rather than WordPress.org.
     159     *
    153160     * The Plugin Directory is available at multiple URLs (internationalised domains), this method allows
    154161     * for the one blog (a single blog_id) to be presented at multiple URLs yet have correct localised links.
    155      */
    156     public function add_rosetta_network_filters() {
    157         // Filter the URLs to use the current localised domain name, rather than WordPress.org.
    158         foreach ( array( 'option_home', 'option_siteurl' ) as $filter ) {
    159             add_filter( $filter, function( $url ) {
    160                 static $localized_url = null;
    161                 if ( is_null( $localized_url ) ) {
    162                     $localized_url = 'https://' . preg_replace( '![^a-z.-]+!', '', $_SERVER['HTTP_HOST'] );
    163                 }
    164 
    165                 return preg_replace( '!^[https]+://wordpress\.org!i', $localized_url, $url );
    166             } );
    167         }
    168 
    169         /*
    170         // This method works in conjuction with a filter in sunrise.php, duplicated here for transparency:
    171 
    172         // Make the Plugin Directory available at /plugins/ on all rosetta sites.
    173         function wporg_plugins_on_rosetta_domains( $site, $domain, $path, $segments ) {
    174             // All non-rosetta networks define DOMAIN_CURRENT_SITE in wp-config.php
    175             if ( ! defined( 'DOMAIN_CURRENT_SITE' ) && 'wordpress.org' != $domain && '/plugins/' == substr( $path . '/', 0, 9 ) ) {
    176                 $site = get_blog_details( WPORG_PLUGIN_DIRECTORY_BLOGID );
    177                 if ( $site ) {
    178                     $site = clone $site;
    179                     // 6 = The Rosetta network, this causes the site to be loaded as part of the Rosetta network
    180                     $site->site_id = 6;
    181                     return $site;
    182                 }
    183             }
    184        
    185             return $site;
    186         }
    187         add_filter( 'pre_get_site_by_path', 'wporg_plugins_on_rosetta_domains', 10, 4 );
    188         */
     162     *
     163     * This method works in conjunction with a filter in sunrise.php, duplicated here for transparency:
     164     *
     165     * // Make the Plugin Directory available at /plugins/ on all rosetta sites.
     166     * function wporg_plugins_on_rosetta_domains( $site, $domain, $path, $segments ) {
     167     *     // All non-rosetta networks define DOMAIN_CURRENT_SITE in wp-config.php
     168     *     if ( ! defined( 'DOMAIN_CURRENT_SITE' ) && 'wordpress.org' != $domain && '/plugins/' == substr( $path . '/', 0, 9 ) ) {
     169     *          $site = get_blog_details( WPORG_PLUGIN_DIRECTORY_BLOGID );
     170     *          if ( $site ) {
     171     *              $site = clone $site;
     172     *              // 6 = The Rosetta network, this causes the site to be loaded as part of the Rosetta network
     173     *              $site->site_id = 6;
     174     *              return $site;
     175     *          }
     176     *     }
     177     *
     178     *     return $site;
     179     * }
     180     * add_filter( 'pre_get_site_by_path', 'wporg_plugins_on_rosetta_domains', 10, 4 );
     181     *
     182     * @param string $url The URL to be localized.
     183     * @return string
     184     */
     185    public function rosetta_network_localize_url( $url ) {
     186        static $localized_url = null;
     187
     188        if ( is_null( $localized_url ) ) {
     189            $localized_url = 'https://' . preg_replace( '![^a-z.-]+!', '', $_SERVER['HTTP_HOST'] );
     190        }
     191
     192        return preg_replace( '!^[https]+://wordpress\.org!i', $localized_url, $url );
    189193    }
    190194
     
    192196     * Filter the permalink for the Plugins to be /plugin-name/.
    193197     *
    194      * @param string  $link The generated permalink.
    195      * @param WP_Post $post The Plugin post object.
     198     * @param string   $link The generated permalink.
     199     * @param \WP_Post $post The Plugin post object.
    196200     * @return string
    197201     */
     
    208212     *
    209213     * @param string $term The term to add or update.
    210      * @return string|WP_Error The term to add or update or WP_Error on failure.
     214     * @return string|\WP_Error The term to add or update or WP_Error on failure.
    211215     */
    212216    public function pre_insert_term_prevent( $term ) {
    213217        if ( ! is_super_admin() ) {
    214             $term = new WP_Error( 'not-allowed', __( 'You are not allowed to add terms.', 'wporg-plugins' ) );
     218            $term = new \WP_Error( 'not-allowed', __( 'You are not allowed to add terms.', 'wporg-plugins' ) );
    215219        }
    216220
     
    219223
    220224    /**
    221      * @param WP_Query $wp_query The WordPress Query object.
     225     * @param \WP_Query $wp_query The WordPress Query object.
    222226     */
    223227    public function use_plugins_in_query( $wp_query ) {
     
    299303     */
    300304    public function split_post_content_into_pages( $content ) {
    301         $_pages = preg_split( "#<!--section=(.+?)-->#", $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
     305        $_pages        = preg_split( "#<!--section=(.+?)-->#", $content, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
    302306        $content_pages = array(
    303307            'screenshots' => '[wporg-plugins-screenshots]',
     
    318322
    319323    /**
    320      * Retrieve the WP_Post object representing a given plugin.
    321      *
    322      * @param $plugin_slug string|WP_Post The slug of the plugin to retrieve.
    323      * @return WP_Post|WP_Error
    324      */
     324     * Retrieve the WP_Post object representing a given plugin.
     325     *
     326     * @param $plugin_slug string|\WP_Post The slug of the plugin to retrieve.
     327     * @return \WP_Post|\WP_Error
     328     */
    325329    public function get_plugin_post( $plugin_slug ) {
    326330        if ( $plugin_slug instanceof \WP_Post ) {
     
    332336            'post_type'   => 'plugin',
    333337            'name'        => $plugin_slug,
    334             'post_status' => 'any'
     338            'post_status' => 'any',
    335339        ) );
    336340        if ( ! $posts ) {
     
    338342        }
    339343
    340         $plugin = reset( $posts );
    341         return $plugin;
    342     }
    343 
    344     /**
    345      * Create a new post entry for a given plugin slug.
    346      *
     344        return reset( $posts );
     345    }
     346
     347    /**
     348     * Create a new post entry for a given plugin slug.
     349     *
    347350     * @param array $plugin_info {
    348351     *     Array of initial plugin post data, all fields are optional.
    349      *
     352     *
    350353     *     @type string $title       The title of the plugin.
    351354     *     @type string $slug        The slug of the plugin.
     
    354357     *     @type string $description The short description of the plugin.
    355358     * }
    356      * @return WP_Post|WP_Error
    357      */
     359     * @return \WP_Post|\WP_Error
     360     */
    358361    public function create_plugin_post( array $plugin_info ) {
    359362        $title  = !empty( $plugin_info['title'] )       ? $plugin_info['title']       : '';
     
    377380        }
    378381
    379         $plugin = get_post( $id );
    380         return $plugin;
     382        return get_post( $id );
    381383    }
    382384}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-geopattern.php

    r2611 r2621  
    77 * Generates Geopattern icons for Plugins.
    88 *
    9  * @package WordPressdotorg_Plugin_Directory
     9 * @package WordPressdotorg\Plugin_Directory
    1010 */
    1111class Plugin_Geopattern extends \RedeyeVentures\GeoPattern\GeoPattern {
    1212
    13     var $slug; // Hashed to generate pattern
    14     var $text; // Text to be overlaid
    15     var $textcolor = 'black';
     13    /**
     14     * Hashed to generate pattern.
     15     *
     16     * @var string
     17     */
     18    public $slug;
    1619
    17     function __construct($options=array()) {
     20    /**
     21     * Text to be overlaid.
     22     *
     23     * @var string
     24     */
     25    public $text;
     26
     27    /**
     28     * @var string
     29     */
     30    public $textcolor = 'black';
     31
     32    /**
     33     * @param array $options
     34     */
     35    function __construct( $options = array() ) {
    1836        parent::__construct( $options );
    1937
    20         if ( isset( $options['text'] ) )
     38        if ( isset( $options['text'] ) ) {
    2139            $this->text = $options['text'];
     40        }
    2241
    23         if ( isset( $options['textcolor'] ) )
     42        if ( isset( $options['textcolor'] ) ) {
    2443            $this->textcolor = $options['textcolor'];
     44        }
    2545
    2646        // Replace the base SVG object with our own, so the dimensions are gettable.
     
    2848    }
    2949
     50    /**
     51     * @param $text
     52     */
    3053    function setText( $text ) {
    3154        $this->text = $text;
    3255    }
    3356
     57    /**
     58     * @param $color
     59     */
    3460    function setTextColor( $color ) {
    3561        $this->textcolor = $color;
    3662    }
    3763
     64    /**
     65     *
     66     */
    3867    function generateText() {
    39         $size = min( $this->svg->getHeight(), $this->svg->getWidth() );
     68        $size        = min( $this->svg->getHeight(), $this->svg->getWidth() );
    4069        $text_height = floor( $size * 0.8 ) . 'px';
    4170
     
    4372    }
    4473
     74    /**
     75     * @param int $width
     76     * @param int $height
     77     * @return string
     78     */
    4579    public function toSVG( $width = 128, $height = 128 ) {
    4680        $this->svg = new Plugin_Geopattern_SVG();
    4781        $this->generateBackground();
    4882
    49         // Work around a bug in 1.1.0: the hash-based pattern selection doesn't account for the size of the pattern array and can choose a null result.
    50         $this->setGenerator( $this->patterns[$this->hexVal(20, 1) % count( $this->patterns )] );
     83        /*
     84         * Work around a bug in 1.1.0:
     85         * The hash-based pattern selection doesn't account for the size of the
     86         * pattern array and can choose a null result.
     87         */
     88        $this->setGenerator( $this->patterns[ $this->hexVal( 20, 1 ) % count( $this->patterns ) ] );
    5189
    5290        $this->generatePattern();
     
    5997            $inner = $this->svg;
    6098
    61             // Outer SVG, containing the text and nested inner SVG.
    62             // Needed because of aspect ratio problems with the background pattern. The outer is square, inner may be a different shape.
     99            /*
     100             * Outer SVG, containing the text and nested inner SVG.
     101             *
     102             * Needed because of aspect ratio problems with the background pattern.
     103             * The outer is square, inner may be a different shape.
     104             */
    63105            $this->svg = new PluginSVG();
    64106            $this->svg->setWidth( $width );
     
    69111
    70112        return $this->svg->getString();
    71 
    72     }
    73 
    74 }
    75 
    76 // The base SVG class doesn't provide functions for getting dimensions, so..
    77 class Plugin_Geopattern_SVG extends \RedeyeVentures\GeoPattern\SVG {
    78 
    79     protected $viewbox;
    80 
    81     function getWidth() {
    82         return $this->width;
    83     }
    84 
    85     function getHeight() {
    86         return $this->height;
    87     }
    88 
    89     protected function getSvgHeader() {
    90         if ( $this->viewbox )
    91             return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{$this->width}\" height=\"{$this->height}\" viewbox=\"{$this->viewbox}\" preserveAspectRatio=\"none\">";
    92         else
    93             return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"{$this->width}\" height=\"{$this->height}\">";
    94     }
    95 
    96     public function addText( $text, $x, $y, $text_anchor, $style, $args=array() ) {
    97         $element = new Plugin_Geopattern_SVGText($text, $x, $y, $text_anchor, $style, $args);
    98         $this->svgString .= $element;
    99         return $this;
    100     }
    101 
    102     public function addNested( $svg ) {
    103         if ( method_exists( $svg, 'getString' ) )
    104             $this->svgString .= $svg->getString();
    105     }
    106 
    107     public function setViewBox( $x, $y, $w, $h ) {
    108         $this->viewbox = esc_attr( "$x $y $w $h" );
    109     }
    110 
    111 }
    112 
    113 // Nor does it support text.
    114 class Plugin_Geopattern_SVGText extends \RedeyeVentures\GeoPattern\SVGElements\Base {
    115     protected $tag = 'text';
    116     protected $text;
    117 
    118     function __construct($text, $x, $y, $text_anchor, $style, $args=array()) {
    119         $this->elements = array(
    120             'x' => $x,
    121             'y' => $y,
    122             'text-anchor' => $text_anchor,
    123             'style' => $style,
    124             );
    125         $this->text = esc_html( $text );
    126         parent::__construct($args);
    127     }
    128 
    129     public function getString() {
    130         return "<{$this->tag}{$this->elementsToString()}{$this->argsToString()}>{$this->text}</{$this->tag}>";
    131113    }
    132114}
    133 
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php

    r2611 r2621  
    55 * Various helpers to retrieve data not stored within WordPress.
    66 *
    7  * @package WordPressdotorg_Plugin_Directory
     7 * @package WordPressdotorg\Plugin_Directory
    88 */
    99class Template {
     
    5353     */
    5454    static function get_plugin_sections() {
    55         $plugin       = get_post();
    56         $plugin_slug  = $plugin->post_name;
     55        $plugin      = get_post();
     56        $plugin_slug = $plugin->post_name;
    5757
    5858        $default_sections = array(
     
    7171        $raw_sections = array_unique( array_merge( $raw_sections, $default_sections ) );
    7272
    73         $sections  = array();
    74         $title     = '';
    75         $permalink = get_permalink();
     73        $sections     = array();
     74        $title = $url = '';
     75        $permalink    = get_permalink();
    7676
    7777        foreach ( $raw_sections as $section_slug ) {
     
    145145     * Retrieve the Plugin Icon details for a plugin.
    146146     *
    147      * @param WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.
     147     * @param \WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.
    148148     * @return mixed
    149149     */
     
    163163                    $icon_2x = self::get_asset_url( $plugin_slug, $info );
    164164                    break;
     165
    165166                case '128x128':
    166167                    $icon = self::get_asset_url( $plugin_slug, $info );
    167168                    break;
     169
    168170                case false && 'icon.svg' == $file:
    169                     $icon = self::get_asset_url( $plugin_slug, $info );
     171                    $icon   = self::get_asset_url( $plugin_slug, $info );
    170172                    $vector = true;
    171173                    break;
     
    191193        switch ( $output ) {
    192194            case 'html':
    193                 $id = "plugin-icon-{$plugin_slug}";
     195                $id   = "plugin-icon-{$plugin_slug}";
    194196                $html = "<style type='text/css'>";
    195197                $html .= "#{$id} { width:128px; height:128px; background-image: url('{$icon}'); background-size:128px 128px; }";
     
    202204                return $html;
    203205                break;
     206
    204207            case 'raw':
    205208            default:
     
    211214     * Retrieve the Plugin Icon details for a plugin.
    212215     *
    213      * @param WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.
     216     * @param \WP_Post|string $plugin An instance of a Plugin post, or the plugin slug.
    214217     * @return mixed
    215218     */
     
    229232                    $banner_2x = self::get_asset_url( $plugin_slug, $info );
    230233                    break;
     234
    231235                case '772x250':
    232236                    $banner = self::get_asset_url( $plugin_slug, $info );
     
    246250    }
    247251
     252    /**
     253     * @param $plugin
     254     * @param $asset
     255     * @return string
     256     */
    248257    static function get_asset_url( $plugin, $asset ) {
    249258        if ( ! empty( $asset['location'] ) && 'plugin' == $asset['location'] ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php

    r2611 r2621  
    55 * Various functions used by other processes, will make sense to move to specific classes.
    66 *
    7  * @package WordPressdotorg_Plugin_Directory
     7 * @package WordPressdotorg\Plugin_Directory
    88 */
    99class Tools {
     
    5454
    5555        $tonesque = new \Tonesque( $file_location );
     56
    5657        return $tonesque->color();
    5758    }
     
    7273     * Grant a user RW access to a plugin.
    7374     *
    74      * @param string         $plugin_slug The plugin slug.
    75      * @param string|WP_User $user        The user to grant access to.
     75     * @param string          $plugin_slug The plugin slug.
     76     * @param string|\WP_User $user        The user to grant access to.
     77     * @return bool
    7678     */
    7779    public static function grant_plugin_committer( $plugin_slug, $user ) {
    7880        global $wpdb;
     81
    7982        if ( ! $user instanceof \WP_User ) {
    8083            $user = new \WP_User( $user );
     
    9194        }
    9295
    93         return (bool)$wpdb->insert(
     96        return (bool) $wpdb->insert(
    9497            PLUGINS_TABLE_PREFIX . 'svn_access',
    9598            array(
     
    104107     * Revoke a users RW access to a plugin.
    105108     *
    106      * @param string         $plugin_slug The plugin slug.
    107      * @param string|WP_User $user        The user to revoke access of.
     109     * @param string          $plugin_slug The plugin slug.
     110     * @param string|\WP_User $user        The user to revoke access of.
     111     * @return bool
    108112     */
    109113    public static function revoke_plugin_committer( $plugin_slug, $user ) {
    110114        global $wpdb;
     115
    111116        if ( ! $user instanceof \WP_User ) {
    112117            $user = new \WP_User( $user );
     
    120125            PLUGINS_TABLE_PREFIX . 'svn_access',
    121126            array(
    122                 'path'   => "/{$plugin_slug}",
    123                 'user'   => $user->user_login
     127                'path' => "/{$plugin_slug}",
     128                'user' => $user->user_login,
    124129            )
    125130        );
    126131    }
    127 
    128 
    129132}
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/plugin-directory.php

    r2611 r2621  
    11<?php
    2 namespace WordPressdotorg\Plugin_Directory;
    32/**
    43 * Plugin Name: Plugin Directory
     
    1514 */
    1615
     16namespace WordPressdotorg\Plugin_Directory;
     17
    1718// Register an Autoloader for all files
    1819include __DIR__ . '/class-autoloader.php';
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme-parser/ReadmeParser.php

    r2563 r2621  
    343343        $text        = str_replace( '&#39;', "'", $text );
    344344
    345             if ( '<pre><code>' == $matches[1] ) {
     345        if ( '<pre><code>' == $matches[1] ) {
    346346            $text = "\n$text\n";
    347347        }
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme-parser/compat.php

    r2501 r2621  
    4040        }
    4141
    42         $result = parent::parse_readme_contents( $contents );
     42        $result           = parent::parse_readme_contents( $contents );
    4343        $result->sections = array_map( array( 'WPorg_Readme', 'filter_text' ), $result->sections );
    4444
     
    7373     * @access protected
    7474     *
    75      * @param string $desc
     75     * @param string $description
    7676     * @return string
    7777     */
    78     protected static function trim_short_desc( &$desc ) {
    79         $desc = self::sanitize_text( $desc );
    80         parent::trim_short_desc( $desc );
     78    protected static function trim_short_desc( &$description ) {
     79        $description = self::sanitize_text( $description );
     80        parent::trim_short_desc( $description );
    8181
    82         return $desc;
     82        return $description;
    8383    }
    8484
  • 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.