Changeset 6118 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
- Timestamp:
- 11/14/2017 05:01:46 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r6027 r6118 46 46 47 47 // Schema for plugin pages. 48 if ( is_singular( 'plugin' ) ) : 49 $plugin = get_queried_object(); 50 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 ); 54 55 echo PHP_EOL; 56 ?> 48 if ( is_singular( 'plugin' ) && 'publish' === get_post_status( get_queried_object_id() ) ) { 49 self::plugin_json_jd_schema( get_queried_object() ); 50 } 51 } 52 53 /** 54 * Prints JSON LD schema for a specific plugin. 55 * 56 * @static 57 * 58 * @param \WP_Post $plugin Plugin to output JSON LD Schema for. 59 */ 60 protected static function plugin_json_jd_schema( $plugin ) { 61 $rating = get_post_meta( $plugin->ID, 'rating', true ) ?: 0; 62 $ratings = get_post_meta( $plugin->ID, 'ratings', true ) ?: []; 63 $num_ratings = array_sum( $ratings ); 64 65 echo PHP_EOL; 66 ?> 57 67 <script type="application/ld+json"> 58 68 [ … … 115 125 ] 116 126 </script> 117 <?php 118 endif; 119 } 120 121 /** 122 * Prints meta description in the head of a page. 123 * 124 * @static 125 */ 126 public static function meta_description() { 127 <?php 128 } 129 130 /** 131 * Prints meta tags in the head of a page. 132 * 133 * @static 134 */ 135 public static function output_meta() { 136 $metas = []; 137 127 138 if ( is_singular( 'plugin' ) ) { 128 printf( '<meta name="description" value="%s"/>',129 esc_attr( get_the_excerpt( get_queried_object()) )139 $metas[] = sprintf( '<meta name="description" value="%s" />', 140 esc_attr( get_the_excerpt() ) 130 141 ); 131 } 142 143 // Add noindex on disabled plugin page. 144 if ( 'publish' !== get_post_status() ) { 145 $metas[] = '<meta name="robots" content="noindex" />'; 146 } 147 } 148 149 echo implode( "\n", $metas ); 132 150 } 133 151
Note: See TracChangeset
for help on using the changeset viewer.