Making WordPress.org


Ignore:
Timestamp:
06/12/2023 08:55:09 PM (3 years ago)
Author:
ryelle
Message:

Theme Directory: Add tabs to view "community" and "commercial" themes.

Fixes #7036.

File:
1 edited

Legend:

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

    r11967 r12646  
    1212 */
    1313
     14$menu_items = array(
     15        array(
     16                'href' => home_url( '/' ),
     17                'label' => _x( 'Popular', 'themes', 'wporg-themes' ),
     18                'data-sort' => 'popular',
     19                'is-current' => ( is_front_page() && ! get_query_var( 'browse' ) ) || 'popular' == get_query_var( 'browse' ),
     20        ),
     21        array(
     22                'href' => home_url( 'browse/new/' ),
     23                'label' => _x( 'Latest', 'themes', 'wporg-themes' ),
     24                'data-sort' => 'new',
     25                'is-current' => 'new' == get_query_var( 'browse' ),
     26        ),
     27        array(
     28                'href' => home_url( 'browse/commercial/' ),
     29                'label' => _x( 'Commercial', 'theme category', 'wporg-themes' ),
     30                'data-model' => 'commercial',
     31                'is-current' => 'commercial' == get_query_var( 'theme_business_model' ),
     32        ),
     33        array(
     34                'href' => home_url( 'browse/community/' ),
     35                'label' => _x( 'Community', 'theme category', 'wporg-themes' ),
     36                'data-model' => 'community',
     37                'is-current' => 'community' == get_query_var( 'theme_business_model' ),
     38        ),
     39        array(
     40                'href' => home_url( 'tags/full-site-editing/' ),
     41                'label' => _x( 'Block Themes', 'themes filter', 'wporg-themes' ),
     42                'data-tag' => 'full-site-editing',
     43                'is-current' => 'full-site-editing' == get_query_var( 'tag' ),
     44        ),
     45);
     46
    1447get_header();
    1548?>
     
    1750                <div class="wp-filter">
    1851                        <h2 class="screen-reader-text"><?php _e( 'Themes List', 'wporg-themes' ); ?></h2>
    19                         <div class="filter-count">
    20                                 <span class="count theme-count"><?php echo number_format_i18n( $wp_query->found_posts ); ?></span>
    21                         </div>
    22 
    2352                        <ul class="filter-links">
    24                                 <li><a href="<?php echo esc_url( home_url( '/' ) ); ?>" data-sort="popular" <?php if ( (is_front_page() && !get_query_var('browse') ) || 'popular' == get_query_var('browse') ) { echo 'class="current"'; } ?>><?php _ex( 'Popular', 'themes', 'wporg-themes' ); ?></a></li>
    25                                 <li><a href="<?php echo esc_url( home_url( 'browse/new/' ) ); ?>" data-sort="new" <?php if ( 'new' == get_query_var('browse') ) { echo 'class="current"'; } ?>><?php _ex( 'Latest', 'themes', 'wporg-themes' ); ?></a></li>
    26                                 <li><a href="<?php echo esc_url( home_url( 'tags/full-site-editing/' ) ); ?>" data-tag="full-site-editing" <?php if ( 'full-site-editing' == get_query_var('tag') ) { echo 'class="current"'; } ?>><?php _ex( 'Block Themes', 'themes filter', 'wporg-themes' ); ?></a></li>
    27                                 <?php if ( is_user_logged_in() ) { ?>
    28                                         <li><a href="<?php echo esc_url( home_url( 'browse/favorites/' ) ); ?>" data-sort="favorites" <?php if ( 'favorites' == get_query_var('browse') ) { echo 'class="current"'; } ?>><?php _ex( 'Favorites', 'themes', 'wporg-themes' ); ?></a></li>
    29                                 <?php } ?>
     53                                <?php
     54                                foreach ( $menu_items as $item ) {
     55                                        $data_attrs = array();
     56                                        foreach ( array( 'data-sort', 'data-tag', 'data-model' ) as $key ) {
     57                                                if ( isset( $item[ $key ] ) ) {
     58                                                        $data_attrs[] = $key . '="' . esc_attr( $item[ $key ] ) . '"';
     59                                                }
     60                                        }
     61                                        printf(
     62                                                '<li><a href="%1$s" %2$s class="filter-tab %3$s">%4$s</a></li>',
     63                                                esc_url( $item['href'] ),
     64                                                implode( ' ', $data_attrs ),
     65                                                $item['is-current'] ? 'current' : '',
     66                                                esc_html( $item['label'] )
     67                                        );
     68                                }
     69                                ?>
     70                                <li style="flex-grow:1;"></li>
     71                                <?php if ( is_user_logged_in() ) : ?>
     72                                        <li>
     73                                                <a
     74                                                        href="<?php echo esc_url( home_url( 'browse/favorites/' ) ); ?>"
     75                                                        data-sort="favorites"
     76                                                        class="filter-tab <?php echo ( 'favorites' == get_query_var( 'browse' ) ) ? 'current' : ''; ?>"
     77                                                >
     78                                                        <?php _ex( 'Favorites', 'themes', 'wporg-themes' ); ?>
     79                                                </a>
     80                                        </li>
     81                                <?php endif; ?>
     82                                <li>
     83                                        <a class="drawer-toggle" href="#">
     84                                                <span class="drawer-text"><?php _e( 'Feature Filter', 'wporg-themes' ); ?></span>
     85                                        </a>
     86                                </li>
    3087                        </ul>
    31 
    32                         <a class="drawer-toggle" href="#">
    33                                 <span class="drawer-text"><?php _e( 'Feature Filter', 'wporg-themes' ); ?></span>
    34                         </a>
    35 
    36                         <div class="search-form"></div>
    3788
    3889                        <div class="filter-drawer">
     
    67118                        <div class="themes">
    68119                                <?php
    69                                 if ( get_query_var('name') && !is_404() ) {
     120                                if ( get_query_var( 'name' ) && ! is_404() ) {
    70121                                        while ( have_posts() ) {
    71122                                                the_post();
Note: See TracChangeset for help on using the changeset viewer.