Making WordPress.org


Ignore:
Timestamp:
02/25/2016 05:03:19 AM (10 years ago)
Author:
dd32
Message:

Plugin Directory: Switch to using namespaces instead of implemeting them through classnames.
This change introduces an autoloader and relies upon it for most file inclusions, this should encourage us to keep a standard naming schema and writing more component classes going forward.
See #1584

File:
1 moved

Legend:

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

    r2561 r2611  
    11<?php
    2 /**
    3  * @package WPorg_Plugin_Directory
    4  */
     2namespace WordPressdotorg\Plugin_Directory;
    53
    64/**
    75 * Various helpers to retrieve data not stored within WordPress.
     6 *
     7 * @package WordPressdotorg_Plugin_Directory
    88 */
    9 class WPorg_Plugin_Directory_Template {
     9class Template {
    1010
    1111    /**
     
    149149     */
    150150    static function get_plugin_icon( $plugin, $output = 'raw' ) {
    151         global $wporg_plugin_directory;
    152         $plugin = $wporg_plugin_directory->get_plugin_post( $plugin );
     151        $plugin = Plugin_Directory::instance()->get_plugin_post( $plugin );
    153152        if ( ! $plugin ) {
    154153            return false;
     
    176175        if ( ! $icon ) {
    177176            $generated = true;
    178             if ( ! class_exists( 'WPorg_Plugin_Geopattern' ) ) {
    179                 include __DIR__ . '/class-wporg-plugin-geopattern.php';
    180             }
    181             $icon = new WPorg_Plugin_Geopattern;
     177
     178            $icon = new Plugin_Geopattern;
    182179            $icon->setString( $plugin->post_name );
    183180
     
    218215     */
    219216    static function get_plugin_banner( $plugin, $output = 'raw' ) {
    220         global $wporg_plugin_directory;
    221         $plugin = $wporg_plugin_directory->get_plugin_post( $plugin );
     217        $plugin = Plugin_Directory::instance()->get_plugin_post( $plugin );
    222218        if ( ! $plugin ) {
    223219            return false;
     
    251247
    252248    static function get_asset_url( $plugin, $asset ) {
     249        if ( ! empty( $asset['location'] ) && 'plugin' == $asset['location'] ) {
     250            // Screenshots in the plugin folder - /plugins/plugin-name/screenshot-1.png
     251            $format = 'https://s.w.org/plugins/%s/%s?rev=%s';
     252        } else {
     253            // Images in the assets folder - /plugin-name/assets/screenshot-1.png
     254            $format = 'https://ps.w.org/%s/assets/%s?rev=%s';
     255        }
     256
    253257        return esc_url( sprintf(
    254             'https://ps.w.org/%s/assets/%s?rev=%s',
     258            $format,
    255259            $plugin,
    256260            $asset['filename'],
Note: See TracChangeset for help on using the changeset viewer.