Changeset 3009
- Timestamp:
- 04/26/2016 07:33:28 AM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 3 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/list-table/class-plugin-posts.php
r2998 r3009 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\List_Table; 3 3 use \WordPressdotorg\Plugin_Directory\Tools; 4 use \WordPressdotorg\Plugin_Directory\Template; 4 5 5 6 _get_list_table( 'WP_Posts_List_Table' ); … … 159 160 */ 160 161 public function column_rating( $post ) { 161 if ( function_exists( 'wporg_get_dashicons_stars' ) ) { 162 echo wporg_get_dashicons_stars( get_post_meta( $post->ID, 'rating', true ) ); 163 } 162 echo Template::dashicons_stars( get_post_meta( $post->ID, 'rating', true ) ); 164 163 } 165 164 … … 170 169 */ 171 170 public function column_installs( $post ) { 172 $active_installs = get_post_meta( $post->ID, 'active_installs', true ); 173 if ( $active_installs >= 1000000 ) { 174 _e( '1+ million', 'wporg-plugins' ); 175 } elseif ( $active_installs <= 10 ) { 176 _e( 'Less than 10', 'wporg-plugins' ); 177 } else { 178 printf( "%s+", number_format_i18n( $active_installs ) ); 179 } 171 echo Template::active_installs( false, $post ); 180 172 } 181 173 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r2998 r3009 22 22 add_action( 'init', array( $this, 'init' ) ); 23 23 add_action( 'init', array( $this, 'register_shortcodes' ) ); 24 add_action( 'widgets_init', array( $this, 'register_widgets' ) ); 24 25 add_filter( 'post_type_link', array( $this, 'package_link' ), 10, 2 ); 25 26 add_filter( 'pre_insert_term', array( $this, 'pre_insert_term_prevent' ) ); … … 32 33 33 34 // Shim in postmeta support for data which doesn't yet live in postmeta 34 add_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ), 10, 4);35 add_filter( 'get_post_metadata', array( $this, 'filter_shim_postmeta' ), 10, 3 ); 35 36 36 37 // Load the API routes … … 196 197 } 197 198 199 public function register_widgets() { 200 register_widget( __NAMESPACE__ . '\Widgets\Metadata' ); 201 register_widget( __NAMESPACE__ . '\Widgets\Ratings' ); 202 } 203 198 204 /** 199 205 * Upon plugin activation, set up the current site for acting … … 423 429 * @param int $object_id Object ID. 424 430 * @param string $meta_key Meta key. 425 * @param bool $single Whether to return only the first value of the specified $meta_key. 426 */ 427 public function filter_shim_postmeta( $value, $object_id, $meta_key, $single ) { 431 */ 432 public function filter_shim_postmeta( $value, $object_id, $meta_key ) { 428 433 switch ( $meta_key ) { 429 434 case 'downloads': … … 431 436 $count = Template::get_downloads_count( $post ); 432 437 433 return $single ? $count :array( $count );438 return array( $count ); 434 439 break; 435 440 case 'rating': … … 441 446 $rating = wporg_get_rating_avg( 'plugin', $post->post_name ); 442 447 443 return $single ? $rating : array( $rating ); 448 return array( $rating ); 449 break; 450 case 'ratings': 451 $post = get_post( $object_id ); 452 if ( ! function_exists( 'wporg_get_rating_counts' ) ) { 453 break; 454 } 455 $ratings = wporg_get_rating_counts( 'plugin', $post->post_name ); 456 457 return array( $ratings ); 444 458 break; 445 459 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r2994 r3009 10 10 11 11 /** 12 * @param \WP_Post|int $post Optional. 13 * @return int 14 */ 15 static function get_active_installs_count( $post = null ) { 12 * Returns a string representing the number of active installs for an item. 13 * 14 * @param bool $full whether to include "actuve installs" suffix. Default: true. 15 * @return string "1+ million" or "1+ milllion active installs" depending on $full. 16 */ 17 static function active_installs( $full = true, $post = null ) { 16 18 $post = get_post( $post ); 17 19 18 return (int) get_post_meta( $post->ID, 'active_installs', true ); 19 } 20 $count = get_post_meta( $post->ID, 'active_installs', true ); 21 22 if ( $count <= 10 ) { 23 $text = __( 'Less than 10', 'wporg-plugins' ); 24 } elseif ( $count >= 1000000 ) { 25 $text = __( '1+ million', 'wporg-plugins' ); 26 } else { 27 $text = number_format_i18n( $count ) . '+'; 28 } 29 return $full ? sprintf( __( '%s active installs', 'wporg-plugins' ), $text ) : $text; 30 } 31 20 32 21 33 /** … … 276 288 ) ); 277 289 } 290 291 /** 292 * A helper method to create dashicon stars. 293 * 294 * @type int|array { 295 * If numeric arg passed, assumed to be 'rating'. 296 * 297 * @type int $rating The rating to display. 298 * @type string $template The HTML template to use for each star. 299 * %1$s is the class, %2$s is the rating. 300 * } 301 * @return string The Rating HTML. 302 */ 303 static function dashicons_stars( $args = array() ) { 304 $defaults = array( 305 'rating' => 0, 306 'template' => '<span class="%1$s"></span>' 307 ); 308 $r = wp_parse_args( ( is_numeric( $args ) ? array( 'rating' => $args ) : $args ), $defaults ); 309 310 $rating = round( $r['rating'] / 0.5 ) * 0.5; 311 $template = $r['template']; 312 $title_template = __( '%s out of 5 stars', 'wporg-plugins' ); 313 $title = sprintf( $title_template, $rating ); 314 315 $output = '<div class="wporg-ratings" title="' . esc_attr( $title ) . '" data-title-template="' . esc_attr( $title_template ) . '" data-rating="' . esc_attr( $rating ) . '" style="color:#ffb900;">'; 316 $counter = round( $rating * 2 ); 317 for ( $i = 1; $i <= 5; $i++ ) { 318 switch ($counter) { 319 case 0: 320 $output .= sprintf( $template, 'dashicons dashicons-star-empty', $i ); 321 break; 322 case 1: 323 $output .= sprintf( $template, 'dashicons dashicons-star-half', $i ); 324 $counter--; 325 break; 326 default: 327 $output .= sprintf( $template, 'dashicons dashicons-star-filled', $i ); 328 $counter -= 2; 329 break; 330 } 331 } 332 $output .= '</div>'; 333 return $output; 334 } 335 278 336 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/filter-bar.php
r2502 r3009 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 3 4 ?> 1 5 <div class="wrapper"> 2 6 <div class="col-12 filter-bar"> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/footer.php
r2499 r3009 1 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 3 2 4 /** 3 5 * The template for displaying the footer. … … 5 7 * @package wporg-plugins 6 8 */ 7 ?>8 </div>9 9 10 <?php require WPORGPATH . 'footer.php'; 10 echo '</div>'; 11 12 require WPORGPATH . 'footer.php'; -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php
r2499 r3009 1 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 2 3 3 4 /** … … 18 19 ) ); 19 20 21 register_sidebar( array( 22 'name' => 'Single Plugin View Sidebar', 23 'id' => 'single-plugin-sidebar', 24 'before_widget' => '<div id="%1$s" class="widget %2$s">', 25 'after_widget' => '</div>', 26 ) ); 27 20 28 // No need for canonical lookups 21 //remove_action( 'template_redirect', 'redirect_canonical' ); 22 remove_action( 'template_redirect', 'wp_old_slug_redirect' ); 29 remove_action( 'template_redirect', __NAMESPACE__ . '\wp_old_slug_redirect' ); 23 30 } 24 add_action( 'after_setup_theme', 'wporg_plugins_setup' );31 add_action( 'after_setup_theme', __NAMESPACE__ . '\wporg_plugins_setup' ); 25 32 26 33 /** … … 45 52 add_filter( 'jetpack_implode_frontend_css', '__return_false' ); 46 53 } 47 add_action( 'wp_enqueue_scripts', 'wporg_plugins_scripts' );54 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\wporg_plugins_scripts' ); 48 55 49 56 function wporg_plugins_body_class( $classes ) { … … 51 58 return $classes; 52 59 } 53 add_filter( 'body_class', 'wporg_plugins_body_class' );60 add_filter( 'body_class', __NAMESPACE__ . '\wporg_plugins_body_class' ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/header.php
r2499 r3009 1 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 3 2 4 /** 3 5 * The header for our theme. -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/index.php
r2499 r3009 1 <?php get_header(); ?> 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 3 4 get_header(); 5 ?> 2 6 3 7 <?php get_template_part( 'filter-bar' ); ?> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/page.php
r2499 r3009 1 <?php get_header(); ?> 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 3 4 get_header(); 5 ?> 2 6 3 7 <?php the_post(); ?> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/plugin-card.php
r2998 r3009 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 3 use WordPressdotorg\Plugin_Directory\Template; 4 5 ?> 1 6 <div class="plugin-card"> 2 7 <div class="plugin-card-top"> 3 8 4 9 <a href="<?php the_permalink(); ?>" class="plugin-icon"> 5 <?php echo WordPressdotorg\Plugin_Directory\Template::get_plugin_icon( $post->post_name, 'html' ); ?>10 <?php echo Template::get_plugin_icon( $post->post_name, 'html' ); ?> 6 11 </a> 7 12 <div class="name column-name"> … … 16 21 <div class="plugin-card-bottom"> 17 22 <div class="vers column-rating"> 18 <?php 19 if ( function_exists( 'wporg_get_dashicons_stars' ) ) { 20 echo wporg_get_dashicons_stars( get_post_meta( $post->ID, 'rating', true ) ); 21 } 22 ?> 23 <?php echo Template::dashicons_stars( get_post_meta( $post->ID, 'rating', true ) ); ?> 23 24 </div> 24 25 <div class="column-updated"> … … 26 27 </div> 27 28 <div class="column-installs"> 28 <?php echo worg_plugins_template_active_installs( true); ?>29 <?php echo Template::active_installs(); ?> 29 30 </div> 30 31 <div class="column-compatibility"> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/single-plugin.php
r2654 r3009 1 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 3 use WordPressdotorg\Plugin_Directory\Template; 4 2 5 the_post(); 3 6 get_header(); 4 $plugin_banners = WordPressdotorg\Plugin_Directory\Template::get_plugin_banner( $post );7 $plugin_banners = Template::get_plugin_banner( $post ); 5 8 6 9 ?> … … 46 49 <ul id="sections"> 47 50 <?php 48 foreach ( WordPressdotorg\Plugin_Directory\Template::get_plugin_sections() as $section ) {51 foreach ( Template::get_plugin_sections() as $section ) { 49 52 $current = ( $section['slug'] == get_query_var( 'content_page' ) || ( 'description' == $section['slug'] && ! get_query_var( 'content_page' ) ) ); 50 53 printf( … … 66 69 67 70 <div class="" style="width: 212px; float: right;"> 68 <p> 69 <strong>Version:</strong> <?php echo wporg_plugins_the_version(); ?><br> 70 <strong>Requires:</strong> <?php printf( __('%s or higher', 'wporg-plugins' ), wporg_plugins_template_requires() ); ?><br> 71 <strong>Compatible up to:</strong> <?php echo wporg_plugins_template_compatible_up_to(); ?><br> 72 <strong>Last Updated: </strong> <?php echo wporg_plugins_template_last_updated(); ?><br> 73 <strong>Active Installs:</strong> <?php echo worg_plugins_template_active_installs( false ); ?><br> 74 <meta itemprop="dateModified" content="<?php the_time('Y-m-d'); ?>" /> 75 </p> 71 <?php dynamic_sidebar('single-plugin-sidebar'); ?> 76 72 </div> 77 73 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/style.css
r2973 r3009 1448 1448 background-color: inherit; 1449 1449 } 1450 1451 .widget { 1452 margin-bottom: 1em; 1453 1454 } 1455 1456 /* Ratings */ 1457 .widget.plugin-ratings { 1458 margin: 0 0 1.5em; 1459 min-height: 26px; 1460 } 1461 1462 .rtl .dashicons-star-half:before { 1463 -webkit-transform: rotateY(180deg); 1464 -ms-transform: rotateY(180deg); 1465 transform: rotateY(180deg); 1466 } 1467 1468 .widget.plugin-ratings a.dashicons { 1469 color: inherit; 1470 } 1471 1472 .widget.plugin-ratings .description { 1473 color: #aa9; 1474 display: inline-block; 1475 font-style: italic; 1476 margin: 0 5px; 1477 vertical-align: text-bottom; 1478 } 1479 .widget.plugin-ratings ul.ratings-list { 1480 list-style-type: none; 1481 padding: 0; 1482 margin: 0 !important; 1483 } 1484 .widget.plugin-ratings .counter-container, 1485 .widget.plugin-ratings .counter-container a { 1486 display: inline-block; 1487 width: 100%; 1488 } 1489 .widget.plugin-ratings .counter-label, 1490 .widget.plugin-ratings .counter-count { 1491 line-height: 1.75; 1492 } 1493 .widget.plugin-ratings .counter-label { 1494 float: left; 1495 margin-right: 5px; 1496 min-width: 55px; 1497 } 1498 .widget.plugin-ratings .counter-back, 1499 .widget.plugin-ratings .counter-bar { 1500 float: left; 1501 height: 17px; 1502 } 1503 .widget.plugin-ratings .counter-back { 1504 background-color: #ececec; 1505 width: 64%; 1506 width: -webkit-calc(100% - 88px); 1507 width: calc(100% - 88px); 1508 } 1509 .widget.plugin-ratings .counter-bar { 1510 background-color: #ffc733; 1511 } 1512 .widget.plugin-ratings .counter-count { 1513 float: left; 1514 margin-left: 5px; 1515 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-tags.php
r2986 r3009 1 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 3 use WordPressdotorg\Plugin_Directory\Template; 2 4 3 5 // Various Template tags … … 30 32 31 33 function wporg_plugins_download_link() { 32 $filename = sprintf( "%s.%s.zip", get_post()->post_name, wporg_plugins_the_version() ); 33 return esc_url( "https://downloads.wordpress.org/plugin/{$filename}" ); 34 } 35 36 function worg_plugins_template_active_installs( $full = true ) { 37 $count = WordPressdotorg\Plugin_Directory\Template::get_active_installs_count(); 38 39 if ( $count <= 10 ) { 40 $text = __( 'Less than 10', 'wporg-plugins' ); 41 } elseif ( $count >= 1000000 ) { 42 $text = __( '1+ million', 'wporg-plugins' ); 43 } else { 44 $text = number_format_i18n( $count ) . '+'; 45 } 46 return $full ? sprintf( __( '%s active installs', 'wporg-plugins' ), $text ) : $text; 34 return esc_url( sprintf( "https://downloads.wordpress.org/plugin/%s.%s.zip", get_post()->post_name, wporg_plugins_the_version() ) ); 47 35 } 48 36 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/view-intro.php
r2612 r3009 1 1 <?php 2 namespace WordPressdotorg\Plugin_Directory\Theme; 3 use WordPressdotorg\Plugin_Directory\Template; 2 4 3 5 if ( is_front_page() && ( ! get_query_var( 'browse' ) || 'featured' == get_query_var( 'browse' ) ) ) { … … 6 8 '<p class="intro">' . __( 'Plugins extend and expand the functionality of WordPress. %1$s plugins with %2$s total downloads are at your fingertips.', 'wporg-plugins' ) . '</p>', 7 9 '<strong>' . number_format_i18n( wp_count_posts( 'plugin' )->publish ) . '</strong>', 8 '<strong>' . number_format_i18n( WordPressdotorg\Plugin_Directory\Template::get_total_downloads() ) . '</strong>'10 '<strong>' . number_format_i18n( Template::get_total_downloads() ) . '</strong>' 9 11 ); 10 12 }
Note: See TracChangeset
for help on using the changeset viewer.