Changeset 6287 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
- Timestamp:
- 12/19/2017 04:22:37 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r6250 r6287 3 3 4 4 // 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' );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'; 8 8 9 9 /** … … 137 137 138 138 if ( is_singular( 'plugin' ) ) { 139 $metas[] = sprintf( '<meta name="description" value="%s" />', 139 $metas[] = sprintf( 140 '<meta name="description" value="%s" />', 140 141 esc_attr( get_the_excerpt() ) 141 142 ); … … 192 193 193 194 // 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 ) ); 195 196 196 197 wp_cache_set( $post->ID, $count, 'plugin_download_count', HOUR_IN_SECONDS ); … … 212 213 global $wpdb; 213 214 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`' ); 215 216 wp_cache_set( 'plugin_download_count', $count, 'plugin_download_count', DAY_IN_SECONDS ); 216 217 } … … 234 235 $num_ratings = array_sum( $ratings ); 235 236 236 return 237 '<div class="plugin-rating">' . 237 return '<div class="plugin-rating">' . 238 238 Template::dashicons_stars( $rating ) . 239 239 '<span class="rating-count">(' . … … 356 356 */ 357 357 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 359 364 $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; 362 366 363 367 foreach ( $raw_icons as $file => $info ) { … … 391 395 $generated = true; 392 396 393 $icon = new Plugin_Geopattern ;397 $icon = new Plugin_Geopattern(); 394 398 $icon->setString( $plugin->post_name ); 395 399 … … 412 416 $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$icon_2x}'); } }"; 413 417 } 414 $html .= "</style>";418 $html .= '</style>'; 415 419 $html .= "<div class='plugin-icon' id='{$id}'></div>"; 416 420 … … 425 429 426 430 /** 427 * Retrieve the Plugin Icondetails for a plugin.431 * Retrieve the Plugin banner details for a plugin. 428 432 * 429 433 * @static … … 436 440 $plugin = get_post( $post ); 437 441 438 if ( in_array( $plugin->post_status, [ 'disabled', 'closed'], true ) ) {442 if ( in_array( $plugin->post_status, [ 'disabled', 'closed' ], true ) ) { 439 443 return false; 440 444 } … … 488 492 $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$banner_2x}'); } }"; 489 493 } 490 $html .= "</style>";494 $html .= '</style>'; 491 495 $html .= "<div class='plugin-banner' id='{$id}'></div>"; 492 496 … … 580 584 */ 581 585 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( 583 588 'rating' => 0, 584 589 'template' => '<span class="%1$s"></span>', … … 629 634 630 635 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 ); 632 637 } 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 ); 634 639 } 635 640 } … … 662 667 663 668 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', 666 671 ), home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/favorite' ) ); 667 672 } … … 759 764 'locale' => 'en_US', 760 765 'hreflang' => 'en', 761 'subdomain' => '' 766 'subdomain' => '', 762 767 ); 763 768 … … 766 771 } ); 767 772 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 ); 769 774 } 770 775 … … 773 778 'https://%swordpress.org%s', 774 779 $site->subdomain ? "{$site->subdomain}." : '', 775 $_SERVER[ 'REQUEST_URI']780 $_SERVER['REQUEST_URI'] 776 781 ); 777 782
Note: See TracChangeset
for help on using the changeset viewer.