Making WordPress.org

Changeset 14764


Ignore:
Timestamp:
03/27/2026 06:23:56 AM (5 days ago)
Author:
dd32
Message:

Plugin Directory: Rest API: Allow direct REST API queries to use Elastic Search.

This optimization targetting ?s= is only supposed to be on /plugins/?s=... not /plugins/wp-json/.../?s=...
This change has no effect upon api.wordpress.org and expected uses of the directory, but enables simpler testing of endpoints.

File:
1 edited

Legend:

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

    r14687 r14764  
    4141     */
    4242    private function __construct() {
    43         if ( isset( $_GET['s'] ) ) {
    44             return false;
     43        if (
     44            // Don't load Jetpack Search if it's a front-end ?s=... query, as we'll be redirecting away anyway.
     45            isset( $_GET['s'] ) &&
     46            // Running super-early, before wp_is_serving_rest_request() returns truthful.
     47            ! str_contains( $_SERVER['REQUEST_URI'] ?? '', '/wp-json/' ) &&
     48            // Never return early in an API context.
     49            ( ! defined( 'WPORG_IS_API' ) || ! WPORG_IS_API )
     50        ) {
     51            return;
    4552        }
    4653
    4754        add_action( 'init', array( $this, 'init' ) );
    48 
    49         return false;
    5055    }
    5156
Note: See TracChangeset for help on using the changeset viewer.