Making WordPress.org


Ignore:
Timestamp:
02/17/2015 11:18:19 PM (9 years ago)
Author:
obenland
Message:

WP.org Themes: Use main query instead of Themes API for server output.

  • Can now deal properly with /browse/*/ URL structure.
  • Adds single theme navigation.
  • Adds Photon support for server output.
  • Brings single theme view closer to melchoyce's mockups.

See #745.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/content-single.php

    r1255 r1274  
    11<?php
    2     global $theme;
    3     $theme = wporg_themes_photon_screen_shot( $theme );
     2$slug  = get_post()->post_name;
     3$theme = themes_api('theme_information', array( 'slug' => $slug ) );
    44?>
    55<div class="theme-wrap">
    66    <div class="theme-about hentry">
    77
    8         <?php if ( strtotime( '-2 years' ) > strtotime( $theme->last_updated ) ) : ?>
     8        <?php if ( strtotime( '-2 years' ) > get_post_modified_time() ) : ?>
    99        <div class="theme-notice notice notice-warning">
    1010            <p><?php _e( 'This theme <strong>hasn&#146;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-themes' ); ?></p>
     
    1414        <div class="theme-head">
    1515            <h3 class="theme-name entry-title"><?php the_title(); ?></h3>
    16             <h4 class="theme-author"><?php printf( __( 'By %s' ), sprintf( '<a href="https://profiles.wordpress.org/%s"><span class="author">%s</span><a/>', $theme->author ) ); ?></h4>
     16            <h4 class="theme-author">
     17                <?php printf( _x( 'By %s', 'post author', 'wporg-themes' ), sprintf( '<a href="https://profiles.wordpress.org/%s"><span class="author">%s</span></a>', get_the_author_meta( 'login' ), esc_html( get_the_author() ) ) ); ?>
     18            </h4>
    1719
    1820            <div class="theme-actions">
    19                 <a href="<?php echo esc_url( '//downloads.wordpress.org/theme/' . $theme->slug . '.' . $theme->version . '.zip' ); ?>" class="button button-primary"><?php _e( 'Download' ); ?></a>
    20                 <a href="<?php echo esc_url( $theme->preview_url ); ?>" class="button button-secondary"><?php _e( 'Preview' ); ?></a>
     21                <a href="<?php echo esc_url( '//wp-themes.com/' . $slug ); ?>" class="button button-secondary"><?php _e( 'Preview' ); ?></a>
     22                <a href="<?php echo esc_url( '//downloads.wordpress.org/theme/' . $slug . '.' . $theme->version . '.zip' ); ?>" class="button button-primary"><?php _e( 'Download' ); ?></a>
    2123            </div>
    2224
    23             <?php if ( ! empty( $theme->parent ) ) : ?>
     25            <?php if ( ! empty( get_post()->parent ) ) : ?>
    2426            <div class="theme-notice notice notice-info">
    2527                <p class="parent-theme"><?php printf( __( 'This is a child theme of %s.' ), sprintf( '<a href="/%1$s">%2$s</a>', $theme->parent->slug, $theme->parent->name ) ); ?></p>
     
    2931
    3032        <div class="theme-info">
    31             <div class="screenshot"><?php echo esc_url( $theme->screenshot_url . '?w=732&strip=all' ); ?></div>
     33            <div class="screenshot"><?php the_post_thumbnail( '798' ); ?></div>
    3234
    3335            <div class="theme-description entry-summary"><?php the_content(); ?></div>
    3436
    3537            <div class="theme-tags">
    36                 <h4><?php _e( 'Tags:' ); ?></h4>
    37                 <?php
    38                 foreach( $theme->tags as &$tag ) :
    39                     $tag = sprintf( '<a href="%1$s">%2$s</a>', esc_url( home_url( "/tag/{$tag}/" ) ), $tag );
    40                 endforeach;
    41                 echo implode( ', ', $theme->tags );
    42                 ?>
     38                <?php the_tags( '<h4>' . __( 'Tags:' ) . '</h4>' ); ?>
    4339            </div><!-- .theme-tags -->
    4440
     
    4642                <h4><?php _e( 'Downloads', 'wporg-themes' ); ?></h4>
    4743
    48                 <div id="theme-download-stats-<?php echo esc_attr( $theme->slug ); ?>" class="chart"></div>
     44                <div id="theme-download-stats-<?php echo esc_attr( $slug ); ?>" class="chart"></div>
    4945                <script type="text/javascript">
    5046                    google.load("visualization", "1", {packages:["corechart"]});
     
    5349                    function drawThemeDownloadsChart() {
    5450                        jQuery(document).ready(function($){
    55                             jQuery.getJSON('https://api.wordpress.org/stats/themes/1.0/downloads.php?slug=<?php echo $theme->slug; ?>&limit=730&callback=?', function (downloads) {
     51                            $.getJSON('https://api.wordpress.org/stats/themes/1.0/downloads.php?slug=<?php echo $slug; ?>&limit=730&callback=?', function (downloads) {
    5652                                var data = new google.visualization.DataTable(),
    5753                                    count = 0;
     
    6763                                });
    6864
    69                                 new google.visualization.ColumnChart(document.getElementById('theme-download-stats-<?php echo esc_attr( $theme->slug ); ?>')).draw(data, {
     65                                new google.visualization.ColumnChart(document.getElementById('theme-download-stats-<?php echo esc_attr( $slug ); ?>')).draw(data, {
    7066                                    colors: ['#253578'],
    7167                                    legend: {
     
    118114                <?php if ( ! empty( $theme->ratings ) && ! empty( $theme->num_ratings ) ) : ?>
    119115                <ul>
    120                     <?php foreach ( $theme->ratings as $key => $rate_count ) : ?>
     116                    <?php
     117                        foreach ( $theme->ratings as $key => $rate_count ) :
     118                            // Hack to have descending key/value pairs.
     119                            $key        = 6 - $key;
     120                            $rate_count = $theme->ratings[ $key ];
     121                    ?>
    121122                    <li class="counter-container">
    122                         <a href="//wordpress.org/support/view/theme-reviews/<?php echo esc_attr( $theme->slug ); ?>?filter=<?php echo $key; ?>" title="<?php printf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key, 'wporg-themes' ), $key ); ?>">
     123                        <a href="//wordpress.org/support/view/theme-reviews/<?php echo esc_attr( $slug ); ?>?filter=<?php echo $key; ?>" title="<?php printf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key, 'wporg-themes' ), $key ); ?>">
    123124                            <span class="counter-label"><?php printf( __( '%d stars', 'wporg-themes' ), $key ); ?></span>
    124125                            <span class="counter-back">
     
    133134            </div><!-- .theme-rating -->
    134135
     136            <div class="theme-support">
     137                <h4><?php _e( 'Support', 'wporg-themes' ); ?></h4>
     138                <p><?php _e( 'Got something to say? Neeed help?', 'wporg-themes' ); ?></p>
     139                <a href="//wordpress.org/support/theme/<?php echo esc_attr( $slug ); ?>" class="button button-secondary"><?php _e( 'View support forum', 'wporg-themes' ); ?></a>
     140            </div><!-- .theme-support -->
     141
    135142            <div class="theme-devs">
    136143                <h4><?php _e( 'Development', 'wporg-themes' ); ?></h4>
     
    138145                <ul class="unmarked-list">
    139146                    <li>
    140                         <a href="//themes.trac.wordpress.org/log/<?php echo esc_attr( $theme->slug ); ?>?limit=100&mode=stop_on_copy&format=rss">
     147                        <a href="//themes.trac.wordpress.org/log/<?php echo esc_attr( $slug ); ?>?limit=100&mode=stop_on_copy&format=rss">
    141148                            <img src="//s.w.org/style/images/feedicon.png" />
    142149                            <?php _e( 'Development Log', 'wporg' ); ?>
     
    147154                <h5><?php _e( 'Browse the Code', 'wporg-themes' ); ?></h5>
    148155                <ul class="unmarked-list">
    149                     <li><a href="//themes.trac.wordpress.org/log/<?php echo esc_attr( $theme->slug ); ?>/" rel="nofollow"><?php _e( 'Development Log', 'wporg-themes' ); ?></a></li>
    150                     <li><a href="//themes.svn.wordpress.org/<?php echo esc_attr( $theme->slug ); ?>/" rel="nofollow"><?php _e( 'Subversion Repository', 'wporg-themes' ); ?></a></li>
    151                     <li><a href="//themes.trac.wordpress.org/browser/<?php echo esc_attr( $theme->slug ); ?>/" rel="nofollow"><?php _e( 'Browse in Trac', 'wporg-themes' ); ?></a></li>
     156                    <li><a href="//themes.trac.wordpress.org/log/<?php echo esc_attr( $slug ); ?>/" rel="nofollow"><?php _e( 'Development Log', 'wporg-themes' ); ?></a></li>
     157                    <li><a href="//themes.svn.wordpress.org/<?php echo esc_attr( $slug ); ?>/" rel="nofollow"><?php _e( 'Subversion Repository', 'wporg-themes' ); ?></a></li>
     158                    <li><a href="//themes.trac.wordpress.org/browser/<?php echo esc_attr( $slug ); ?>/" rel="nofollow"><?php _e( 'Browse in Trac', 'wporg-themes' ); ?></a></li>
    152159                </ul>
    153160            </div><!-- .theme-devs -->
    154161        </div><!-- .theme-meta -->
    155162    </div>
     163    <div class="theme-footer">
     164        <a class="index-link" rel="home" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php _e( 'Return to Themes List', 'wporg-themes' ); ?></a>
     165        <?php the_post_navigation( array(
     166            'prev_text' => '<span class="screen-reader-text">' . __( 'Next', 'wporg-themes' ) . '</span>',
     167            'next_text' => '<span class="screen-reader-text">' . __( 'Previous', 'wporg-themes' ) . '</span>',
     168        ) ); ?>
     169    </div>
    156170</div>
Note: See TracChangeset for help on using the changeset viewer.