From e2cf6f27a2302be1477afbb79536581a1fb92cbb Mon Sep 17 00:00:00 2001 From: Michael Beckwith Date: Tue, 29 Nov 2022 19:00:40 -0600 Subject: [PATCH 1/6] add a variable filter for the posts index ID value --- includes/indices/class-algolia-posts-index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/indices/class-algolia-posts-index.php b/includes/indices/class-algolia-posts-index.php index 91971be6..5e172a20 100644 --- a/includes/indices/class-algolia-posts-index.php +++ b/includes/indices/class-algolia-posts-index.php @@ -412,7 +412,7 @@ private function update_post_records( WP_Post $post, array $records ) { * @return string */ public function get_id() { - return 'posts_' . $this->post_type; + return apply_filters( "algolia_posts_{ $this->post_type }_index_id", 'posts_' . $this->post_type ); } /** From 01157edfe6f0fd28a639ebe215ca0fad7b8653e0 Mon Sep 17 00:00:00 2001 From: Michael Beckwith Date: Tue, 29 Nov 2022 19:00:56 -0600 Subject: [PATCH 2/6] add a variable filter for the searchable posts index ID value --- includes/indices/class-algolia-searchable-posts-index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/indices/class-algolia-searchable-posts-index.php b/includes/indices/class-algolia-searchable-posts-index.php index 16ed0441..ac1d623f 100644 --- a/includes/indices/class-algolia-searchable-posts-index.php +++ b/includes/indices/class-algolia-searchable-posts-index.php @@ -393,7 +393,7 @@ private function update_post_records( WP_Post $post, array $records ) { * @return string */ public function get_id() { - return 'searchable_posts'; + return apply_filters( 'algolia_searchable_posts_index_id', 'searchable_posts' ); } /** From cec8dc07b0804db1b05b9130f74617215617176c Mon Sep 17 00:00:00 2001 From: Michael Beckwith Date: Tue, 29 Nov 2022 19:01:11 -0600 Subject: [PATCH 3/6] add a variable filter for the taxonomy index ID value --- includes/indices/class-algolia-terms-index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/indices/class-algolia-terms-index.php b/includes/indices/class-algolia-terms-index.php index 4aeadc5b..406f034b 100644 --- a/includes/indices/class-algolia-terms-index.php +++ b/includes/indices/class-algolia-terms-index.php @@ -185,7 +185,7 @@ protected function get_synonyms() { * @return string */ public function get_id() { - return 'terms_' . $this->taxonomy; + return apply_filters( "algolia_terms_{ $this->taxonomy }_index_id", 'terms_' . $this->taxonomy ); } From 2b814bcf16c52ed7bda081c2c1bb3193f8b0eba2 Mon Sep 17 00:00:00 2001 From: Michael Beckwith Date: Tue, 29 Nov 2022 19:01:21 -0600 Subject: [PATCH 4/6] add a variable filter for the users index ID value --- includes/indices/class-algolia-users-index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/indices/class-algolia-users-index.php b/includes/indices/class-algolia-users-index.php index 9dfc5a70..8d047f78 100644 --- a/includes/indices/class-algolia-users-index.php +++ b/includes/indices/class-algolia-users-index.php @@ -175,7 +175,7 @@ protected function get_synonyms() { * @return string */ public function get_id() { - return 'users'; + return apply_filters( "algolia_users_index_id", 'users' ); } From 0a57611be27fcc9156b6376e881d3c6a19753edf Mon Sep 17 00:00:00 2001 From: Michael Beckwith Date: Mon, 5 Dec 2022 19:21:04 -0600 Subject: [PATCH 5/6] we need to pass the same filter for this get_index to prevent null return --- includes/admin/class-algolia-admin-page-native-search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/class-algolia-admin-page-native-search.php b/includes/admin/class-algolia-admin-page-native-search.php index 89a1621c..292e290f 100644 --- a/includes/admin/class-algolia-admin-page-native-search.php +++ b/includes/admin/class-algolia-admin-page-native-search.php @@ -207,7 +207,7 @@ public function display_errors() { $maybe_get_page = filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING ); - $searchable_posts_index = $this->plugin->get_index( 'searchable_posts' ); + $searchable_posts_index = $this->plugin->get_index( apply_filters( 'algolia_searchable_posts_index_id', 'searchable_posts' ) ); if ( false === $searchable_posts_index->is_enabled() && ( ! empty( $maybe_get_page ) ) && $maybe_get_page === $this->slug ) { /* translators: placeholder contains the link to the indexing page. */ $message = sprintf( __( 'Searchable posts index needs to be checked on the Algolia: Indexing page for the search results to be powered by Algolia.', 'wp-search-with-algolia' ), esc_url( admin_url( 'admin.php?page=algolia-indexing' ) ) ); From cd59cbf900ad0dd9c1bb6ccd3842dd77b851c0a3 Mon Sep 17 00:00:00 2001 From: Michael Beckwith Date: Mon, 5 Dec 2022 19:46:47 -0600 Subject: [PATCH 6/6] spaces do not render the contents like expected --- includes/indices/class-algolia-posts-index.php | 2 +- includes/indices/class-algolia-terms-index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/indices/class-algolia-posts-index.php b/includes/indices/class-algolia-posts-index.php index 5e172a20..4438e8bc 100644 --- a/includes/indices/class-algolia-posts-index.php +++ b/includes/indices/class-algolia-posts-index.php @@ -412,7 +412,7 @@ private function update_post_records( WP_Post $post, array $records ) { * @return string */ public function get_id() { - return apply_filters( "algolia_posts_{ $this->post_type }_index_id", 'posts_' . $this->post_type ); + return apply_filters( "algolia_posts_{$this->post_type}_index_id", 'posts_' . $this->post_type ); } /** diff --git a/includes/indices/class-algolia-terms-index.php b/includes/indices/class-algolia-terms-index.php index 406f034b..e8f2d5e0 100644 --- a/includes/indices/class-algolia-terms-index.php +++ b/includes/indices/class-algolia-terms-index.php @@ -185,7 +185,7 @@ protected function get_synonyms() { * @return string */ public function get_id() { - return apply_filters( "algolia_terms_{ $this->taxonomy }_index_id", 'terms_' . $this->taxonomy ); + return apply_filters( "algolia_terms_{$this->taxonomy}_index_id", 'terms_' . $this->taxonomy ); }