WordPress.org

Making WordPress.org

Changeset 11239


Ignore:
Timestamp:
09/15/2021 07:54:06 AM (3 months ago)
Author:
dd32
Message:

Theme Directory: Hide delisted themes from everything, except when certain query parameters are set.

This forces delisted themes ot only be on singular queries, and author archives for easier debugging.

File:
1 edited

Legend:

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

    r11227 r11239  
    1313        return;
    1414    }
     15
    1516    // Themes are never via pagename
    1617    if ( !empty( $query->query_vars['pagename'] ) ) {
     
    2324    }
    2425
    25     // From now on, always query themes.
    26     $query->query_vars['post_type'] = 'repopackage';
     26    // From now on, always query published themes.
     27    $query->query_vars['post_type']   = 'repopackage';
     28    if ( ! isset( $query->query_vars['post_status'] ) ) {
     29        $query->query_vars['post_status'] = 'publish';
     30    }
    2731    if ( ! isset( $query->query_vars['browse'] ) ) {
    2832        $query->query_vars['browse'] = '';
     
    3438    }
    3539
    36     // eliminate draft posts from showing up in the directory
     40    // Delisted items should be available on singular / author archives.
    3741    if (
    38         (
    39             ! isset( $query->query_vars['post_status'] ) ||
    40             'publish' === $query->query_vars['post_status']
    41         ) &&
    42         ! $query->is_search()
     42        ! empty( $query->query_vars['name'] ) ||
     43        ! empty( $query->query_vars['author_name'] )
    4344    ) {
    44         $query->query_vars['post_status'] = array(
    45             'publish',
    46             'delist',
    47         );
    48     }
     45        if ( ! is_array( $query->query_vars['post_status'] ) ) {
     46            $query->query_vars['post_status'] = array(
     47                $query->query_vars['post_status']
     48            );
     49        }
     50
     51        $query->query_vars['post_status'][] = 'delist';
     52    }
    4953
    5054    switch ( $query->query_vars['browse'] ) {
Note: See TracChangeset for help on using the changeset viewer.