WordPress.org

Making WordPress.org

Changeset 9051


Ignore:
Timestamp:
07/17/2019 07:14:19 AM (3 months ago)
Author:
tellyworth
Message:

Plugin dir: add an endpoint to search by block name.

The implementation is temporary, will be replaced with ElasticSearch. This should work as a temporary measure while developing the block install code.

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

Legend:

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

    r6287 r9051  
    6060        }
    6161
     62        // Temporary hacky block search
     63        if ( $request->get_param( 'block' ) ) {
     64            global $wpdb;
     65            $block_search = $request->get_param( 'block' );
     66            $meta_query = array(
     67                'relation' => 'OR',
     68                array(
     69                    'key' => 'block_name',
     70                    'value' => '^' . $block_search,
     71                    'compare' => 'RLIKE',
     72                ),
     73                array(
     74                    'key' => 'block_name',
     75                    'value' => '/' . $block_search, // search following the slash
     76                    'compare' => 'RLIKE',
     77                ),
     78            );
     79
     80            // Limit the search to the Block section
     81            $query[ 'meta_query' ] = $meta_query;
     82            $query[ 'tax_query' ] = array(
     83                array(
     84                    'taxonomy' => 'plugin_section',
     85                    'field' => 'slug',
     86                    'terms' => 'block',
     87                )
     88            );
     89        }
     90
    6291        if ( ! $query ) {
    6392            return $response;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/standalone/class-plugins-info-api-request.php

    r6496 r9051  
    216216                $query['author_name'] = $this->args->author;
    217217            }
     218
     219            // Block
     220            if ( ! empty( $this->args->block ) ) {
     221                $query['block'] = $this->args->block;
     222            }
    218223        }
    219224
Note: See TracChangeset for help on using the changeset viewer.