Ticket #3310: plugin-template-cleanup.patch
File plugin-template-cleanup.patch, 32.6 KB (added by , 7 years ago) |
---|
-
wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
diff --git wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php index 09f5ada0..684c5702 100644
1 1 <?php 2 2 3 namespace WordPressdotorg\Plugin_Directory; 3 4 4 5 // Explicitly require dependencies so this file can be sourced outside the Plugin Directory. … … require_once( __DIR__ . '/class-plugin-geopattern-svgtext.php' ); 12 13 * @package WordPressdotorg\Plugin_Directory 13 14 */ 14 15 class Template { 15 16 16 /** 17 17 * Prints markup information in the head of a page. 18 18 * … … class Template { 26 26 if ( is_front_page() ) : 27 27 echo PHP_EOL; 28 28 ?> 29 <script type="application/ld+json">29 <script type="application/ld+json"> 30 30 { 31 31 "@context": "http://schema.org", 32 32 "@type": "WebSite", … … class Template { 40 40 } 41 41 ] 42 42 } 43 </script> 43 44 </script> 44 45 <?php 45 46 endif; 46 47 … … class Template { 64 65 65 66 echo PHP_EOL; 66 67 ?> 67 <script type="application/ld+json">68 <script type="application/ld+json"> 68 69 [ 69 70 { 70 71 "@context": "http://schema.org", … … class Template { 123 124 } 124 125 } 125 126 ] 126 </script> 127 128 </script> 127 129 <?php 128 130 } 129 131 … … class Template { 156 158 * 157 159 * @param bool $full Optional. Whether to include "active installations" suffix. Default: true. 158 160 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 161 * 159 162 * @return string "1+ million" or "1+ million active installations" depending on $full. 160 163 */ 161 164 public static function active_installs( $full = true, $post = null ) { … … class Template { 179 182 * Returns the number of downloads for a plugin. 180 183 * 181 184 * @static 182 * @global \wpdb $wpdb WordPress database abstraction object.185 * @global \wpdb $wpdb WordPress database abstraction object. 183 186 * 184 187 * @param int|\WP_Post|null $post Optional. 188 * 185 189 * @return int 186 190 */ 187 191 public static function get_downloads_count( $post = null ) { … … class Template { 224 228 * @static 225 229 * 226 230 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 231 * 227 232 * @return string 228 233 */ 229 234 public static function get_star_rating( $post = null ) { … … class Template { 235 240 236 241 return 237 242 '<div class="plugin-rating">' . 238 239 240 241 242 243 244 245 246 247 243 Template::dashicons_stars( $rating ) . 244 '<span class="rating-count">(' . 245 '<a href="https://wordpress.org/support/plugin/' . $post->post_name . '/reviews/">' . 246 sprintf( 247 /* translators: 1: number of ratings */ 248 __( '%1$s<span class="screen-reader-text"> total ratings</span>', 'wporg-plugins' ), 249 number_format_i18n( $num_ratings ) 250 ) . 251 '</a>' . 252 ')</span>' . 248 253 '</div>'; 249 254 } 250 255 … … class Template { 254 259 * @static 255 260 * 256 261 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 262 * 257 263 * @return array 258 264 */ 259 265 public static function get_plugin_sections( $post = null ) { … … class Template { 352 358 * 353 359 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 354 360 * @param string $output Optional. Output type. 'html' or 'raw'. Default: 'raw'. 361 * 355 362 * @return mixed 356 363 */ 357 364 public static function get_plugin_icon( $post = null, $output = 'raw' ) { … … class Template { 404 411 405 412 switch ( $output ) { 406 413 case 'html': 407 $id 408 $html 414 $id = "plugin-icon-{$plugin->post_name}"; 415 $html = "<style type='text/css'>"; 409 416 $html .= "#{$id} { background-image: url('{$icon}'); } .plugin-icon { background-size: cover; height: 128px; width: 128px; }"; 410 417 if ( ! empty( $icon_2x ) && ! $generated ) { 411 418 $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$icon_2x}'); } }"; … … class Template { 429 436 * 430 437 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 431 438 * @param string $output Optional. Output type. 'html' or 'raw'. Default: 'raw'. 439 * 432 440 * @return mixed 433 441 */ 434 442 public static function get_plugin_banner( $post = null, $output = 'raw' ) { … … class Template { 476 484 477 485 switch ( $output ) { 478 486 case 'html': 479 $id 480 $html 487 $id = "plugin-banner-{$plugin->post_name}"; 488 $html = "<style type='text/css'>"; 481 489 $html .= "#{$id} { background-image: url('{$banner}'); }"; 482 490 if ( ! empty( $banner_2x ) ) { 483 491 $html .= "@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) { #{$id} { background-image: url('{$banner_2x}'); } }"; … … class Template { 504 512 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 505 513 * @param array $asset Assets folder information. 506 514 * @param bool $cdn Optional. If the url should be CDN'ised. Default true. 515 * 507 516 * @return string 508 517 */ 509 518 public static function get_asset_url( $post, $asset, $cdn = true ) { … … class Template { 538 547 * 539 548 * @static 540 549 * 541 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 550 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 551 * 542 552 * @return string 543 553 */ 544 554 public static function get_support_url( $post = null ) { … … class Template { 564 574 * 565 575 * @static 566 576 * 567 * @param int|array $args {568 * If numeric arg passed, assumed to be 'rating'.577 * @param int|array $args { 578 * If numeric arg passed, assumed to be 'rating'. 569 579 * 570 * @type int$rating The rating to display.571 * @type string$template The HTML template to use for each star.580 * @type int $rating The rating to display. 581 * @type string $template The HTML template to use for each star. 572 582 * %1$s is the class, %2$s is the rating. 573 583 * } 574 584 * @return string The Rating HTML. … … class Template { 586 596 587 597 $output = '<div class="wporg-ratings" aria-label="' . esc_attr( $title ) . '" data-title-template="' . esc_attr( $title_template ) . '" data-rating="' . esc_attr( $rating ) . '" style="color:#ffb900;">'; 588 598 $counter = round( $rating * 2 ); 589 for ( $i = 1; $i <= 5; $i ++ ) {599 for ( $i = 1; $i <= 5; $i ++ ) { 590 600 switch ( $counter ) { 591 601 case 0: 592 602 $output .= sprintf( $template, 'dashicons dashicons-star-empty', $i ); … … class Template { 594 604 595 605 case 1: 596 606 $output .= sprintf( $template, 'dashicons dashicons-star-half', $i ); 597 $counter --;607 $counter --; 598 608 break; 599 609 600 610 default: … … class Template { 613 623 * 614 624 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 615 625 * @param string $version The version to link to. Optional. Default: latest. 626 * 616 627 * @return string The Download URL. 617 628 */ 618 629 public static function download_link( $post = null, $version = 'latest' ) { … … class Template { 635 646 * @static 636 647 * 637 648 * @param string $string 649 * 638 650 * @return string 639 651 */ 640 652 public static function encode( $string ) { … … class Template { 648 660 * 649 661 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 650 662 * @param mixed $user The user to alter the favorite status for. 663 * 651 664 * @return string URL to toggle status. 652 665 */ 653 666 public static function get_favorite_link( $post = null, $user = 0 ) { … … class Template { 656 669 $favorited = Tools::favorited_plugin( $post, $user ); 657 670 658 671 return add_query_arg( array( 659 '_wpnonce' => wp_create_nonce( 'wp_rest' ),660 ( $favorited ? 'unfavorite' : 'favorite' ) => '1' 672 '_wpnonce' => wp_create_nonce( 'wp_rest' ), 673 ( $favorited ? 'unfavorite' : 'favorite' ) => '1', 661 674 ), home_url( 'wp-json/plugins/v1/plugin/' . $post->post_name . '/favorite' ) ); 662 675 } 663 676 664 677 /** 678 * Checks whether a plugin is closed or not. 679 * 680 * @return bool 681 */ 682 public static function plugin_is_closed() { 683 $status = get_post_status(); 684 if ( in_array( $status, array( 'closed', 'disabled' ) ) ) { 685 return true; 686 } 687 688 return false; 689 } 690 691 /** 692 * Returns text to show to plugin authors on closed pages 693 */ 694 public static function plugin_closed_author_info() { 695 return sprintf( 696 /* translators: 1: plugins@wordpress.org */ 697 __( 'If you did not request this change, please contact <a href="mailto:%1$s">%1$s</a> for a status. All developers with commit access are contacted when a plugin is closed, with the reasons why, so check your spam email too.', 'wporg-plugins' ), 698 'plugins@wordpress.org' 699 ); 700 } 701 702 /** 703 * Returns a string about why the plugin isn't active. 704 * 705 * @return array { 706 * @type string $message The reason the plugin isn't active 707 * @type string $notice_type The notice type. 708 * } 709 */ 710 public static function plugin_not_active_reason() { 711 $status = get_post_status(); 712 $notice_type = 'notice-error'; 713 switch ( $status ) { 714 case 'draft': 715 case 'pending': 716 $message = __( 'This plugin is requested and not visible to the public yet. Please be patient as your plugin gets reviewed.', 'wporg-plugins' ); 717 $notice_type = 'notice-info'; 718 break; 719 720 case 'approved': 721 $message = __( 'This plugin is approved and awaiting data upload but not visible to the public yet. Once you make your first commit, the plugin will become public.', 'wporg-plugins' ); 722 $notice_type = 'notice-info'; 723 break; 724 725 case 'rejected': 726 $message = __( 'This plugin has been rejected and is not visible to the public.', 'wporg-plugins' ); 727 break; 728 729 case 'disabled': 730 if ( current_user_can( 'plugin_approve' ) ) { 731 $message = __( 'This plugin is disabled (closed, but actively serving updates).', 'wporg-plugins' ); 732 break; 733 } else { 734 $message = __( 'This plugin has been closed for new installs.', 'wporg-plugins' ); 735 break; 736 } 737 // fall through 738 default: 739 case 'closed': 740 $message = __( 'This plugin has been closed and is no longer available for download.', 'wporg-plugins' ); 741 break; 742 } 743 744 return compact( $message, $notice_type ); 745 } 746 747 /** 665 748 * Returns the reasons for closing or disabling a plugin. 666 749 * 667 750 * @return array Close/disable reason labels. … … class Template { 681 764 * Returns the close/disable reason for a plugin. 682 765 * 683 766 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. 767 * 684 768 * @return string Close/disable reason. 685 769 */ 686 770 public static function get_close_reason( $post = null ) { … … class Template { 688 772 689 773 $close_reasons = self::get_close_reasons(); 690 774 $close_reason = (string) get_post_meta( $post->ID, '_close_reason', true ); 691 775 692 776 if ( isset( $close_reasons[ $close_reason ] ) ) { 693 777 $reason_label = $close_reasons[ $close_reason ]; 694 778 } else { … … class Template { 753 837 $sites['en_US'] = (object) array( 754 838 'locale' => 'en_US', 755 839 'hreflang' => 'en', 756 'subdomain' => '' 840 'subdomain' => '', 757 841 ); 758 842 759 uasort( $sites, function ( $a, $b ) {843 uasort( $sites, function ( $a, $b ) { 760 844 return strcasecmp( $a->hreflang, $b->hreflang ); 761 845 } ); 762 846 763 wp_cache_set( 'local-sites-' .get_post()->post_name, $sites, 'locale-associations', DAY_IN_SECONDS );847 wp_cache_set( 'local-sites-' . get_post()->post_name, $sites, 'locale-associations', DAY_IN_SECONDS ); 764 848 } 765 849 766 850 foreach ( $sites as $site ) { 767 851 $url = sprintf( 768 852 'https://%swordpress.org%s', 769 853 $site->subdomain ? "{$site->subdomain}." : '', 770 $_SERVER[ 'REQUEST_URI']854 $_SERVER['REQUEST_URI'] 771 855 ); 772 856 773 857 printf( -
wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php index 7646230e..9d21434e 100644
2 2 /** 3 3 * Template part for displaying posts. 4 4 * 5 * @link https://codex.wordpress.org/Template_Hierarchy5 * @link https://codex.wordpress.org/Template_Hierarchy 6 6 * 7 7 * @package WordPressdotorg\Plugin_Directory\Theme 8 8 */ 9 9 10 10 namespace WordPressdotorg\Plugin_Directory\Theme; 11 11 12 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 12 13 use WordPressdotorg\Plugin_Directory\Template; 13 14 use WordPressdotorg\Plugin_Directory\Tools; 15 14 16 global $section, $section_slug, $section_content, $section_read_more; 15 17 16 18 $content = Plugin_Directory::instance()->split_post_content_into_pages( get_the_content() ); 17 $status = get_post_status();18 19 ?><article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>20 <?php21 // Don't show the plugin banner for closed plugins22 if ( ! in_array( $status, array( 'closed', 'disabled' ) ) ) {23 echo Template::get_plugin_banner( get_post(), 'html' );24 }25 ?>26 27 <header class="plugin-header">28 <?php if ( time() - get_post_modified_time() > 2 * YEAR_IN_SECONDS ) : ?>29 <div class="plugin-notice notice notice-warning notice-alt">30 <p><?php _e( 'This plugin <strong>hasn’t been updated in over 2 years</strong>. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.', 'wporg-plugins' ); ?></p>31 </div>32 <?php endif; ?>33 <?php if ( 'publish' !== $status ) :34 $notice_type = 'notice-error';35 switch ( $status ) {36 case 'draft':37 case 'pending':38 $message = __( 'This plugin is requested and not visible to the public yet. Please be patient as your plugin gets reviewed.', 'wporg-plugins' );39 $notice_type = 'notice-info';40 break;41 42 case 'approved':43 $message = __( 'This plugin is approved and awaiting data upload but not visible to the public yet. Once you make your first commit, the plugin will become public.', 'wporg-plugins' );44 $notice_type = 'notice-info';45 break;46 47 case 'rejected':48 $message = __( 'This plugin has been rejected and is not visible to the public.', 'wporg-plugins' );49 break;50 51 case 'disabled':52 if ( current_user_can( 'plugin_approve' ) ) {53 $message = __( 'This plugin is disabled (closed, but actively serving updates).', 'wporg-plugins' );54 break;55 } else {56 $message = __( 'This plugin has been closed for new installs.', 'wporg-plugins' );57 break;58 }59 // fall through60 default:61 case 'closed':62 $message = __( 'This plugin has been closed and is no longer available for download.', 'wporg-plugins' );63 break;64 }65 19 66 if ( in_array( $status, array( 'closed', 'disabled' ) ) ) { 67 $closed_date = get_post_meta( get_the_ID(), 'plugin_closed_date', true ); 68 if ( ! empty( $closed_date ) ) { 69 $message .= '<br/>'; 70 $message .= sprintf( __( 'This plugin was closed on %s.', 'wporg-plugins' ), mysql2date( get_option( 'date_format' ), $closed_date ) ); 20 ?> 21 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 22 <?php 23 // Don't show the plugin banner for closed plugins 24 if ( ! Template::plugin_is_closed() ) { 25 echo Template::get_plugin_banner( get_post(), 'html' ); 26 } 27 ?> 28 29 <header class="plugin-header"> 30 <?php 31 32 $status = get_post_status(); 33 if ( 'publish' !== $status ) : 34 $message = Template::plugin_not_active_reason(); 35 if ( Template::plugin_is_closed() ) { 36 $closed_date = get_post_meta( get_the_ID(), 'plugin_closed_date', true ); 37 if ( ! empty( $closed_date ) ) { 38 $message['message'] .= '<br/>'; 39 $message['message'] .= sprintf( __( 'This plugin was closed on %s.', 'wporg-plugins' ), mysql2date( get_option( 'date_format' ), $closed_date ) ); 71 40 } 72 } 73 74 if ( ! in_array( $status, array( 'closed', 'disabled' ) ) ) { 75 // the notice for closed and disabled is shown below the Description header, because we don't output the readme there 76 ?> 77 <!-- .plugin-notice --> 78 <div class="plugin-notice notice <?php echo esc_attr( $notice_type ); ?> notice-alt"> 79 <p><?php echo $message; ?></p> 80 </div> 81 <!-- .plugin-notice --> 82 <?php } ?> 83 <?php endif; ?> 84 85 <div class="entry-thumbnail"> 86 <?php 87 // Don't show the icon for closed plugins 88 if ( ! in_array( $status, array( 'closed', 'disabled' ) ) ) { 89 echo Template::get_plugin_icon( get_post(), 'html' ); 90 } 91 ?> 92 </div> 93 94 <div class="plugin-actions"> 41 } else { 42 // the notice for closed and disabled is shown below the Description header, because we don't output the readme there 43 ?> 44 <!-- .plugin-notice --> 45 <div class="plugin-notice notice <?php echo esc_attr( $message['notice_type'] ); ?> notice-alt"> 46 <p><?php echo $message['message']; ?></p> 47 </div> 48 <!-- .plugin-notice --> 49 <?php 50 } 51 52 endif; 53 54 // Don't show the icon (and its wrapping div) for closed plugins 55 if ( ! Template::plugin_is_closed() ) { 56 printf( '<div class="entry-thumbnail">%s</div>', Template::get_plugin_icon( get_post(), 'html' ) ); 57 } 58 ?> 59 60 <div class="plugin-actions"> 95 61 <?php 96 62 if ( is_user_logged_in() ) : 97 63 $url = Template::get_favorite_link(); 98 $is_favorited = Tools::favorited_plugin( $post);64 $is_favorited = Tools::favorited_plugin( get_post() ); 99 65 ?> 100 <div class="plugin-favorite"> 101 <a href="<?php echo esc_url( $url ); ?>" class="plugin-favorite-heart<?php echo $is_favorited ? ' favorited' : ''; ?>"> 66 <div class="plugin-favorite"> 67 <a href="<?php echo esc_url( $url ); ?>" 68 class="plugin-favorite-heart<?php echo $is_favorited ? ' favorited' : ''; ?>"> 102 69 <span class="screen-reader-text"> 103 70 <?php 104 105 106 107 108 109 110 71 if ( $is_favorited ) { 72 /* translators: %s: plugin name */ 73 printf( __( 'Unfavorite %s', 'wporg-plugins' ), get_the_title() ); 74 } else { 75 /* translators: %s: plugin name */ 76 printf( __( 'Favorite %s', 'wporg-plugins' ), get_the_title() ); 77 } 111 78 ?> 112 79 </span> 113 114 115 jQuery( '.plugin-favorite-heart')116 .on( 'click touchstart animationend', function() {117 jQuery( this ).toggleClass( 'is-animating');80 </a> 81 <script> 82 jQuery( ".plugin-favorite-heart" ) 83 .on( "click touchstart animationend", function() { 84 jQuery( this ).toggleClass( "is-animating" ); 118 85 } ) 119 .on( 'click', function() {120 jQuery( this ).toggleClass( 'favorited');86 .on( "click", function() { 87 jQuery( this ).toggleClass( "favorited" ); 121 88 } ); 122 123 89 </script> 90 </div> 124 91 <?php endif; ?> 125 92 126 93 <?php if ( 'publish' === get_post_status() || current_user_can( 'plugin_admin_view', get_post() ) ) : ?> 127 <a class="plugin-download button download-button button-large" href="<?php echo esc_url( Template::download_link() ); ?>"><?php _e( 'Download', 'wporg-plugins' ); ?></a> 94 <a class="plugin-download button download-button button-large" 95 href="<?php echo esc_url( Template::download_link() ); ?>"><?php _e( 'Download', 'wporg-plugins' ); ?></a> 128 96 <?php endif; ?> 129 130 97 </div> 98 131 99 <?php 132 if ( in_array( $status, array( 'closed', 'disabled' )) ) {133 add_filter( 'the_title', function ( $title, $id ) {100 if ( Template::plugin_is_closed() ) { 101 add_filter( 'the_title', function ( $title, $id ) { 134 102 $post = get_post( $id ); 103 135 104 return $post->post_name; 136 105 }, 10, 2 ); 137 106 } 138 107 the_title( '<h1 class="plugin-title"><a href="' . esc_url( get_permalink() ) . '">', '</a></h1>' ); ?> 139 108 140 141 $url = get_post_meta( get_the_ID(), 'header_author_uri', true );109 <span class="byline"><?php 110 $url = get_post_meta( get_the_ID(), 'header_author_uri', true ); 142 111 $author = strip_tags( get_post_meta( get_the_ID(), 'header_author', true ) ) ?: get_the_author(); 143 112 144 113 printf( … … $status = get_post_status(); 149 118 ( $url ? '</a>' : '' ) . 150 119 '</span>' 151 120 ); 152 ?></span> 153 </header><!-- .entry-header --> 154 155 <?php if ( ! get_query_var( 'plugin_advanced' ) ) { ?> 156 <span id="description"></span> 157 <span id="reviews"></span> 158 <span id="installation"></span> 159 <span id="developers"></span> 160 <ul class="tabs clear"> 161 <li id="tablink-description"><a href='#description'><?php _e( 'Details', 'wporg-plugins' ); ?></a></li> 162 <li id="tablink-reviews"><a href='#reviews'><?php _e( 'Reviews', 'wporg-plugins' ); ?></a></li> 163 <?php if ( isset( $content[ 'installation' ] ) && ! in_array( $status, array( 'closed', 'disabled' ) ) ) { ?> 164 <li id="tablink-installation"><a href='#installation'><?php _e( 'Installation', 'wporg-plugins' ); ?></a></li> 165 <?php } ?> 166 <li id="tablink-support"><a href='<?php echo Template::get_support_url(); ?>'><?php _e( 'Support', 'wporg-plugins' ); ?></a></li> 167 <li id="tablink-developers"><a href='#developers'><?php _e( 'Development', 'wporg-plugins' ); ?></a></li> 168 </ul> 169 <?php } ?> 170 <div class="entry-content"> 121 ?></span> 122 </header><!-- .entry-header --> 123 124 <?php if ( ! get_query_var( 'plugin_advanced' ) ) { ?> 125 <span id="description"></span> 126 <span id="reviews"></span> 127 <span id="installation"></span> 128 <span id="developers"></span> 129 <ul class="tabs clear"> 130 <li id="tablink-description"><a href='#description'><?php _e( 'Details', 'wporg-plugins' ); ?></a></li> 131 <li id="tablink-reviews"><a href='#reviews'><?php _e( 'Reviews', 'wporg-plugins' ); ?></a></li> 132 <?php if ( isset( $content['installation'] ) && ! Template::plugin_is_closed() ) { ?> 133 <li id="tablink-installation"><a 134 href='#installation'><?php _e( 'Installation', 'wporg-plugins' ); ?></a></li> 135 <?php } ?> 136 <li id="tablink-support"><a 137 href='<?php echo Template::get_support_url(); ?>'><?php _e( 'Support', 'wporg-plugins' ); ?></a> 138 </li> 139 <li id="tablink-developers"><a href='#developers'><?php _e( 'Development', 'wporg-plugins' ); ?></a></li> 140 </ul> 141 <?php } ?> 142 <div class="entry-content"> 171 143 <?php 172 144 if ( get_query_var( 'plugin_advanced' ) ) : 173 145 get_template_part( 'template-parts/section-advanced' ); 174 146 else: 175 147 $plugin_sections = Template::get_plugin_sections(); 176 148 177 foreach ( array( 'description', 'screenshots', 'installation', 'faq', 'reviews', 'developers', 'changelog' ) as $section_slug ) : 149 foreach ( 150 array( 151 'description', 152 'screenshots', 153 'installation', 154 'faq', 155 'reviews', 156 'developers', 157 'changelog', 158 ) as $section_slug 159 ) : 178 160 if ( ! isset( $content[ $section_slug ] ) ) { 179 161 continue; 180 162 } 181 163 182 if ( 'description' === $section_slug && in_array( $status, array( 'closed', 'disabled' )) ) {183 184 $section_content = '<div class="plugin-notice notice notice-error notice-alt"><p>' . $message. '</p></div>';185 186 $section_content .= '<div class="plugin-notice notice notice-info notice-alt"><p>' .187 sprintf(188 /* translators: 1: plugins@wordpress.org */189 __( 'If you did not request this change, please contact <a href="mailto:%1$s">%1$s</a> for a status. All developers with commit access are contacted when a plugin is closed, with the reasons why, so check your spam email too.', 'wporg-plugins' ),190 'plugins@wordpress.org'191 ) . '</p></div><!-- .plugin-notice -->';192 }193 }194 else if ( in_array( $section_slug, array( 'screenshots', 'installation', 'faq', 'changelog' ) ) && in_array( $status, array( 'closed', 'disabled' ) ) ) {195 $section_content = '';196 }197 else {164 if ( 'description' === $section_slug && Template::plugin_is_closed() ) { 165 // Don't show the description for closed plugins 166 $section_content = '<div class="plugin-notice notice ' . $message['notice_type'] . ' notice-alt"><p>' . $message['message'] . '</p></div>'; 167 if ( get_current_user_id() == get_post()->post_author ) { 168 $section_content .= '<div class="plugin-notice notice notice-info notice-alt"><p>' 169 . Template::plugin_closed_author_info() 170 . '</p></div><!-- .plugin-notice -->'; 171 } 172 } else if ( in_array( $section_slug, array( 173 'screenshots', 174 'installation', 175 'faq', 176 'changelog', 177 ) ) && Template::plugin_is_closed() ) { 178 $section_content = ''; 179 } else { 198 180 $section_content = trim( apply_filters( 'the_content', $content[ $section_slug ], $section_slug ) ); 199 181 } 200 182 … … $status = get_post_status(); 217 199 endforeach; 218 200 endif; // plugin_advanced 219 201 ?> 220 202 </div><!-- .entry-content --> 221 203 222 204 <div class="entry-meta"> 223 205 <?php 224 206 get_template_part( 'template-parts/plugin-sidebar', ( get_query_var( 'plugin_advanced' ) ? 'advanced' : '' ) ); 225 207 ?> 226 208 </div><!-- .entry-meta --> 227 209 </article><!-- #post-## --> -
wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-advanced.php
diff --git wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-advanced.php wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/section-advanced.php index 55b0c6e4..50067c5f 100644
2 2 /** 3 3 * Template part for displaying the plugin administration sections. 4 4 * 5 * @link https://codex.wordpress.org/Template_Hierarchy5 * @link https://codex.wordpress.org/Template_Hierarchy 6 6 * 7 7 * @package WordPressdotorg\Plugin_Directory\Theme 8 8 */ 9 9 10 10 namespace WordPressdotorg\Plugin_Directory\Theme; 11 11 12 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 12 13 use WordPressdotorg\Plugin_Directory\Template; 14 13 15 ?> 14 16 15 17 <div id="admin" class="section"> 16 <?php17 $status = get_post_status();18 if ( in_array( $status, array( 'closed', 'disabled' ) ) ) {19 echo '<div class="plugin-notice notice notice-error notice-alt"><p>' . __( 'This plugin has been closed and is no longer available for download.', 'wporg-plugins' ) . '</p></div>';20 if ( get_current_user_id() == get_post()->post_author ) {21 echo '<div class="plugin-notice notice notice-info notice-alt"><p>' .22 sprintf(23 /* translators: 1: plugins@wordpress.org */24 __( 'If you did not request this change, please contact <a href="mailto:%1$s">%1$s</a> for a status. All developers with commit access are contacted when a plugin is closed, with the reasons why, so check your spam email too.', 'wporg-plugins' ),25 'plugins@wordpress.org'26 ) . '</p></div><!-- .plugin-notice -->';27 }28 }29 30 ?>31 <h2><?php _e( 'Plugin Stats', 'wporg-plugins' ); ?></h2>32 33 <h4><?php _e( 'Active versions', 'wporg-plugins' ); ?></h4>34 <div id="plugin-version-stats" class="chart version-stats"></div>35 36 <h4><?php _e( 'Downloads Per Day', 'wporg-plugins' ); ?></h4>37 <div id="plugin-download-stats" class="chart download-stats"></div>38 39 <h5><?php _e( 'Downloads history', 'wporg-plugins' ); ?></h5>40 <table id="plugin-download-history-stats" class="download-history-stats">41 <tbody></tbody>42 </table>43 44 18 <?php 19 if ( Template::plugin_is_closed() ) { 20 $message = Template::plugin_not_active_reason(); 21 echo '<div class="plugin-notice notice ' . $message['notice_type'] . ' notice-alt"><p>' . $message['message'] . '</p></div>'; 22 if ( get_current_user_id() == get_post()->post_author ) { 23 echo '<div class="plugin-notice notice notice-info notice-alt"><p>' 24 . Template::plugin_closed_author_info() 25 . '</p></div><!-- .plugin-notice -->'; 26 } 27 } 45 28 46 $tags = (array) get_post_meta( $post->ID, 'tagged_versions', true ); 47 // Sort the versions by version 48 usort( $tags, 'version_compare' ); 49 // We'll want to add a Development Version if it exists 50 $tags[] = 'trunk'; 29 ?> 30 <h2><?php _e( 'Plugin Stats', 'wporg-plugins' ); ?></h2> 51 31 52 // Remove the current version, this may be trunk. 53 $tags = array_diff( $tags, array( get_post_meta( $post->ID, 'stable_tag', true ) ) ); 32 <h4><?php _e( 'Active versions', 'wporg-plugins' ); ?></h4> 33 <div id="plugin-version-stats" class="chart version-stats"></div> 54 34 55 // List Trunk, followed by the most recent non-stable release. 56 $tags = array_reverse( $tags ); 35 <h4><?php _e( 'Downloads Per Day', 'wporg-plugins' ); ?></h4> 36 <div id="plugin-download-stats" class="chart download-stats"></div> 57 37 58 if ( $tags && 'publish' === get_post_status() ) { 59 echo '<h5>' . __( 'Previous Versions', 'wporg-plugins' ) . '</h5>'; 38 <h5><?php _e( 'Downloads history', 'wporg-plugins' ); ?></h5> 39 <table id="plugin-download-history-stats" class="download-history-stats"> 40 <tbody></tbody> 41 </table> 60 42 61 echo '<div class="plugin-notice notice notice-info notice-alt"><p>' . __( 'Previous versions of this plugin may not be secure or stable and are available for testing purposes only.', 'wporg-plugins' ) . '</p></div>';43 <?php 62 44 63 echo '<select class="previous-versions" onchange="getElementById(\'download-previous-link\').href=this.value;">'; 64 foreach ( $tags as $version ) { 65 $text = ( 'trunk' == $version ? __( 'Development Version', 'wporg-plugins' ) : $version ); 66 printf( '<option value="%s">%s</option>', esc_attr( Template::download_link( $post, $version ) ), esc_html( $text ) ); 67 } 68 echo '</select> '; 45 $tags = (array) get_post_meta( get_the_ID(), 'tagged_versions', true ); 46 // Sort the versions by version 47 usort( $tags, 'version_compare' ); 48 // We'll want to add a Development Version if it exists 49 $tags[] = 'trunk'; 69 50 70 printf( 71 '<a href="%s" id="download-previous-link" class="button">%s</a>', 72 esc_url( Template::download_link( $post, reset( $tags ) ) ), 73 __( 'Download', 'wporg-plugins' ) 74 ); 51 // Remove the current version, this may be trunk. 52 $tags = array_diff( $tags, array( get_post_meta( get_the_ID(), 'stable_tag', true ) ) ); 53 54 // List Trunk, followed by the most recent non-stable release. 55 $tags = array_reverse( $tags ); 56 57 if ( $tags && 'publish' === get_post_status() ) { 58 echo '<h5>' . __( 'Previous Versions', 'wporg-plugins' ) . '</h5>'; 59 60 echo '<div class="plugin-notice notice notice-info notice-alt"><p>' . __( 'Previous versions of this plugin may not be secure or stable and are available for testing purposes only.', 'wporg-plugins' ) . '</p></div>'; 61 62 echo '<select class="previous-versions" onchange="getElementById(\'download-previous-link\').href=this.value;">'; 63 foreach ( $tags as $version ) { 64 $text = ( 'trunk' == $version ? __( 'Development Version', 'wporg-plugins' ) : $version ); 65 printf( '<option value="%s">%s</option>', esc_attr( Template::download_link( get_post(), $version ) ), esc_html( $text ) ); 75 66 } 67 echo '</select> '; 68 69 printf( 70 '<a href="%s" id="download-previous-link" class="button">%s</a>', 71 esc_url( Template::download_link( get_post(), reset( $tags ) ) ), 72 __( 'Download', 'wporg-plugins' ) 73 ); 74 } 76 75 77 76 ?> 78 77 </div>