From 45832588a5a620ca43ef94c910528dd96e32074d Mon Sep 17 00:00:00 2001 From: Jason Moon Date: Mon, 15 Nov 2021 17:53:43 -0700 Subject: [PATCH 1/9] Migrate template tags class --- .../search/src/class-template-tags.php} | 80 ++++++++++--------- .../modules/search/class.jetpack-search.php | 1 - .../jetpack/modules/widgets/search.php | 19 +++-- 3 files changed, 55 insertions(+), 45 deletions(-) rename projects/{plugins/jetpack/modules/search/class.jetpack-search-template-tags.php => packages/search/src/class-template-tags.php} (80%) 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..144357672018f 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(); + $filters = Jetpack_Search::instance( $blog_id )->get_filters(); } if ( is_null( $post_types ) ) { @@ -40,12 +43,12 @@ 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. + $active_buckets = Jetpack_Search::instance( $blog_id )->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 +68,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 +79,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). + * @param string $blog_id Blog id. + * @param array $filters The available filters for the current query. */ - public static function render_instant_filters( $filters = null, $post_types = null ) { + public static function render_instant_filters( $blog_id, $filters = null ) { if ( is_null( $filters ) ) { - $filters = Jetpack_Search::instance()->get_filters(); + $filters = Jetpack_Search::instance( $blog_id )->get_filters(); } foreach ( (array) $filters as $filter ) { @@ -133,7 +134,7 @@ public static function render_filter( $filter, $default_post_types ) {