WordPress.org

Making WordPress.org


Ignore:
Timestamp:
06/20/2016 01:32:51 PM (2 years ago)
Author:
dd32
Message:

Plugin Directory: Fix the query_plugins API endpoint to use Jetpack Search.

See #1584

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-query-plugins.php

    r3289 r3501  
    3636     */
    3737    function query( $request ) {
     38        global $wp_query;
     39
    3840        $response = array(
    3941            'info' => array(
     
    5355        $query['post_type'] = 'plugin';
    5456
    55         $wp_query = new WP_Query( $query );
     57        // Use the main query so that is_main_query() is triggered for the filters.
     58        $wp_query->query( $query );
    5659
    5760        $response['info']['page']    = (int) $wp_query->get_query_var( 'paged' ) ?: 1;
     
    6063
    6164        foreach ( $wp_query->posts as $post ) {
    62             $response['plugins'][] = $post->post_name;
     65            $response['plugins'][] = $post->post_name ?: get_post( $post->ID )->post_name;
    6366        }
    6467
Note: See TracChangeset for help on using the changeset viewer.