Making WordPress.org

Changeset 1331


Ignore:
Timestamp:
02/25/2015 11:26:57 PM (10 years ago)
Author:
obenland
Message:

WP.org Themes: Make commercial theme shops the content type that they are.

See #745.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r1321 r1331  
    6969    }
    7070
     71    if ( ! post_type_exists( 'theme_shop' ) ) {
     72        register_post_type( 'theme_shop', array(
     73            'labels'              => array(
     74                'name'               => __( 'Theme Shops', 'wporg-themes' ),
     75                'singular_name'      => __( 'Theme Shop', 'wporg-themes' ),
     76                'add_new'            => __( 'Add New', 'wporg-themes' ),
     77                'add_new_item'       => __( 'Add New Theme Shop', 'wporg-themes' ),
     78                'edit_item'          => __( 'Edit Theme Shop', 'wporg-themes' ),
     79                'new_item'           => __( 'New Theme Shop', 'wporg-themes' ),
     80                'view_item'          => __( 'View Theme Shop', 'wporg-themes' ),
     81                'search_items'       => __( 'Search Theme Shops', 'wporg-themes' ),
     82                'not_found'          => __( 'No Theme Shops found', 'wporg-themes' ),
     83                'not_found_in_trash' => __( 'No Theme Shops found in Trash', 'wporg-themes' ),
     84                'parent_item_colon'  => __( 'Parent Theme Shop:', 'wporg-themes' ),
     85                'menu_name'          => __( 'Theme Shops', 'wporg-themes' ),
     86            ),
     87            'supports'            => array( 'title', 'editor', 'author', 'custom-fields' ),
     88            'public'              => true,
     89            'show_in_nav_menus'   => false,
     90            'exclude_from_search' => true,
     91            'menu_icon'           => 'dashicons-businessman',
     92        ) );
     93    }
     94
    7195    // Add the browse/* views
    7296    add_rewrite_tag( '%browse%', '(featured|popular|new)' );
     
    83107 */
    84108function wporg_themes_set_up_query( $wp_query ) {
    85     if ( is_admin() || in_array( $wp_query->get( 'pagename' ), array( 'upload', 'commercial', 'getting-started' ) ) || 'nav_menu_item' == $wp_query->get( 'post_type' ) ) {
     109    if ( is_admin() || in_array( $wp_query->get( 'pagename' ), array( 'upload', 'commercial', 'getting-started' ) ) || in_array( $wp_query->get( 'post_type' ), array( 'nav_menu_item', 'theme_shop' ) ) ) {
    86110        return $wp_query;
    87111    }
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/page-commercial.php

    r1237 r1331  
    66 */
    77
    8 
    9 /**
    10  * Filter to get an array of data for theme shops to be listed.
    11  *
    12  * Expected structure for each element in the commercial theme shops array:
    13  *
    14  * array(
    15  *    'name'        => '', // Theme shop name.
    16  *    'url'         => '', // Company URL.
    17  *    'description' => "", // Haiku.
    18  *    'user_id'     => '', // User ID of the WordPress.org user associated with the theme shop.
    19  *    'image'       => '', // Theme shop site screenshot URL. Optional; only if overriding default, automatic image retrieval.
    20  * )
    21  *
    22  * @param array $commercial Array of commercial theme shops data array. Default empty array.
    23  */
    24 $commercial = (array) apply_filters( 'wporg_themes_commercial', array() );
    25 
    26 shuffle( $commercial );
     8$theme_shops = new WP_Query( array(
     9    'post_type'      => 'theme_shop',
     10    'posts_per_page' => -1,
     11    'orderby'        => 'rand',
     12) );
    2713
    2814get_header();
     
    5238                    <div class="theme-browser content-filterable">
    5339                        <div class="themes">
    54                             <?php foreach ( $commercial as $theme ) : ?>
    55                                 <article id="post-<?php echo sanitize_title_with_dashes( $theme['name'] ); ?>" class="theme hentry">
    56                                     <div class="theme-screenshot">
    57                                         <img src="<?php echo esc_url( '//s0.wp.com/mshots/v1/' . urlencode( $theme['url'] ) . '?w=572' ); ?>" alt="">
    58                                     </div>
    59                                     <a class="more-details url" href="<?php echo esc_url( $theme['url'] ); ?>" rel="bookmark"><?php echo nl2br( $theme['description'] ); ?></a>
    60                                     <h3 class="theme-name entry-title"><?php echo $theme['name']; ?></h3>
    61                                 </article>
    62                             <?php endforeach; ?>
     40                            <?php
     41                                while ( $theme_shops->have_posts() ) :
     42                                    $theme_shops->the_post();
     43                            ?>
     44                            <article id="post-<?php the_ID(); ?>" <?php post_class( array( 'theme', 'hentry' ) ); ?>>
     45                                <div class="theme-screenshot">
     46                                    <img src="<?php echo esc_url( '//s0.wp.com/mshots/v1/' . urlencode( post_custom( 'url' ) ) . '?w=572' ); ?>" alt="">
     47                                </div>
     48                                <a class="more-details url" href="<?php echo esc_url( post_custom( 'url' ) ); ?>" rel="bookmark"><?php the_content(); ?></a>
     49                                <h3 class="theme-name entry-title"><?php the_title(); ?></h3>
     50                            </article>
     51                            <?php
     52                                endwhile;
     53                                wp_reset_postdata();
     54                            ?>
    6355                        </div>
    6456                    </div>
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/style.css

    r1313 r1331  
    815815.commercial .theme .more-details {
    816816    font-size: 13px;
    817      top: 23%;
    818      right: 5%;
    819      left: 5%;
     817    top: 23%;
     818    right: 5%;
     819    left: 5%;
     820}
     821
     822.commercial .theme .more-details p {
     823    margin: 0;
    820824}
    821825
Note: See TracChangeset for help on using the changeset viewer.