Changeset 5457 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
- Timestamp:
- 05/01/2017 09:23:28 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-template.php
r5404 r5457 13 13 */ 14 14 class Template { 15 16 /** 17 * Prints markup information in the head of a page. 18 * 19 * @link http://schema.org/SoftwareApplication 20 * @link https://developers.google.com/search/docs/data-types/software-apps 21 * 22 * @static 23 */ 24 public static function json_ld_schema() { 25 // Schema for the front page. 26 if ( is_front_page() ) : 27 echo PHP_EOL; 28 ?> 29 <script type="application/ld+json"> 30 { 31 "@context": "http://schema.org", 32 "@type": "WebSite", 33 "name": <?php echo wp_json_encode( __( 'WordPress Plugins', 'wporg-plugins' ) ); ?>, 34 "url": <?php echo wp_json_encode( home_url( '/' ) ); ?>, 35 "potentialAction": [ 36 { 37 "@type": "SearchAction", 38 "target": <?php echo wp_json_encode( home_url( '?s={search_term_string}' ) ); ?>, 39 "query-input": "required name=search_term_string" 40 } 41 ] 42 } 43 </script> 44 <?php 45 endif; 46 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 ?> 57 <script type="application/ld+json"> 58 [ 59 { 60 "@context": "http://schema.org", 61 "@type": "BreadcrumbList", 62 "itemListElement": [ 63 { 64 "@type": "ListItem", 65 "position": 1, 66 "item": { 67 "@id": "https://wordpress.org/", 68 "name": "WordPress" 69 } 70 }, 71 { 72 "@type": "ListItem", 73 "position": 2, 74 "item": { 75 "@id": <?php echo wp_json_encode( home_url( '/' ) ); ?>, 76 "name": <?php echo wp_json_encode( __( 'WordPress Plugins', 'wporg-plugins' ) ) . PHP_EOL; ?> 77 } 78 } 79 ] 80 }, 81 { 82 "@context": "http://schema.org", 83 "@type": "SoftwareApplication", 84 "applicationCategory": "http://schema.org/OtherApplication", 85 "name": <?php echo wp_json_encode( get_the_title( $plugin ) ); ?>, 86 "description": <?php echo wp_json_encode( get_the_excerpt( $plugin ) ); ?>, 87 "softwareVersion": <?php echo wp_json_encode( $plugin->version ); ?>, 88 "fileFormat": "application/zip", 89 "downloadUrl": <?php echo wp_json_encode( self::download_link( $plugin ) ); ?>, 90 "dateModified": <?php echo wp_json_encode( get_post_modified_time( 'c', false, $plugin ) ); ?>, 91 "aggregateRating": { 92 "@type": "AggregateRating", 93 "worstRating": 0, 94 "bestRating": 5, 95 "ratingValue": <?php echo wp_json_encode( $rating ); ?>, 96 "ratingCount": <?php echo wp_json_encode( $num_ratings ); ?>, 97 "reviewCount": <?php echo wp_json_encode( $num_ratings ) . PHP_EOL; ?> 98 }, 99 "interactionStatistic": { 100 "@type": "InteractionCounter", 101 "interactionType": "http://schema.org/DownloadAction", 102 "userInteractionCount": <?php echo wp_json_encode( self::get_downloads_count( $plugin ) ) . PHP_EOL; ?> 103 }, 104 "offers": { 105 "@type": "Offer", 106 "price": "0.00", 107 "priceCurrency": "USD", 108 "seller": { 109 "@type": "Organization", 110 "name": "WordPress.org", 111 "url": "https://wordpress.org" 112 } 113 } 114 } 115 ] 116 </script> 117 <?php 118 endif; 119 } 15 120 16 121 /** … … 99 204 100 205 return 101 '<div class="plugin-rating" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">' . 102 '<meta itemprop="ratingCount" content="' . esc_attr( $num_ratings ) . '"/>' . 103 '<meta itemprop="ratingValue" content="' . esc_attr( $rating ) . '"/>' . 206 '<div class="plugin-rating">' . 104 207 Template::dashicons_stars( $rating ) . 105 208 '<span class="rating-count">(' .
Note: See TracChangeset
for help on using the changeset viewer.