Making WordPress.org


Ignore:
Timestamp:
12/19/2017 04:22:37 PM (9 years ago)
Author:
obenland
Message:

PLugins: Clean up formatting with phpcbf

File:
1 edited

Legend:

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

    r6250 r6287  
    33
    44// Explicitly require dependencies so this file can be sourced outside the Plugin Directory.
    5 require_once( __DIR__ . '/class-plugin-geopattern.php' );
    6 require_once( __DIR__ . '/class-plugin-geopattern-svg.php' );
    7 require_once( __DIR__ . '/class-plugin-geopattern-svgtext.php' );
     5require_once __DIR__ . '/class-plugin-geopattern.php';
     6require_once __DIR__ . '/class-plugin-geopattern-svg.php';
     7require_once __DIR__ . '/class-plugin-geopattern-svgtext.php';
    88
    99/**
     
    137137
    138138                if ( is_singular( 'plugin' ) ) {
    139                         $metas[] = sprintf( '<meta name="description" value="%s" />',
     139                        $metas[] = sprintf(
     140                                '<meta name="description" value="%s" />',
    140141                                esc_attr( get_the_excerpt() )
    141142                        );
     
    192193
    193194                        // TODO: While the plugin ZIPs are still being served by bbPress, the download stats are stored there.
    194                         $count = $wpdb->get_var( $wpdb->prepare( "SELECT downloads FROM `" . PLUGINS_TABLE_PREFIX . "download_counts` WHERE topic_id = (SELECT topic_id FROM `" . PLUGINS_TABLE_PREFIX . "topics` WHERE topic_slug = %s )", $post->post_name ) );
     195                        $count = $wpdb->get_var( $wpdb->prepare( 'SELECT downloads FROM `' . PLUGINS_TABLE_PREFIX . 'download_counts` WHERE topic_id = (SELECT topic_id FROM `' . PLUGINS_TABLE_PREFIX . 'topics` WHERE topic_slug = %s )', $post->post_name ) );
    195196
    196197                        wp_cache_set( $post->ID, $count, 'plugin_download_count', HOUR_IN_SECONDS );
     
    212213                        global $wpdb;
    213214
    214                         $count = $wpdb->get_var( "SELECT SUM(downloads) FROM `" . PLUGINS_TABLE_PREFIX . "stats`" );
     215                        $count = $wpdb->get_var( 'SELECT SUM(downloads) FROM `' . PLUGINS_TABLE_PREFIX . 'stats`' );
    215216                        wp_cache_set( 'plugin_download_count', $count, 'plugin_download_count', DAY_IN_SECONDS );
    216217                }
     
    234235                $num_ratings = array_sum( $ratings );
    235236
    236                 return
    237                         '<div class="plugin-rating">' .
     237                return '<div class="plugin-rating">' .
    238238                                Template::dashicons_stars( $rating ) .
    239239                                '<span class="rating-count">(' .
     
    356356         */
    357357        public static function get_plugin_icon( $post = null, $output = 'raw' ) {
    358                 $plugin    = get_post( $post );
     358                $plugin = get_post( $post );
     359
     360                if ( in_array( $plugin->post_status, [ 'disabled', 'closed' ], true ) ) {
     361                        return false;
     362                }
     363
    359364                $raw_icons = get_post_meta( $plugin->ID, 'assets_icons', true ) ?: array();
    360 
    361                 $icon = $icon_2x = $svg = $generated = false;
     365                $icon      = $icon_2x = $svg = $generated = false;
    362366
    363367                foreach ( $raw_icons as $file => $info ) {
     
    391395                        $generated = true;
    392396
    393                         $icon = new Plugin_Geopattern;
     397                        $icon = new Plugin_Geopattern();
    394398                        $icon->setString( $plugin->post_name );
    395399
     
    412416                                        $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$icon_2x}'); } }";
    413417                                }
    414                                 $html .= "</style>";
     418                                $html .= '</style>';
    415419                                $html .= "<div class='plugin-icon' id='{$id}'></div>";
    416420
     
    425429
    426430        /**
    427          * Retrieve the Plugin Icon details for a plugin.
     431         * Retrieve the Plugin banner details for a plugin.
    428432         *
    429433         * @static
     
    436440                $plugin = get_post( $post );
    437441
    438                 if ( in_array( $plugin->post_status, ['disabled', 'closed'], true ) ) {
     442                if ( in_array( $plugin->post_status, [ 'disabled', 'closed' ], true ) ) {
    439443                        return false;
    440444                }
     
    488492                                        $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$banner_2x}'); } }";
    489493                                }
    490                                 $html .= "</style>";
     494                                $html .= '</style>';
    491495                                $html .= "<div class='plugin-banner' id='{$id}'></div>";
    492496
     
    580584         */
    581585        public static function dashicons_stars( $args = array() ) {
    582                 $args = wp_parse_args( ( is_numeric( $args ) ? array( 'rating' => $args ) : $args ), array(
     586                $args = is_numeric( $args ) ? array( 'rating' => $args ) : $args;
     587                $args = wp_parse_args( $args, array(
    583588                        'rating'   => 0,
    584589                        'template' => '<span class="%1$s"></span>',
     
    629634
    630635                if ( 'trunk' != $version ) {
    631                         return sprintf( "https://downloads.wordpress.org/plugin/%s.%s.zip", $post->post_name, $version );
     636                        return sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $post->post_name, $version );
    632637                } else {
    633                         return sprintf( "https://downloads.wordpress.org/plugin/%s.zip", $post->post_name );
     638                        return sprintf( 'https://downloads.wordpress.org/plugin/%s.zip', $post->post_name );
    634639                }
    635640        }
     
    662667
    663668                return add_query_arg( array(
    664                         '_wpnonce' => wp_create_nonce( 'wp_rest' ),
    665                         ( $favorited ? 'unfavorite' : 'favorite' ) => '1'
     669                        '_wpnonce'                                 => wp_create_nonce( 'wp_rest' ),
     670                        ( $favorited ? 'unfavorite' : 'favorite' ) => '1',
    666671                ), home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/favorite' ) );
    667672        }
     
    759764                                'locale'    => 'en_US',
    760765                                'hreflang'  => 'en',
    761                                 'subdomain' => ''
     766                                'subdomain' => '',
    762767                        );
    763768
     
    766771                        } );
    767772
    768                         wp_cache_set( 'local-sites-'.get_post()->post_name, $sites, 'locale-associations', DAY_IN_SECONDS );
     773                        wp_cache_set( 'local-sites-' . get_post()->post_name, $sites, 'locale-associations', DAY_IN_SECONDS );
    769774                }
    770775
     
    773778                                'https://%swordpress.org%s',
    774779                                $site->subdomain ? "{$site->subdomain}." : '',
    775                                 $_SERVER[ 'REQUEST_URI' ]
     780                                $_SERVER['REQUEST_URI']
    776781                        );
    777782
Note: See TracChangeset for help on using the changeset viewer.