From 66228f54e4dde91e3fd1aacfd11e6d7dcf3522a8 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 30 Jan 2025 18:38:23 +0500 Subject: [PATCH 1/4] Fix: Function _load_textdomain_just_in_time was called incorrectly --- .../Feature/BooleanSearchOperators.php | 12 +++++++++-- includes/classes/Feature/CoAuthorsPlus.php | 12 +++++++++-- includes/classes/Feature/ElasticPressLabs.php | 12 +++++++++-- includes/classes/Feature/ExternalContent.php | 12 +++++++++-- includes/classes/Feature/MetaKeyPattern.php | 12 +++++++++-- includes/classes/Feature/SearchAlgorithm.php | 12 +++++++++-- includes/classes/Feature/Users.php | 20 +++++++++++++------ .../Feature/WooCommerceSubscriptionSearch.php | 12 +++++++++-- 8 files changed, 84 insertions(+), 20 deletions(-) diff --git a/includes/classes/Feature/BooleanSearchOperators.php b/includes/classes/Feature/BooleanSearchOperators.php index 97c50dc..e0c4adc 100644 --- a/includes/classes/Feature/BooleanSearchOperators.php +++ b/includes/classes/Feature/BooleanSearchOperators.php @@ -36,8 +36,6 @@ class BooleanSearchOperators extends Feature { public function __construct() { $this->slug = 'boolean_search_operators'; - $this->title = esc_html__( 'Boolean Search Operators', 'elasticpress-labs' ); - $this->requires_install_reindex = false; $this->default_settings = [ 'active' => false, @@ -46,6 +44,16 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 2.4.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Boolean Search Operators', 'elasticpress-labs' ); + } + /** * Setup Feature Functionality */ diff --git a/includes/classes/Feature/CoAuthorsPlus.php b/includes/classes/Feature/CoAuthorsPlus.php index 66875c1..46562ba 100644 --- a/includes/classes/Feature/CoAuthorsPlus.php +++ b/includes/classes/Feature/CoAuthorsPlus.php @@ -46,8 +46,6 @@ class CoAuthorsPlus extends Feature { public function __construct() { $this->slug = 'co_authors_plus'; - $this->title = esc_html__( 'Co-Authors Plus', 'elasticpress-labs' ); - $this->requires_install_reindex = true; $protected_content_feature = Features::factory()->get_registered_feature( 'protected_content' ); @@ -59,6 +57,16 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 2.4.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Co-Authors Plus', 'elasticpress-labs' ); + } + /** * Setup all feature filters * diff --git a/includes/classes/Feature/ElasticPressLabs.php b/includes/classes/Feature/ElasticPressLabs.php index 79dfa67..dd7f3cb 100644 --- a/includes/classes/Feature/ElasticPressLabs.php +++ b/includes/classes/Feature/ElasticPressLabs.php @@ -34,14 +34,22 @@ class ElasticPressLabs extends \ElasticPress\Feature { public function __construct() { $this->slug = 'elasticpress_labs'; - $this->title = esc_html__( 'ElasticPress Labs', 'elasticpress-labs' ); - $this->requires_install_reindex = false; $this->default_settings = []; parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 2.4.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'ElasticPress Labs', 'elasticpress-labs' ); + } + /** * Output feature box summary. */ diff --git a/includes/classes/Feature/ExternalContent.php b/includes/classes/Feature/ExternalContent.php index 6f59f9c..71207c5 100644 --- a/includes/classes/Feature/ExternalContent.php +++ b/includes/classes/Feature/ExternalContent.php @@ -33,14 +33,22 @@ class ExternalContent extends Feature { public function __construct() { $this->slug = 'external_content'; + parent::__construct(); + } + + /** + * Sets i18n strings. + * + * @return void + * @since 2.4.0 + */ + public function set_i18n_strings(): void { $this->title = esc_html__( 'External Content', 'elasticpress-labs' ); $this->summary = __( 'List meta keys containing a path or a URL, and ElasticPress will index the content of those path or URL. For example, for a meta key called meta_key with https://wordpress.org/news/wp-json/wp/v2/posts/16837 as its value, the JSON returned by that REST API endpoint will be indexed in a meta key called ep_external_content_meta_key.', 'elasticpress-labs' ); - - parent::__construct(); } /** diff --git a/includes/classes/Feature/MetaKeyPattern.php b/includes/classes/Feature/MetaKeyPattern.php index b3d9b43..87133de 100644 --- a/includes/classes/Feature/MetaKeyPattern.php +++ b/includes/classes/Feature/MetaKeyPattern.php @@ -31,8 +31,6 @@ class MetaKeyPattern extends \ElasticPress\Feature { public function __construct() { $this->slug = 'meta_key_pattern'; - $this->title = esc_html__( 'Meta Key Pattern', 'elasticpress-labs' ); - $this->requires_install_reindex = false; $this->default_settings = [ 'meta_key_allow_pattern' => '', @@ -42,6 +40,16 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 2.4.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Meta Key Pattern', 'elasticpress-labs' ); + } + /** * Output feature box summary. */ diff --git a/includes/classes/Feature/SearchAlgorithm.php b/includes/classes/Feature/SearchAlgorithm.php index 933670f..323288d 100644 --- a/includes/classes/Feature/SearchAlgorithm.php +++ b/includes/classes/Feature/SearchAlgorithm.php @@ -29,8 +29,6 @@ class SearchAlgorithm extends \ElasticPress\Feature { public function __construct() { $this->slug = 'search_algorithm'; - $this->title = esc_html__( 'Search Algorithm Version', 'elasticpress-labs' ); - $this->requires_install_reindex = false; $this->default_settings = [ 'search_algorithm_version' => '3.5', @@ -39,6 +37,16 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 2.4.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Search Algorithm Version', 'elasticpress-labs' ); + } + /** * Output feature box summary. */ diff --git a/includes/classes/Feature/Users.php b/includes/classes/Feature/Users.php index b6a814a..94c0ee9 100644 --- a/includes/classes/Feature/Users.php +++ b/includes/classes/Feature/Users.php @@ -22,12 +22,6 @@ class Users extends Feature { public function __construct() { $this->slug = 'users'; - $this->title = esc_html__( 'Users', 'elasticpress-labs' ); - - $this->summary = __( 'Improve user search relevancy and query performance.', 'elasticpress-labs' ); - - $this->docs_url = __( 'https://elasticpress.zendesk.com/hc/en-us/articles/360050447492-Configuring-ElasticPress-via-the-Plugin-Dashboard#users', 'elasticpress-labs' ); - $this->requires_install_reindex = true; Indexables::factory()->register( new \ElasticPressLabs\Indexable\User\User(), false ); @@ -35,6 +29,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 2.4.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Users', 'elasticpress-labs' ); + + $this->summary = __( 'Improve user search relevancy and query performance.', 'elasticpress-labs' ); + + $this->docs_url = __( 'https://elasticpress.zendesk.com/hc/en-us/articles/360050447492-Configuring-ElasticPress-via-the-Plugin-Dashboard#users', 'elasticpress-labs' ); + } + /** * Hook search functionality */ diff --git a/includes/classes/Feature/WooCommerceSubscriptionSearch.php b/includes/classes/Feature/WooCommerceSubscriptionSearch.php index 59cff51..ee3626f 100644 --- a/includes/classes/Feature/WooCommerceSubscriptionSearch.php +++ b/includes/classes/Feature/WooCommerceSubscriptionSearch.php @@ -30,13 +30,21 @@ class WooCommerceSubscriptionSearch extends \ElasticPress\Feature { public function __construct() { $this->slug = 'woocommerce_subscription_search'; - $this->title = esc_html__( 'WooCommerce Admin Subscription Search', 'elasticpress-labs' ); - $this->requires_install_reindex = true; parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 2.4.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'WooCommerce Admin Subscription Search', 'elasticpress-labs' ); + } + /** * Output feature box summary. */ From da80d88916a0633f48baa142bcaeb4f57beb3294 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 30 Jan 2025 18:43:32 +0500 Subject: [PATCH 2/4] Fix tests --- tests/phpunit/feature/TestBooleanSearchOperators.php | 3 ++- tests/phpunit/feature/TestCoAuthorsPlus.php | 3 ++- tests/phpunit/feature/TestExternalContent.php | 1 + tests/phpunit/feature/TestMetaKeyPattern.php | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/feature/TestBooleanSearchOperators.php b/tests/phpunit/feature/TestBooleanSearchOperators.php index a368369..1f013d0 100644 --- a/tests/phpunit/feature/TestBooleanSearchOperators.php +++ b/tests/phpunit/feature/TestBooleanSearchOperators.php @@ -37,12 +37,13 @@ protected function get_feature() { } /** - * Test constrcut + * Test construct * * @since 1.2.0 */ public function testConstruct() { $instance = $this->get_feature(); + $instance->set_i18n_strings(); $this->assertEquals( 'boolean_search_operators', $instance->slug ); $this->assertEquals( 'Boolean Search Operators', $instance->title ); diff --git a/tests/phpunit/feature/TestCoAuthorsPlus.php b/tests/phpunit/feature/TestCoAuthorsPlus.php index d502dd5..de73aad 100644 --- a/tests/phpunit/feature/TestCoAuthorsPlus.php +++ b/tests/phpunit/feature/TestCoAuthorsPlus.php @@ -53,12 +53,13 @@ protected function get_protected_function( $function_name, $class_name = 'Elasti } /** - * Test constrcut + * Test construct * * @since 1.1.0 */ public function testConstruct() { $instance = $this->get_feature(); + $instance->set_i18n_strings(); $this->assertEquals( 'co_authors_plus', $instance->slug ); $this->assertEquals( 'Co-Authors Plus', $instance->title ); diff --git a/tests/phpunit/feature/TestExternalContent.php b/tests/phpunit/feature/TestExternalContent.php index 4a5bef2..4c4814d 100644 --- a/tests/phpunit/feature/TestExternalContent.php +++ b/tests/phpunit/feature/TestExternalContent.php @@ -54,6 +54,7 @@ protected function get_feature() { */ public function test_construct() { $instance = $this->get_feature(); + $instance->set_i18n_strings(); $this->assertEquals( 'external_content', $instance->slug ); $this->assertEquals( 'External Content', $instance->title ); diff --git a/tests/phpunit/feature/TestMetaKeyPattern.php b/tests/phpunit/feature/TestMetaKeyPattern.php index 4918fc9..1c7978c 100644 --- a/tests/phpunit/feature/TestMetaKeyPattern.php +++ b/tests/phpunit/feature/TestMetaKeyPattern.php @@ -47,12 +47,13 @@ protected function get_private_function( $function_name, $class_name = 'ElasticP } /** - * Test constrcut + * Test construct * * @group MetaKeyPattern */ public function testConstruct() { $instance = $this->get_feature(); + $instance->set_i18n_strings(); $this->assertEquals( 'meta_key_pattern', $instance->slug ); $this->assertEquals( 'Meta Key Pattern', $instance->title ); From 21f5c325b6d52070ed0740c5862c41cfb14c0de7 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 30 Jan 2025 19:08:25 +0500 Subject: [PATCH 3/4] Add backward compatability --- includes/classes/Feature/BooleanSearchOperators.php | 4 ++++ includes/classes/Feature/CoAuthorsPlus.php | 4 ++++ includes/classes/Feature/ElasticPressLabs.php | 4 ++++ includes/classes/Feature/ExternalContent.php | 4 ++++ includes/classes/Feature/MetaKeyPattern.php | 4 ++++ includes/classes/Feature/SearchAlgorithm.php | 4 ++++ includes/classes/Feature/Users.php | 4 ++++ includes/classes/Feature/WooCommerceSubscriptionSearch.php | 4 ++++ 8 files changed, 32 insertions(+) diff --git a/includes/classes/Feature/BooleanSearchOperators.php b/includes/classes/Feature/BooleanSearchOperators.php index e0c4adc..f96d031 100644 --- a/includes/classes/Feature/BooleanSearchOperators.php +++ b/includes/classes/Feature/BooleanSearchOperators.php @@ -36,6 +36,10 @@ class BooleanSearchOperators extends Feature { public function __construct() { $this->slug = 'boolean_search_operators'; + if ( ! defined( 'EP_VERSION' ) || version_compare( EP_VERSION, '5.2.0', '<' ) ) { + $this->set_i18n_strings(); + } + $this->requires_install_reindex = false; $this->default_settings = [ 'active' => false, diff --git a/includes/classes/Feature/CoAuthorsPlus.php b/includes/classes/Feature/CoAuthorsPlus.php index 46562ba..44d2b66 100644 --- a/includes/classes/Feature/CoAuthorsPlus.php +++ b/includes/classes/Feature/CoAuthorsPlus.php @@ -46,6 +46,10 @@ class CoAuthorsPlus extends Feature { public function __construct() { $this->slug = 'co_authors_plus'; + if ( ! defined( 'EP_VERSION' ) || version_compare( EP_VERSION, '5.2.0', '<' ) ) { + $this->set_i18n_strings(); + } + $this->requires_install_reindex = true; $protected_content_feature = Features::factory()->get_registered_feature( 'protected_content' ); diff --git a/includes/classes/Feature/ElasticPressLabs.php b/includes/classes/Feature/ElasticPressLabs.php index dd7f3cb..16b927c 100644 --- a/includes/classes/Feature/ElasticPressLabs.php +++ b/includes/classes/Feature/ElasticPressLabs.php @@ -34,6 +34,10 @@ class ElasticPressLabs extends \ElasticPress\Feature { public function __construct() { $this->slug = 'elasticpress_labs'; + if ( ! defined( 'EP_VERSION' ) || version_compare( EP_VERSION, '5.2.0', '<' ) ) { + $this->set_i18n_strings(); + } + $this->requires_install_reindex = false; $this->default_settings = []; diff --git a/includes/classes/Feature/ExternalContent.php b/includes/classes/Feature/ExternalContent.php index 71207c5..06129a0 100644 --- a/includes/classes/Feature/ExternalContent.php +++ b/includes/classes/Feature/ExternalContent.php @@ -33,6 +33,10 @@ class ExternalContent extends Feature { public function __construct() { $this->slug = 'external_content'; + if ( ! defined( 'EP_VERSION' ) || version_compare( EP_VERSION, '5.2.0', '<' ) ) { + $this->set_i18n_strings(); + } + parent::__construct(); } diff --git a/includes/classes/Feature/MetaKeyPattern.php b/includes/classes/Feature/MetaKeyPattern.php index 87133de..384d4c6 100644 --- a/includes/classes/Feature/MetaKeyPattern.php +++ b/includes/classes/Feature/MetaKeyPattern.php @@ -31,6 +31,10 @@ class MetaKeyPattern extends \ElasticPress\Feature { public function __construct() { $this->slug = 'meta_key_pattern'; + if ( ! defined( 'EP_VERSION' ) || version_compare( EP_VERSION, '5.2.0', '<' ) ) { + $this->set_i18n_strings(); + } + $this->requires_install_reindex = false; $this->default_settings = [ 'meta_key_allow_pattern' => '', diff --git a/includes/classes/Feature/SearchAlgorithm.php b/includes/classes/Feature/SearchAlgorithm.php index 323288d..d71d320 100644 --- a/includes/classes/Feature/SearchAlgorithm.php +++ b/includes/classes/Feature/SearchAlgorithm.php @@ -29,6 +29,10 @@ class SearchAlgorithm extends \ElasticPress\Feature { public function __construct() { $this->slug = 'search_algorithm'; + if ( ! defined( 'EP_VERSION' ) || version_compare( EP_VERSION, '5.2.0', '<' ) ) { + $this->set_i18n_strings(); + } + $this->requires_install_reindex = false; $this->default_settings = [ 'search_algorithm_version' => '3.5', diff --git a/includes/classes/Feature/Users.php b/includes/classes/Feature/Users.php index 94c0ee9..16eb81b 100644 --- a/includes/classes/Feature/Users.php +++ b/includes/classes/Feature/Users.php @@ -22,6 +22,10 @@ class Users extends Feature { public function __construct() { $this->slug = 'users'; + if ( ! defined( 'EP_VERSION' ) || version_compare( EP_VERSION, '5.2.0', '<' ) ) { + $this->set_i18n_strings(); + } + $this->requires_install_reindex = true; Indexables::factory()->register( new \ElasticPressLabs\Indexable\User\User(), false ); diff --git a/includes/classes/Feature/WooCommerceSubscriptionSearch.php b/includes/classes/Feature/WooCommerceSubscriptionSearch.php index ee3626f..e8f4a6f 100644 --- a/includes/classes/Feature/WooCommerceSubscriptionSearch.php +++ b/includes/classes/Feature/WooCommerceSubscriptionSearch.php @@ -30,6 +30,10 @@ class WooCommerceSubscriptionSearch extends \ElasticPress\Feature { public function __construct() { $this->slug = 'woocommerce_subscription_search'; + if ( ! defined( 'EP_VERSION' ) || version_compare( EP_VERSION, '5.2.0', '<' ) ) { + $this->set_i18n_strings(); + } + $this->requires_install_reindex = true; parent::__construct(); From fa4871d3eea82cd2bb61861e1c1d02e57eaac039 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 30 Jan 2025 19:38:39 +0500 Subject: [PATCH 4/4] Update SearchTemplates --- includes/classes/Feature/SearchTemplates.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/classes/Feature/SearchTemplates.php b/includes/classes/Feature/SearchTemplates.php index 8bf6ea4..6edab75 100644 --- a/includes/classes/Feature/SearchTemplates.php +++ b/includes/classes/Feature/SearchTemplates.php @@ -36,6 +36,19 @@ class SearchTemplates extends Feature { public function __construct() { $this->slug = 'search_templates'; + if ( ! defined( 'EP_VERSION' ) || version_compare( EP_VERSION, '5.2.0', '<' ) ) { + $this->set_i18n_strings(); + } + + parent::__construct(); + } + + /** + * Sets i18n strings. + * + * @return void + */ + public function set_i18n_strings(): void { $this->title = esc_html__( 'Search Templates', 'elasticpress-labs' ); $this->summary = '

' . sprintf( @@ -48,8 +61,6 @@ public function __construct() { ) . '

' . '

' . __( 'Please note that all the API fields are still available for custom search templates. Your templates do not to differ in post types, offset, pagination arguments, or even filters, as for those you can still use query parameters. The templates can be used for searching in different fields or applying different scores, for instance.', 'elasticpress-labs' ) . '

' . '

' . __( 'Requires an ElasticPress.io plan to function.', 'elasticpress-labs' ) . '

'; - - parent::__construct(); } /**