diff --git a/projects/packages/search/changelog/update-move-more-search-helpers-to-package b/projects/packages/search/changelog/update-move-more-search-helpers-to-package new file mode 100644 index 0000000000000..6a2a0b90e70c9 --- /dev/null +++ b/projects/packages/search/changelog/update-move-more-search-helpers-to-package @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Migrate additional helper classes to package diff --git a/projects/plugins/jetpack/modules/search/class-jetpack-search-settings.php b/projects/packages/search/src/class-settings.php similarity index 89% rename from projects/plugins/jetpack/modules/search/class-jetpack-search-settings.php rename to projects/packages/search/src/class-settings.php index 2298aa84716f7..ec4a9ed8ea54f 100644 --- a/projects/plugins/jetpack/modules/search/class-jetpack-search-settings.php +++ b/projects/packages/search/src/class-settings.php @@ -2,9 +2,11 @@ /** * Jetpack Search Overlay Settings * - * @package automattic/jetpack + * @package automattic/jetpack-search */ +namespace Automattic\Jetpack\Search; + // Exit if file is accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; @@ -12,15 +14,11 @@ /** * Class to initialize search settings on the site. - * - * @since 8.3.0 */ -class Jetpack_Search_Settings { +class Settings { /** * Class initialization. - * - * @since 8.3.0 */ public function __construct() { add_action( 'admin_init', array( $this, 'settings_register' ) ); @@ -34,7 +32,7 @@ public function __construct() { */ public function settings_register() { // NOTE: This contains significant code overlap with class-jetpack-search-customize. - $setting_prefix = Automattic\Jetpack\Search\Options::OPTION_PREFIX; + $setting_prefix = Options::OPTION_PREFIX; $settings = array( array( $setting_prefix . 'color_theme', 'string', 'light' ), array( $setting_prefix . 'result_format', 'string', 'minimal' ), diff --git a/projects/plugins/jetpack/modules/search/class.jetpack-search-template-tags.php b/projects/packages/search/src/class-template-tags.php similarity index 80% rename from projects/plugins/jetpack/modules/search/class.jetpack-search-template-tags.php rename to projects/packages/search/src/class-template-tags.php index befe9ba83aba6..bc40103543334 100644 --- a/projects/plugins/jetpack/modules/search/class.jetpack-search-template-tags.php +++ b/projects/packages/search/src/class-template-tags.php @@ -1,13 +1,15 @@ get_filters(); + // TODO: Must be migrated to use Classic_Search once the migration is underway. + $filters = \Jetpack_Search::instance()->get_filters(); } if ( is_null( $post_types ) ) { @@ -40,12 +43,13 @@ public static function render_available_filters( $filters = null, $post_types = */ $active_post_types = array(); if ( Helper::post_types_differ_searchable( $post_types ) ) { - // get the active filter buckets from the query - $active_buckets = Jetpack_Search::instance()->get_active_filter_buckets(); + // get the active filter buckets from the query. + // TODO: Must be migrated to use Classic_Search once the migration is underway. + $active_buckets = \Jetpack_Search::instance()->get_active_filter_buckets(); $post_types_differ_query = Helper::post_types_differ_query( $post_types ); // remove any post_type filters from display if the current query - // already specifies to match all post types + // already specifies to match all post types. if ( ! $post_types_differ_query ) { $active_buckets = array_filter( $active_buckets, array( __CLASS__, 'is_not_post_type_filter' ) ); } @@ -65,7 +69,7 @@ public static function render_available_filters( $filters = null, $post_types = } foreach ( (array) $filters as $filter ) { - if ( 'post_type' == $filter['type'] ) { + if ( 'post_type' === $filter['type'] ) { self::render_filter( $filter, $post_types ); } else { self::render_filter( $filter, $active_post_types ); @@ -76,14 +80,12 @@ public static function render_available_filters( $filters = null, $post_types = /** * Renders filters for instant search. * - * @since 8.3.0 - * * @param array $filters The available filters for the current query. - * @param array $post_types An array of post types (ignored). */ - public static function render_instant_filters( $filters = null, $post_types = null ) { + public static function render_instant_filters( $filters = null ) { if ( is_null( $filters ) ) { - $filters = Jetpack_Search::instance()->get_filters(); + // TODO: Must be migrated to use Classic_Search once the migration is underway. + $filters = \Jetpack_Search::instance()->get_filters(); } foreach ( (array) $filters as $filter ) { @@ -133,7 +135,7 @@ public static function render_filter( $filter, $default_post_types ) {