Making WordPress.org


Ignore:
Timestamp:
02/03/2015 07:18:37 PM (12 years ago)
Author:
obenland
Message:

WP.org Themes: Bail early if we're not looking for repopackages.

Once we have all themes synced over, this needs to be improved to work properly
with the various routes. Needed for Google parsing and parity between server
and API output.

See r1211, #745.

File:
1 edited

Legend:

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

    r1156 r1212  
    6161 */
    6262function wporg_themes_set_up_query( $query ) {
    63         if ( ! is_admin() && ! in_array( $query->query_vars['pagename'], array( 'upload', 'commercial' ) ) ) {
    64 
    65                 $query->set( 'post_type', 'repopackage' );
    66 
    67                 $args = array(
    68                         'per_page' => 15,
    69                         'fields'   => array(
    70                                 'description'  => true,
    71                                 'sections'     => false,
    72                                 'tested'       => true,
    73                                 'requires'     => true,
    74                                 'rating'       => true,
    75                                 'downloaded'   => true,
    76                                 'downloadlink' => true,
    77                                 'last_updated' => true,
    78                                 'homepage'     => true,
    79                                 'tags'         => true,
    80                                 'num_ratings'  => true,
    81                                 'parent'       => true,
    82                         ),
    83                 );
    84 
    85                 if ( $query->query_vars['tag'] ) {
    86                         $args['tag'][] = $query->query_vars['tag'];
     63        if ( is_admin() || in_array( $query->query_vars['pagename'], array( 'upload', 'commercial' ) ) || 'nav_menu_item' == $query->get( 'post_type' ) ) {
     64                return $query;
     65        }
     66
     67        $query->set( 'post_type', 'repopackage' );
     68
     69        $args = array(
     70                'per_page' => 15,
     71                'fields'   => array(
     72                        'description'  => true,
     73                        'sections'     => false,
     74                        'tested'       => true,
     75                        'requires'     => true,
     76                        'rating'       => true,
     77                        'downloaded'   => true,
     78                        'downloadlink' => true,
     79                        'last_updated' => true,
     80                        'homepage'     => true,
     81                        'tags'         => true,
     82                        'num_ratings'  => true,
     83                        'parent'       => true,
     84                ),
     85        );
     86
     87        if ( $query->query_vars['tag'] ) {
     88                $args['tag'][] = $query->query_vars['tag'];
     89        }
     90        elseif ( $query->query_vars['author_name'] ) {
     91                $args['author'] = $query->query_vars['author_name'];
     92        }
     93        elseif ( $query->query_vars['pagename'] ) {
     94                $slugs = explode( '/', $query->query_vars['pagename'] );
     95
     96                if ( count( $slugs ) > 1 && 'browse' == $slugs[0] ) {
     97                        $args['browse'] = $slugs[1];
     98                } else {
     99                        $args['theme'] = $slugs[0];
    87100                }
    88                 elseif ( $query->query_vars['author_name'] ) {
    89                         $args['author'] = $query->query_vars['author_name'];
    90                 }
    91                 elseif ( $query->query_vars['pagename'] ) {
    92                         $slugs = explode( '/', $query->query_vars['pagename'] );
    93 
    94                         if ( count( $slugs ) > 1 && 'browse' == $slugs[0] ) {
    95                                 $args['browse'] = $slugs[1];
    96                         } else {
    97                                 $args['theme'] = $slugs[0];
    98                         }
    99                 }
    100                 else {
    101                         $args['browse'] = 'featured';
    102                 }
    103 
    104                 if ( ! function_exists( 'themes_api' ) ) {
    105                         include ABSPATH . 'wp-admin/includes/theme.php';
    106                 }
    107                 $GLOBALS['themes'] = themes_api( 'query_themes', $args );
    108         }
     101        }
     102        else {
     103                $args['browse'] = 'featured';
     104        }
     105
     106        if ( ! function_exists( 'themes_api' ) ) {
     107                include ABSPATH . 'wp-admin/includes/theme.php';
     108        }
     109        $GLOBALS['themes'] = themes_api( 'query_themes', $args );
    109110
    110111        return $query;
Note: See TracChangeset for help on using the changeset viewer.