Ticket #2627: 2627-add-noindex-meta.2.patch
File 2627-add-noindex-meta.2.patch, 5.8 KB (added by , 7 years ago) |
---|
-
plugins/plugin-directory/class-plugin-directory.php
46 46 add_action( 'wp_head', array( Template::class, 'json_ld_schema' ), 1 ); 47 47 add_action( 'wp_head', array( Template::class, 'meta_description' ), 1 ); 48 48 add_action( 'wp_head', array( Template::class, 'hreflang_link_attributes' ), 2 ); 49 add_action( 'wp_head', array( Template::class, 'output_meta' ), 1 ); 49 50 50 51 // Cron tasks. 51 52 new Jobs\Manager(); … … 317 318 ) ); 318 319 register_post_status( 'disabled', array( 319 320 'label' => _x( 'Disabled', 'plugin status', 'wporg-plugins' ), 320 'public' => false,321 'public' => true, 321 322 'show_in_admin_status_list' => current_user_can( 'plugin_disable' ), 322 323 'label_count' => _n_noop( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', 'wporg-plugins' ), 323 324 ) ); … … 818 819 }, 10, 2 ); 819 820 } 820 821 822 // Allow anyone to view a disabled plugin directly from its page. It won't show in search results or lists. 823 if ( !empty( $wp_query->query_vars['name'] ) ) { 824 $wp_query->query_vars['post_status'] = (array) $wp_query->query_vars['post_status']; 825 $wp_query->query_vars['post_status'][] = 'disabled'; 826 $wp_query->query_vars['post_status'] = array_unique( $wp_query->query_vars['post_status'] ); 827 } 828 821 829 // By default, all archives are sorted by active installs 822 830 if ( $wp_query->is_archive() && empty( $wp_query->query_vars['orderby'] ) ) { 823 831 $wp_query->query_vars['orderby'] = 'meta_value_num'; -
plugins/plugin-directory/class-template.php
45 45 endif; 46 46 47 47 // Schema for plugin pages. 48 if ( is_singular( 'plugin' ) ) : 49 $plugin = get_queried_object(); 48 if ( is_singular( 'plugin' ) && get_post_status( get_queried_object_id() ) !== 'disabled' ) { 49 self::plugin_json_jd_schema( get_queried_object() ); 50 } 51 } 50 52 51 $rating = get_post_meta( $plugin->ID, 'rating', true ) ?: 0; 52 $ratings = get_post_meta( $plugin->ID, 'ratings', true ) ?: []; 53 $num_ratings = array_sum( $ratings ); 53 /** 54 * Prints JSON LD schema for a specific plugin 55 * 56 * @param \WP_Post $plugin Plugin to output JSON LD Schema for. 57 */ 58 protected static function plugin_json_jd_schema( $plugin ) { 59 $rating = get_post_meta( $plugin->ID, 'rating', true ) ?: 0; 60 $ratings = get_post_meta( $plugin->ID, 'ratings', true ) ?: []; 61 $num_ratings = array_sum( $ratings ); 54 62 55 56 57 <script type="application/ld+json">63 echo PHP_EOL; 64 ?> 65 <script type="application/ld+json"> 58 66 [ 59 67 { 60 68 "@context": "http://schema.org", … … 114 122 } 115 123 ] 116 124 </script> 117 <?php 118 endif; 125 <?php 119 126 } 120 127 121 128 /** 129 * Prints meta tags on a page. 130 */ 131 public static function output_meta() { 132 $metas = []; 133 134 // Add noindex on disabled plugin page. 135 if ( is_singular( 'plugin' ) && get_post_status( get_queried_object_id() ) === 'disabled' ) { 136 $metas[] = '<meta name="robots" content="noindex" />'; 137 } 138 139 echo implode( PHP_EOL, $metas ); 140 } 141 142 /** 122 143 * Prints meta description in the head of a page. 123 144 * 124 145 * @static -
themes/pub/wporg-plugins/template-parts/plugin-single.php
24 24 <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> 25 25 </div><!-- .plugin-notice --> 26 26 <?php endif; ?> 27 27 <?php if ( 'publish' != get_post()->post_status ) : 28 28 $notice_type = 'notice-error'; 29 29 switch ( get_post()->post_status ) { 30 30 case 'draft': … … 50 50 // fall through 51 51 default: 52 52 case 'closed': 53 $message = __( 'This plugin is closed and is not visible to the public.', 'wporg-plugins' );53 $message = __( 'This plugin is closed and no longer available for download.', 'wporg-plugins' ); 54 54 break; 55 55 } 56 56 ?> … … 95 95 </div> 96 96 <?php endif; ?> 97 97 98 <?php if ( get_post_status() !== 'disabled' || current_user_can( 'plugin_admin_view', get_post() ) ) : ?> 98 99 <a class="plugin-download button download-button button-large" href="<?php echo esc_url( Template::download_link() ); ?>"><?php _e( 'Download', 'wporg-plugins' ); ?></a> 100 <?php endif; ?> 99 101 </div> 100 102 101 103 <?php the_title( '<h1 class="plugin-title"><a href="' . esc_url( get_permalink() ) . '">', '</a></h1>' ); ?> -
themes/pub/wporg-plugins/template-parts/section-advanced.php
40 40 // List Trunk, followed by the most recent non-stable release. 41 41 $tags = array_reverse( $tags ); 42 42 43 if ( $tags ) {43 if ( $tags && 'publish' == get_post()->post_status ) { 44 44 echo '<h5>' . __( 'Previous Versions', 'wporg-plugins' ) . '</h5>'; 45 45 46 46 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>';