Making WordPress.org


Ignore:
Timestamp:
04/20/2015 02:17:13 AM (9 years ago)
Author:
dd32
Message:

Theme Directory: Morph the Theme directory theme into a API front-end rather than a WordPress Theme.
This commit alters the directory to only rely upon the WordPress Query Vars, it doesn't actually use the WordPress posts query to get it's posts, rather it pulls it directly from the API.
This is part of the process of bringing the Theme Directory to rosetta/locallised sites, where the theme data won't live in the localised sites database.

File:
1 copied

Legend:

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

    r1483 r1489  
    1 <script id="tmpl-theme-single" type="text/template">
     1<div>
    22    <div class="theme-navigation">
    3         <button class="close"><?php _e( 'Return to Themes List', 'wporg-themes' ); ?></button>
     3        <a class="close" href="<?php echo home_url('/'); ?>"><?php _e( 'Return to Themes List', 'wporg-themes' ); ?></a>
    44        <div class="navigation post-navigation">
    5             <button class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme', 'wporg-themes' ); ?></span></button>
    6             <button class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme', 'wporg-themes' ); ?></span></button>
     5            <button class="left dashicons dashicons-no disabled"><span class="screen-reader-text"><?php _e( 'Show previous theme', 'wporg-themes' ); ?></span></button>
     6            <button class="right dashicons dashicons-no disabled"><span class="screen-reader-text"><?php _e( 'Show next theme', 'wporg-themes' ); ?></span></button>
    77        </div>
    88    </div>
    99    <div class="theme-wrap">
    1010        <div class="theme-about hentry" itemscope itemtype="http://schema.org/CreativeWork">
    11             <# if ( data.is_outdated ) { #>
     11            <?php if ( time() - strtotime( $theme->last_updated ) > 2 * YEAR_IN_SECONDS ) { ?>
    1212            <div class="theme-notice notice notice-warning">
    1313                <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><!-- .theme-notice -->
    15             <# } #>
     15            <?php } ?>
    1616
    1717            <div>
    18                 <h3 class="theme-name entry-title" itemprop="name">{{{ data.name }}}</h3>
    19                 <h4 class="theme-author"><?php printf( _x( 'By %s', 'theme author', 'wporg-themes' ), '<a href="https://wordpress.org/themes/author/{{ data.author.user_nicename }}/"><span class="author" itemprop="author">{{{ data.author.display_name }}}</span></a>' ); ?></h4>
     18                <h3 class="theme-name entry-title" itemprop="name"><?php echo esc_html( $theme->name ); ?></h3>
     19                <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>
    2020            </div>
    2121
    2222            <div class="theme-head">
    2323                <div class="theme-actions clear">
    24                     <a href="{{{ data.preview_url }}}" class="button button-secondary alignleft"><?php _e( 'Preview', 'wporg-themes' ); ?></a>
    25                     <a href="//downloads.wordpress.org/theme/{{ data.slug }}.{{ data.version }}.zip" class="button button-primary alignright"><?php _e( 'Download', 'wporg-themes' ); ?></a>
     24                    <a href="<?php echo esc_url( $theme->preview_url ); ?>" class="button button-secondary alignleft"><?php _e( 'Preview', 'wporg-themes' ); ?></a>
     25                    <a href="<?php echo esc_url( $theme->download_link); ?>" class="button button-primary alignright"><?php _e( 'Download', 'wporg-themes' ); ?></a>
    2626                </div>
    2727
    28                 <# if ( data.parent ) { #>
     28                <?php if ( !empty( $theme->parent ) ) { ?>
    2929                <div class="theme-notice notice notice-info">
    30                     <p class="parent"><?php printf( __( 'This is a child theme of %s.', 'wporg-themes' ), sprintf( '<a href="/themes/%1$s/">%2$s</a>', '{{{ data.parent.slug }}}', '{{{ data.parent.name }}}' ) ); ?></p>
     30                    <p class="parent"><?php printf( __( 'This is a child theme of %s.', 'wporg-themes' ), sprintf( '<a href="%1$s">%2$s</a>', home_url( $theme->parent['slug'] . '/' ), esc_html( $theme->parent['name'] ) ) ); ?></p>
    3131                </div>
    32                 <# } #>
     32                <?php } ?>
    3333
    3434                <div class="theme-meta-info">
    35                     <p class="updated"><?php printf( __( 'Last updated: %s', 'wporg-themes' ), '<strong>{{ data.last_updated }}</strong>' ); ?></p>
    36                     <# if ( data.theme_url ) { #>
    37                     <a href="{{ data.theme_url }}"><?php _e( 'Theme Homepage', 'wporg-themes' ); ?></a>
    38                     <# } #>
     35                    <p class="updated"><?php printf( __( 'Last updated: %s', 'wporg-themes' ), '<strong>' . date_i18n( 'F j, Y', strtotime( $theme->last_updated ) ) . '</strong>' ); ?></p>
     36                    <?php if ( $theme->theme_url ) { ?>
     37                    <a href="<?php echo esc_url( $theme->theme_url ); ?>"><?php _e( 'Theme Homepage', 'wporg-themes' ); ?></a>
     38                    <?php } ?>
    3939                </div>
    4040            </div><!-- .theme-head -->
    4141
    4242            <div class="theme-info">
    43                 <# if ( data.screenshot_url ) { #>
    44                 <div class="screenshot"><img src="{{ data.screenshot_url }}?w=1142&strip=all" alt=""/></div>
    45                 <# } else { #>
    46                 <div class="screenshot blank"></div>
    47                 <# } #>
     43                <?php if ( $theme->screenshot_url ) { ?>
     44                    <div class="screenshot"><img src="<?php echo esc_url( $theme->screenshot_url ); ?>?w=1142&strip=all" alt=""/></div>
     45                <?php } else { ?>
     46                    <div class="screenshot blank"></div>
     47                <?php } ?>
    4848
    49                 <div class="theme-description entry-summary" itemprop="description"><p>{{{ data.description }}}</p></div>
     49                <div class="theme-description entry-summary" itemprop="description"><p><?php echo esc_html( $theme->description ); ?></p></div>
    5050
    51                 <# if ( data.tags ) { #>
     51                <?php if ( $theme->tags ) { ?>
    5252                <div class="theme-tags">
    5353                    <h4><?php _e( 'Tags:', 'wporg-themes' ); ?></h4>
    54                     {{{ data.tags }}}
     54                    <?php
     55                    $tag_links = array();
     56                    foreach ( $theme->tags as $slug => $tagname ) {
     57                        $tag_links[] = sprintf(
     58                            "<a href='%s'>%s</a>",
     59                            esc_url( home_url( "/tags/$slug/" ) ),
     60                            esc_html( $tagname )
     61                        );
     62                    }
     63                    echo implode( ', ', $tag_links );                       
     64                    ?>
    5565                </div><!-- .theme-tags -->
    56                 <# } #>
     66                <?php } ?>
    5767
    5868                <div class="theme-downloads">
    59                     <h4><?php _e( 'Downloads Per Day', 'wporg-themes' ); ?></h4>
    60                     <div id="theme-download-stats-{{data.id}}" class="chart"></div>
    61                     <p class="total-downloads"><?php printf( __( 'Total downloads: %s', 'wporg-themes' ), '<strong>{{ data.downloaded }}</strong>' ); ?></p>
     69                    <p class="total-downloads"><?php printf( __( 'Total downloads: %s', 'wporg-themes' ), '<strong>' . number_format_i18n( $theme->downloaded ) . '</strong>' ); ?></p>
    6270                </div><!-- .theme-downloads -->
    6371            </div>
     
    6573            <div class="theme-meta">
    6674                <div class="theme-ratings" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
    67                     <meta itemprop="ratingCount" content="{{ data.num_ratings }}"/>
     75                    <meta itemprop="ratingCount" content="<?php echo $theme->num_ratings; ?>"/>
    6876                    <h4><?php _e( 'Ratings', 'wporg-themes' ); ?></h4>
    6977
    70                     <# if ( data.rating ) { #>
    71                     <div class="rating rating-{{ Math.round( data.rating / 10 ) * 10 }}">
     78                    <?php if ( $theme->rating ) { ?>
     79                    <div class="rating rating-<?php echo round( $theme->rating / 10 ) * 10; ?>">
    7280                        <span class="one"></span>
    7381                        <span class="two"></span>
     
    7583                        <span class="four"></span>
    7684                        <span class="five"></span>
    77                         <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>
     85                        <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>
    7886                    </div>
    79                     <# } else { #>
     87                    <?php } else { ?>
    8088                    <div class="rating">
    8189                        <div class="ratings"><?php _e( 'This theme has not been rated yet.', 'wporg-themes' ); ?></div>
    8290                    </div>
    83                     <# } #>
     91                    <?php } ?>
    8492
    85                     <# if ( data.ratings ) { #>
     93                    <?php if ( $theme->ratings ) { ?>
    8694                    <ul>
    87                         <?php foreach ( range( 5, 1 ) as $stars ) : ?>
     95                        <?php foreach ( range( 5, 1 ) as $stars ) :
     96                            $rating_bar_width = $theme->num_ratings ? 100 * $theme->ratings[$stars] / $theme->num_ratings : 0;
     97                        ?>
    8898                        <li class="counter-container">
    89                             <a href="//wordpress.org/support/view/theme-reviews/{{ data.id }}?filter=<?php echo $stars; ?>" title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $stars, 'wporg-themes' ), $stars ) ); ?>">
     99                            <a href="//wordpress.org/support/view/theme-reviews/<?php echo $theme->slug; ?>?filter=<?php echo $stars; ?>" title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $stars, 'wporg-themes' ), $stars ) ); ?>">
    90100                                <span class="counter-label"><?php printf( _n( '%d star', '%d stars', $stars, 'wporg-themes' ), $stars ); ?></span>
    91101                                <span class="counter-back">
    92                                     <span class="counter-bar" style="width: {{ 100 * data.ratings[<?php echo $stars; ?>] / data.num_ratings }}%;"></span>
     102                                    <span class="counter-bar" style="width: <?php echo $rating_bar_width; ?>%;"></span>
    93103                                </span>
    94                                 <span class="counter-count">{{ data.ratings[<?php echo $stars; ?>] }}</span>
     104                                <span class="counter-count"><?php echo $theme->ratings[$stars]; ?></span>
    95105                            </a>
    96106                        </li>
    97107                        <?php endforeach; ?>
    98108                    </ul>
    99                     <# } #>
     109                    <?php } ?>
    100110
    101                     <a class="button button-secondary" href="https://wordpress.org/support/view/theme-reviews/{{ data.id }}#postform"><?php _e( 'Add your review', 'wporg-themes' ); ?></a>
     111                    <a class="button button-secondary" href="https://wordpress.org/support/view/theme-reviews/<?php echo $theme->slug; ?>#postform"><?php _e( 'Add your review', 'wporg-themes' ); ?></a>
    102112                </div><!-- .theme-rating -->
    103113
     
    105115                    <h4><?php _e( 'Support', 'wporg-themes' ); ?></h4>
    106116                    <p><?php _e( 'Got something to say? Need help?', 'wporg-themes' ); ?></p>
    107                     <a href="//wordpress.org/support/theme/{{ data.slug }}" class="button button-secondary"><?php _e( 'View support forum', 'wporg-themes' ); ?></a>
     117                    <a href="//wordpress.org/support/theme/<?php echo $theme->slug; ?>" class="button button-secondary"><?php _e( 'View support forum', 'wporg-themes' ); ?></a>
    108118                </div><!-- .theme-support -->
    109119
     
    113123                    <ul class="unmarked-list">
    114124                        <li>
    115                             <a href="//themes.trac.wordpress.org/log/{{data.id}}?limit=100&mode=stop_on_copy&format=rss">
     125                            <a href="//themes.trac.wordpress.org/log/<?php echo $theme->slug; ?>?limit=100&amp;mode=stop_on_copy&amp;format=rss">
    116126                                <img src="//s.w.org/style/images/feedicon.png" />
    117127                                <?php _e( 'Development Log', 'wporg-themes' ); ?>
     
    122132                    <h5><?php _e( 'Browse the Code', 'wporg-themes' ); ?></h5>
    123133                    <ul class="unmarked-list">
    124                         <li><a href="//themes.trac.wordpress.org/log/{{data.id}}/" rel="nofollow"><?php _e( 'Development Log', 'wporg-themes' ); ?></a></li>
    125                         <li><a href="//themes.svn.wordpress.org/{{data.id}}/" rel="nofollow"><?php _e( 'Subversion Repository', 'wporg-themes' ); ?></a></li>
    126                         <li><a href="//themes.trac.wordpress.org/browser/{{data.id}}/" rel="nofollow"><?php _e( 'Browse in Trac', 'wporg-themes' ); ?></a></li>
     134                        <li><a href="//themes.trac.wordpress.org/log/<?php echo $theme->slug; ?>/" rel="nofollow"><?php _e( 'Development Log', 'wporg-themes' ); ?></a></li>
     135                        <li><a href="//themes.svn.wordpress.org/<?php echo $theme->slug; ?>/" rel="nofollow"><?php _e( 'Subversion Repository', 'wporg-themes' ); ?></a></li>
     136                        <li><a href="//themes.trac.wordpress.org/browser/<?php echo $theme->slug; ?>/" rel="nofollow"><?php _e( 'Browse in Trac', 'wporg-themes' ); ?></a></li>
    127137                    </ul>
    128138                </div><!-- .theme-devs -->
     
    130140        </div>
    131141    </div>
    132 </script>
     142</div>
Note: See TracChangeset for help on using the changeset viewer.