Making WordPress.org

Changeset 12158


Ignore:
Timestamp:
10/31/2022 01:20:46 AM (19 months ago)
Author:
dd32
Message:

Plugin Directory: Search: Prepare for a Jetpack upgrade.

Jetpack moved where the search files are stored, causing the existing code here to not work as expected.

Props kraftbj, dd32.
Closes https://github.com/WordPress/wordpress.org/pull/103.
See #6551.

File:
1 edited

Legend:

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

    r11650 r12158  
    6767
    6868            // add_filter( 'jetpack_search_abort', array( $this, 'log_jetpack_search_abort' ) );
    69 
    70             require_once( ABSPATH . 'wp-content/plugins/jetpack/modules/search/class.jetpack-search.php' );
    71             require_once( ABSPATH . 'wp-content/plugins/jetpack/modules/search/class.jetpack-search-helpers.php' );
     69           
    7270            // $es_query_args = apply_filters( 'jetpack_search_es_query_args', $es_query_args, $query );
    73             //
     71
    7472            add_filter( 'jetpack_search_es_wp_query_args', array( $this, 'jetpack_search_es_wp_query_args' ), 10, 2 );
    75             add_filter( 'jetpack_search_es_query_args', array( $this, 'jetpack_search_es_query_args' ), 10, 2 );
    76 
    77             \Jetpack_Search::instance()->setup();
     73            add_filter( 'jetpack_search_es_query_args', array( $this, 'jetpack_search_es_query_args' ), 10, 2 );           
     74
     75            // Load Jetpack Search.
     76            include_once WP_PLUGIN_DIR . '/jetpack/vendor/autoload_packages.php';
     77
     78            if ( class_exists( '\Automattic\Jetpack\Search\Classic_Search' ) ) {
     79                // New Jetpack
     80                \Automattic\Jetpack\Search\Classic_Search::instance();
     81
     82            } else {
     83                // Old(er) Jetpack, load the classic search module, Temporarily.
     84               
     85                include_once WP_PLUGIN_DIR . '/jetpack/modules/search/class.jetpack-search.php';
     86                include_once WP_PLUGIN_DIR . '/jetpack/modules/search/class.jetpack-search-helpers.php';
     87
     88                \Jetpack_Search::instance()->setup();
     89            }
     90
    7891        }
    7992
Note: See TracChangeset for help on using the changeset viewer.