Making WordPress.org

Changeset 11292


Ignore:
Timestamp:
10/22/2021 07:16:10 PM (3 months ago)
Author:
ryelle
Message:

Plugin Directory: Bypass the block plugin search when searching for core blocks.

If a core block (core/*) is disabled or missing from the editor, the missing block handler will try to look for it on WordPress.org, but no plugin should provide core blocks. This will short-circuit out of the block search and return zero results, to avoid issues if a plugin claims to provide the core block.

See #5910.

File:
1 edited

Legend:

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

    r11218 r11292  
    8686         * - `slug:example-plugin` will only return THAT plugin, nothing else.
    8787         * - `block:example-plugin/my-block` will return Block directory plugins, or
    88          *    regular plugins that supply that block if there were no matches in the block directory.
    89          *
     88         *   regular plugins that supply that block if there were no matches in the block directory.
     89         * - `block:core/...` will short-circuit out and return an empty array, since no plugin
     90         *   should provide core blocks.
     91         *
    9092         * TODO: This might have been useful as a general search filter for the website too.
    9193         */
    92         if ( !empty( $query['s'] ) ) {
     94        if ( ! empty( $query['s'] ) ) {
     95            if ( 'block:core/' === substr( $query['s'], 0, 11 ) ) {
     96                return $response;
     97            }
     98
    9399            if ( 'slug:' === substr( $query['s'], 0, 5 ) ) {
    94100                $query['name'] = substr( $query['s'], 5 );
    95 
    96                 unset( $query['s'] );
    97101            }
    98102
    99             if ( isset( $query['s'] ) && 'block:' === substr( $query['s'], 0, 6 ) ) {
     103            if ( 'block:' === substr( $query['s'], 0, 6 ) ) {
    100104                $query['meta_query'][] = [
    101105                    'key' => 'block_name',
     
    111115                // Prioritise block plugins, but try again without the restriction.
    112116                $try_again_without_tax_query = true;
    113 
    114                 unset( $query['s'], $query['block_search'] );
    115117            }
    116118
     119            unset( $query['s'], $query['block_search'] );
    117120        }
    118121
Note: See TracChangeset for help on using the changeset viewer.