Changeset 9533
- Timestamp:
- 02/24/2020 07:29:25 AM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
r9522 r9533 804 804 'tested' => true, 805 805 'requires' => true, 806 'downloaded' => false,806 'downloaded' => true, 807 807 'downloadlink' => true, 808 808 'last_updated' => true, -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php
r9523 r9533 452 452 new Jetpack_SEO; 453 453 } 454 455 /** 456 * Prints markup information in the head of a page. 457 * 458 * @link http://schema.org/SoftwareApplication 459 * @link https://developers.google.com/search/docs/data-types/software-apps 460 */ 461 function wporg_themes_json_ld_schema() { 462 $schema = false; 463 464 // Schema for the front page. 465 if ( is_front_page() ) { 466 $schema = [ 467 "@context" => "http://schema.org", 468 "@type" => "WebSite", 469 "name" => __( 'WordPress Themes', 'wporg-themes' ), 470 "url" => home_url( '/' ), 471 "potentialAction" => [ 472 [ 473 "@type" => "SearchAction", 474 "target" => home_url( '/search/{search_term_string}' ), 475 "query-input" => "required name=search_term_string" 476 ] 477 ] 478 ]; 479 480 // Schema for theme pages. 481 } elseif ( is_singular( 'repopackage' ) && 'publish' === get_post_status( get_queried_object_id() ) ) { 482 $schema = wporg_themes_json_jd_schema( get_queried_object() ); 483 } 484 485 // Print the schema. 486 if ( $schema ) { 487 echo PHP_EOL, '<script type="application/ld+json">', PHP_EOL; 488 // Output URLs without escaping the slashes, and print it human readable. 489 echo wp_json_encode( $schema, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ); 490 echo PHP_EOL, '</script>', PHP_EOL; 491 } 492 } 493 add_action( 'wp_head', 'wporg_themes_json_ld_schema' ); 494 495 /** 496 * Fetches JSON LD schema for a specific theme. 497 * 498 * @static 499 * 500 * @param \WP_Post $post Plugin to output JSON LD Schema for. 501 * @return array Schema object. 502 */ 503 function wporg_themes_json_jd_schema( $post ) { 504 505 $theme = wporg_themes_theme_information( $post->post_name ); 506 507 $schema = []; 508 509 // Add the theme 'SoftwareApplication' node. 510 $software_application = [ 511 "@context" => "http://schema.org", 512 "@type" => [ 513 "SoftwareApplication", 514 "Product" 515 ], 516 "applicationCategory" => "Theme", 517 "operatingSystem" => "WordPress", 518 "name" => $theme->name, 519 "url" => get_permalink( $post ), 520 "description" => $theme->description, 521 "softwareVersion" => $theme->version, 522 "fileFormat" => "application/zip", 523 "downloadUrl" => $theme->download_link, 524 "dateModified" => get_post_modified_time( 'c', false, $post ), 525 "aggregateRating" => [ 526 "@type" => "AggregateRating", 527 "worstRating" => 1, 528 "bestRating" => 5, 529 "ratingValue" => round( $theme->rating / 20 / 0.5 )*0.5, 530 "ratingCount" => (int) $theme->num_ratings, 531 "reviewCount" => (int) $theme->num_ratings, 532 ], 533 "interactionStatistic" => [ 534 "@type" => "InteractionCounter", 535 "interactionType" => "http://schema.org/DownloadAction", 536 "userInteractionCount" => $theme->downloaded, 537 ], 538 "image" => $theme->screenshot_url, 539 "offers" => [ 540 "@type" => "Offer", 541 "url" => get_permalink( $post ), 542 "price" => "0.00", 543 "priceCurrency" => "USD", 544 "seller" => [ 545 "@type" => "Organization", 546 "name" => "WordPress.org", 547 "url" => "https://wordpress.org" 548 ] 549 ] 550 ]; 551 552 // Remove the aggregateRating node if there's no reviews. 553 if ( ! $software_application['aggregateRating']['ratingCount'] ) { 554 unset( $software_application['aggregateRating'] ); 555 } 556 557 $schema[] = $software_application; 558 559 return $schema; 560 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/theme-single.php
r9346 r9533 8 8 </div> 9 9 <div class="theme-wrap"> 10 <div class="theme-about hentry" itemscope itemtype="http://schema.org/CreativeWork">10 <div class="theme-about hentry"> 11 11 <?php if ( time() - strtotime( $theme->last_updated ) > 2 * YEAR_IN_SECONDS ) { ?> 12 12 <div class="theme-notice notice notice-warning notice-alt"> … … 16 16 17 17 <div> 18 <h3 class="theme-name entry-title" itemprop="name"><?php echo esc_html( $theme->name ); ?></h3>18 <h3 class="theme-name entry-title"><?php echo esc_html( $theme->name ); ?></h3> 19 19 <?php if ( $theme->author->display_name ) { ?> 20 <h4 class="theme-author"><?php printf( _x( 'By %s', 'theme author', 'wporg-themes' ), '<a href="https://wordpress.org/themes/author/' . $theme->author->user_nicename . '/"><span class="author" itemprop="author">' . esc_html( $theme->author->display_name ) . '</span></a>' ); ?></h4>20 <h4 class="theme-author"><?php printf( _x( 'By %s', 'theme author', 'wporg-themes' ), '<a href="https://wordpress.org/themes/author/' . $theme->author->user_nicename . '/"><span class="author">' . esc_html( $theme->author->display_name ) . '</span></a>' ); ?></h4> 21 21 <?php } ?> 22 22 … … 84 84 <?php } ?> 85 85 86 <div class="theme-description entry-summary" itemprop="description"><p><?php echo esc_html( $theme->description ); ?></p></div>86 <div class="theme-description entry-summary"><p><?php echo esc_html( $theme->description ); ?></p></div> 87 87 88 88 <?php if ( $theme->tags ) { ?> … … 108 108 109 109 <div class="theme-meta"> 110 <div class="theme-ratings" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"> 111 <meta itemprop="ratingCount" content="<?php echo $theme->num_ratings; ?>"/> 110 <div class="theme-ratings"> 112 111 <h4><?php _e( 'Ratings', 'wporg-themes' ); ?></h4> 113 112 … … 121 120 <span class="four"></span> 122 121 <span class="five"></span> 123 <p class="description"><?php printf( __( '%s out of 5 stars.', 'wporg-themes' ), '<span itemprop="ratingValue">' . round( $theme->rating / 20 / 0.5 )*0.5 . '</span>' ); ?></p>122 <p class="description"><?php printf( __( '%s out of 5 stars.', 'wporg-themes' ), '<span>' . round( $theme->rating / 20 / 0.5 )*0.5 . '</span>' ); ?></p> 124 123 </div> 125 124 <?php } else { ?> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/view-templates/theme-single.php
r9346 r9533 8 8 </div> 9 9 <div class="theme-wrap"> 10 <div class="theme-about hentry" itemscope itemtype="http://schema.org/CreativeWork">10 <div class="theme-about hentry"> 11 11 <# if ( data.is_outdated ) { #> 12 12 <div class="theme-notice notice notice-warning notice-alt"> … … 16 16 17 17 <div> 18 <h3 class="theme-name entry-title" itemprop="name">{{{ data.name }}}</h3>18 <h3 class="theme-name entry-title">{{{ data.name }}}</h3> 19 19 <# if ( data.author.display_name ) { #> 20 <h4 class="theme-author"><?php printf( _x( 'By %s', 'theme author', 'wporg-themes' ), '<a href="{{{ data.path }}}author/{{ data.author.user_nicename }}/"><span class="author" itemprop="author">{{{ data.author.display_name }}}</span></a>' ); ?></h4>20 <h4 class="theme-author"><?php printf( _x( 'By %s', 'theme author', 'wporg-themes' ), '<a href="{{{ data.path }}}author/{{ data.author.user_nicename }}/"><span class="author">{{{ data.author.display_name }}}</span></a>' ); ?></h4> 21 21 <# } #> 22 22 … … 63 63 <# } #> 64 64 65 <div class="theme-description entry-summary" itemprop="description"><p>{{{ data.description }}}</p></div>65 <div class="theme-description entry-summary"><p>{{{ data.description }}}</p></div> 66 66 67 67 <# if ( data.tags ) { #> … … 79 79 80 80 <div class="theme-meta"> 81 <div class="theme-ratings" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"> 82 <meta itemprop="ratingCount" content="{{ data.num_ratings }}"/> 81 <div class="theme-ratings"> 83 82 <h4><?php _e( 'Ratings', 'wporg-themes' ); ?></h4> 84 83 … … 92 91 <span class="four"></span> 93 92 <span class="five"></span> 94 <p class="description"><?php printf( __( '%s out of 5 stars.', 'wporg-themes' ), '<span itemprop="ratingValue">{{ Math.round( data.rating / 20 / 0.5 )*0.5 }}</span>' ); ?></p>93 <p class="description"><?php printf( __( '%s out of 5 stars.', 'wporg-themes' ), '<span>{{ Math.round( data.rating / 20 / 0.5 )*0.5 }}</span>' ); ?></p> 95 94 </div> 96 95 <# } else { #>
Note: See TracChangeset
for help on using the changeset viewer.