WordPress.org

Making WordPress.org

Changeset 11243


Ignore:
Timestamp:
09/17/2021 04:01:02 AM (2 months ago)
Author:
dd32
Message:

Theme Directory: Rejig the query modifications for when to include delisted themes.

This reimplements [11239] after it caused the API to fail to return correctly for non-delisted themes.

See #5906.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory
Files:
2 edited

Legend:

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

    r11199 r11243  
    477477            // get_post_by_slug()
    478478            $themes = get_posts( array(
    479                 'name'      => $this->request->slug,
    480                 'post_type' => 'repopackage',
    481                 'post_status' => 'publish,delist',
     479                'name'        => $this->request->slug,
     480                'post_type'   => 'repopackage',
     481                'post_status' => 'publish', // delist will be added by query-modifications.
    482482            ) );
    483483
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php

    r11240 r11243  
    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 ( empty( $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'] = explode( ',', $query->query_vars['post_status'] );
     47        }
     48
     49        $query->query_vars['post_status'][] = 'delist';
     50    }
    4951
    5052    switch ( $query->query_vars['browse'] ) {
Note: See TracChangeset for help on using the changeset viewer.