Changeset 5457
- Timestamp:
- 05/01/2017 09:23:28 PM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r5340 r5457 43 43 add_filter( 'single_term_title', array( $this, 'filter_single_term_title' ) ); 44 44 add_filter( 'the_content', array( $this, 'filter_rel_nofollow' ) ); 45 add_action( 'wp_head', array( Template::class, 'json_ld_schema' ), 1 ); 45 46 46 47 // Cron tasks. -
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">(' . -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-meta.php
r5248 r5457 33 33 34 34 <h3 class="screen-reader-text"><?php echo apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Meta', 'wporg-plugins' ) : $instance['title'], $instance, $this->id_base ); ?></h3> 35 <link itemprop="applicationCategory" href="http://schema.org/OtherApplication" />36 <span itemprop="offers" itemscope itemtype="http://schema.org/Offer">37 <meta itemprop="price" content="0.00" />38 <meta itemprop="priceCurrency" content="USD" />39 <span itemprop="seller" itemscope itemtype="http://schema.org/Organization">40 <span itemprop="name" content="WordPress.org"></span>41 </span>42 </span>43 35 44 36 <ul> … … 52 44 printf( __( 'Last updated: %s', 'wporg-plugins' ), 53 45 /* Translators: Plugin modified time. */ 54 '<strong>' . sprintf( __( '%s ago', 'wporg-plugins' ), '<span itemprop="dateModified" content="' . esc_attr( get_post_modified_time( 'c' ) ) . '">' . human_time_diff( get_post_modified_time() ) . '</span>' ) . '</strong>'46 '<strong>' . sprintf( __( '%s ago', 'wporg-plugins' ), '<span>' . human_time_diff( get_post_modified_time() ) . '</span>' ) . '</strong>' 55 47 ); 56 48 ?> … … 73 65 <?php endif; ?> 74 66 75 <?php if ( ! get_query_var( 'plugin_advanced' ) ) : ?> 67 <?php if ( ! get_query_var( 'plugin_advanced' ) ) : ?> 76 68 <li class="hide-if-no-js"> 77 69 <?php -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/widgets/class-ratings.php
r5001 r5457 37 37 echo $args['before_title'] . $title . $args['after_title']; 38 38 ?> 39 <meta itemprop="ratingCount" content="<?php echo esc_attr( $num_ratings ) ?>"/>40 39 41 40 <?php if ( $rating ) : ?> … … 44 43 <div class="rating"> 45 44 <?php echo Template::dashicons_stars( $rating ); ?> 46 <meta itemprop="ratingValue" content="<?php echo esc_attr( $rating ) ?>">47 45 </div> 48 46 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/template-parts/plugin-single.php
r5405 r5457 96 96 <?php endif; ?> 97 97 98 <a class="plugin-download button download-button button-large" href="<?php echo esc_url( Template::download_link() ); ?>" itemprop="downloadUrl"><?php _e( 'Download', 'wporg-plugins' ); ?></a> 99 <meta itemprop="softwareVersion" content="<?php echo esc_attr( get_post_meta( get_the_ID(), 'version', true ) ); ?>"> 100 <meta itemprop="fileFormat" content="application/zip"> 98 <a class="plugin-download button download-button button-large" href="<?php echo esc_url( Template::download_link() ); ?>"><?php _e( 'Download', 'wporg-plugins' ); ?></a> 101 99 </div> 102 100
Note: See TracChangeset
for help on using the changeset viewer.