Ticket #3310: plugin-template-cleanup-2.patch
File plugin-template-cleanup-2.patch, 14.8 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 227e4645..2aa8b6ec 100644
class Template { 679 679 } 680 680 681 681 /** 682 * Checks whether a plugin is closed or not. 683 * 684 * @return bool 685 */ 686 public static function plugin_is_closed() { 687 $status = get_post_status(); 688 if ( in_array( $status, array( 'closed', 'disabled' ) ) ) { 689 return true; 690 } 691 692 return false; 693 } 694 695 /** 696 * Returns text to show to plugin authors on closed pages 697 */ 698 public static function plugin_closed_author_info() { 699 return sprintf( 700 /* translators: 1: plugins@wordpress.org */ 701 __( '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' ), 702 'plugins@wordpress.org' 703 ); 704 } 705 706 /** 707 * Returns a string about why the plugin isn't active. 708 * 709 * @return array { 710 * @type string $message The reason the plugin isn't active 711 * @type string $notice_type The notice type. 712 * } 713 */ 714 public static function plugin_not_active_reason() { 715 $status = get_post_status(); 716 $notice_type = 'notice-error'; 717 switch ( $status ) { 718 case 'draft': 719 case 'pending': 720 $message = __( 'This plugin is requested and not visible to the public yet. Please be patient as your plugin gets reviewed.', 'wporg-plugins' ); 721 $notice_type = 'notice-info'; 722 break; 723 724 case 'approved': 725 $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' ); 726 $notice_type = 'notice-info'; 727 break; 728 729 case 'rejected': 730 $message = __( 'This plugin has been rejected and is not visible to the public.', 'wporg-plugins' ); 731 break; 732 733 case 'disabled': 734 if ( current_user_can( 'plugin_approve' ) ) { 735 $message = __( 'This plugin is disabled (closed, but actively serving updates).', 'wporg-plugins' ); 736 break; 737 } else { 738 $message = __( 'This plugin has been closed for new installs.', 'wporg-plugins' ); 739 break; 740 } 741 // fall through 742 default: 743 case 'closed': 744 $message = __( 'This plugin has been closed and is no longer available for download.', 'wporg-plugins' ); 745 break; 746 } 747 748 return compact( $message, $notice_type ); 749 } 750 751 /** 682 752 * Returns the close/disable reason for a plugin. 683 753 * 684 754 * @param int|\WP_Post|null $post Optional. Post ID or post object. Defaults to global $post. -
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 708ba636..bb57cb62 100644
use WordPressdotorg\Plugin_Directory\Tools; 14 14 global $section, $section_slug, $section_content, $section_read_more; 15 15 16 16 $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 <?php 21 // Don't show the plugin banner for closed plugins 22 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 through 60 default: 61 case 'closed': 62 $message = __( 'This plugin has been closed and is no longer available for download.', 'wporg-plugins' ); 63 break; 64 } 17 ?> 18 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 19 <?php 20 // Don't show the plugin banner for closed plugins 21 if ( ! Template::plugin_is_closed() ) { 22 echo Template::get_plugin_banner( get_post(), 'html' ); 23 } 24 ?> 25 26 <header class="plugin-header"> 27 <?php 65 28 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 ) ); 29 $status = get_post_status(); 30 if ( 'publish' !== $status ) : 31 $message = Template::plugin_not_active_reason(); 32 if ( Template::plugin_is_closed() ) { 33 $closed_date = get_post_meta( get_the_ID(), 'plugin_closed_date', true ); 34 if ( ! empty( $closed_date ) ) { 35 $message['message'] .= '<br/>'; 36 $message['message'] .= sprintf( __( 'This plugin was closed on %s.', 'wporg-plugins' ), mysql2date( get_option( 'date_format' ), $closed_date ) ); 71 37 } 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 echo Template::get_plugin_icon( get_post(), 'html' ); ?> 87 </div> 38 } else { 39 // the notice for closed and disabled is shown below the Description header, because we don't output the readme there 40 ?> 41 <!-- .plugin-notice --> 42 <div class="plugin-notice notice <?php echo esc_attr( $message['notice_type'] ); ?> notice-alt"> 43 <p><?php echo $message['message']; ?></p> 44 </div> 45 <!-- .plugin-notice --> 46 <?php 47 } 48 49 endif; 50 51 // Don't show the icon (and its wrapping div) for closed plugins 52 if ( ! Template::plugin_is_closed() ) { 53 printf( '<div class="entry-thumbnail">%s</div>', Template::get_plugin_icon( get_post(), 'html' ) ); 54 } 55 ?> 88 56 89 57 <div class="plugin-actions"> 90 58 <?php 91 59 if ( is_user_logged_in() ) : 92 60 $url = Template::get_favorite_link(); 93 $is_favorited = Tools::favorited_plugin( $post);61 $is_favorited = Tools::favorited_plugin( get_post() ); 94 62 ?> 95 63 <div class="plugin-favorite"> 96 64 <a href="<?php echo esc_url( $url ); ?>" class="plugin-favorite-heart<?php echo $is_favorited ? ' favorited' : ''; ?>"> … … $status = get_post_status(); 124 92 </div> 125 93 126 94 <?php 127 if ( in_array( $status, array( 'closed', 'disabled' )) ) {128 $plugin_title = $post->post_name;95 if ( Template::plugin_is_closed() ) { 96 $plugin_title = get_post()->post_name; 129 97 } else { 130 98 $plugin_title = get_the_title(); 131 99 } … … $status = get_post_status(); 155 123 <ul class="tabs clear"> 156 124 <li id="tablink-description"><a href='#description'><?php _e( 'Details', 'wporg-plugins' ); ?></a></li> 157 125 <li id="tablink-reviews"><a href='#reviews'><?php _e( 'Reviews', 'wporg-plugins' ); ?></a></li> 158 <?php if ( isset( $content[ 'installation' ] ) && ! in_array( $status, array( 'closed', 'disabled' )) ) { ?>126 <?php if ( isset( $content[ 'installation' ] ) && ! Template::plugin_is_closed() ) { ?> 159 127 <li id="tablink-installation"><a href='#installation'><?php _e( 'Installation', 'wporg-plugins' ); ?></a></li> 160 128 <?php } ?> 161 129 <li id="tablink-support"><a href='<?php echo Template::get_support_url(); ?>'><?php _e( 'Support', 'wporg-plugins' ); ?></a></li> … … $status = get_post_status(); 174 142 continue; 175 143 } 176 144 177 if ( 'description' === $section_slug && in_array( $status, array( 'closed', 'disabled' ) ) ) { 178 // Don't show the description for closed plugins 179 $section_content = '<div class="plugin-notice notice notice-error notice-alt"><p>' . $message . '</p></div>'; 180 if ( get_current_user_id() == get_post()->post_author ) { 181 $section_content .= '<div class="plugin-notice notice notice-info notice-alt"><p>' . 182 sprintf( 183 /* translators: 1: plugins@wordpress.org */ 184 __( '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' ), 185 'plugins@wordpress.org' 186 ) . '</p></div><!-- .plugin-notice -->'; 187 } 145 if ( 'description' === $section_slug && Template::plugin_is_closed() ) { 146 $section_content = '<div class="plugin-notice notice ' . $message['notice_type'] . ' notice-alt"><p>' . $message['message'] . '</p></div>'; 147 if ( get_current_user_id() == get_post()->post_author ) { 148 $section_content .= '<div class="plugin-notice notice notice-info notice-alt"><p>' 149 . Template::plugin_closed_author_info() 150 . '</p></div><!-- .plugin-notice -->'; 151 } 188 152 } 189 else if ( in_array( $section_slug, array( 'screenshots', 'installation', 'faq', 'changelog' ) ) && in_array( $status, array( 'closed', 'disabled' )) ) {153 else if ( in_array( $section_slug, array( 'screenshots', 'installation', 'faq', 'changelog' ) ) && Template::plugin_is_closed() ) { 190 154 $section_content = ''; 191 155 } 192 156 else { -
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..ed913576 100644
8 8 */ 9 9 10 10 namespace WordPressdotorg\Plugin_Directory\Theme; 11 use WordPressdotorg\Plugin_Directory\Plugin_Directory;12 11 use WordPressdotorg\Plugin_Directory\Template; 12 13 13 ?> 14 14 15 15 <div id="admin" class="section"> 16 16 <?php 17 $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>';17 if ( Template::plugin_is_closed() ) { 18 $message = Template::plugin_not_active_reason(); 19 echo '<div class="plugin-notice notice ' . $message['notice_type'] . ' notice-alt"><p>' . $message['message'] . '</p></div>'; 20 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 -->'; 21 echo '<div class="plugin-notice notice notice-info notice-alt"><p>' 22 . Template::plugin_closed_author_info() 23 . '</p></div><!-- .plugin-notice -->'; 27 24 } 28 25 } 29 26 … … use WordPressdotorg\Plugin_Directory\Template; 43 40 44 41 <?php 45 42 46 $tags = (array) get_post_meta( $post->ID, 'tagged_versions', true );43 $tags = (array) get_post_meta( get_the_ID(), 'tagged_versions', true ); 47 44 // Sort the versions by version 48 45 usort( $tags, 'version_compare' ); 49 46 // We'll want to add a Development Version if it exists 50 47 $tags[] = 'trunk'; 51 48 52 49 // Remove the current version, this may be trunk. 53 $tags = array_diff( $tags, array( get_post_meta( $post->ID, 'stable_tag', true ) ) );50 $tags = array_diff( $tags, array( get_post_meta( get_the_ID(), 'stable_tag', true ) ) ); 54 51 55 52 // List Trunk, followed by the most recent non-stable release. 56 53 $tags = array_reverse( $tags ); … … use WordPressdotorg\Plugin_Directory\Template; 63 60 echo '<select class="previous-versions" onchange="getElementById(\'download-previous-link\').href=this.value;">'; 64 61 foreach ( $tags as $version ) { 65 62 $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 ) );63 printf( '<option value="%s">%s</option>', esc_attr( Template::download_link( get_post(), $version ) ), esc_html( $text ) ); 67 64 } 68 65 echo '</select> '; 69 66 70 67 printf( 71 68 '<a href="%s" id="download-previous-link" class="button">%s</a>', 72 esc_url( Template::download_link( $post, reset( $tags ) ) ),69 esc_url( Template::download_link( get_post(), reset( $tags ) ) ), 73 70 __( 'Download', 'wporg-plugins' ) 74 71 ); 75 72 }