From 0c8d74f3e9ca0702b2df1f45e223d668367083da Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Thu, 23 Jan 2025 17:48:38 +0500 Subject: [PATCH 1/5] Fix: Function _load_textdomain_just_in_time was called incorrectly --- includes/classes/Feature.php | 9 ++++ .../Feature/Autosuggest/Autosuggest.php | 24 ++++++---- .../classes/Feature/Comments/Comments.php | 21 ++++++--- .../classes/Feature/DidYouMean/DidYouMean.php | 20 ++++++--- .../classes/Feature/Documents/Documents.php | 16 +++++-- includes/classes/Feature/Facets/Facets.php | 44 +++++++++++-------- .../Feature/InstantResults/InstantResults.php | 27 ++++++++---- .../ProtectedContent/ProtectedContent.php | 22 +++++++--- .../Feature/RelatedPosts/RelatedPosts.php | 23 ++++++++-- includes/classes/Feature/Search/Search.php | 25 ++++++++--- .../Feature/SearchOrdering/SearchOrdering.php | 20 ++++++--- includes/classes/Feature/Terms/Terms.php | 20 ++++++--- .../Feature/WooCommerce/WooCommerce.php | 20 ++++++--- includes/classes/Features.php | 2 + .../classes/Indexable/Comment/Comment.php | 15 ++----- includes/classes/Indexable/Post/Post.php | 7 +-- includes/classes/Indexable/Term/Term.php | 15 ++----- tests/php/features/TestAutosuggest.php | 1 + tests/php/features/TestComments.php | 1 + tests/php/features/TestDidYouMean.php | 1 + tests/php/features/TestSearchOrdering.php | 2 + tests/php/indexables/TestPost.php | 1 + tests/php/screen/TestStatusReport.php | 2 +- 23 files changed, 225 insertions(+), 113 deletions(-) diff --git a/includes/classes/Feature.php b/includes/classes/Feature.php index 43295b5b40..dfd2082918 100644 --- a/includes/classes/Feature.php +++ b/includes/classes/Feature.php @@ -622,4 +622,13 @@ protected function set_settings_schema() { ]; } } + + /** + * Sets the i18n strings for the feature. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + } } diff --git a/includes/classes/Feature/Autosuggest/Autosuggest.php b/includes/classes/Feature/Autosuggest/Autosuggest.php index b811965b12..85445c3d18 100644 --- a/includes/classes/Feature/Autosuggest/Autosuggest.php +++ b/includes/classes/Feature/Autosuggest/Autosuggest.php @@ -40,14 +40,6 @@ class Autosuggest extends Feature { public function __construct() { $this->slug = 'autosuggest'; - $this->title = esc_html__( 'Autosuggest', 'elasticpress' ); - - $this->short_title = esc_html__( 'Autosuggest', 'elasticpress' ); - - $this->summary = '

' . __( 'Input fields of type "search" or with the CSS class "search-field" or "ep-autosuggest" will be enhanced with autosuggest functionality. As text is entered into the search field, suggested content will appear below it, based on top search results for the text. Suggestions link directly to the content.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#autosuggest', 'elasticpress' ); - $this->requires_install_reindex = true; $this->default_settings = [ @@ -63,6 +55,22 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Autosuggest', 'elasticpress' ); + + $this->short_title = esc_html__( 'Autosuggest', 'elasticpress' ); + + $this->summary = '

' . __( 'Input fields of type "search" or with the CSS class "search-field" or "ep-autosuggest" will be enhanced with autosuggest functionality. As text is entered into the search field, suggested content will appear below it, based on top search results for the text. Suggestions link directly to the content.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#autosuggest', 'elasticpress' ); + } + /** * Output feature box long * diff --git a/includes/classes/Feature/Comments/Comments.php b/includes/classes/Feature/Comments/Comments.php index 302c24b489..81813aebe2 100644 --- a/includes/classes/Feature/Comments/Comments.php +++ b/includes/classes/Feature/Comments/Comments.php @@ -36,12 +36,6 @@ class Comments extends Feature { public function __construct() { $this->slug = 'comments'; - $this->title = esc_html__( 'Comments', 'elasticpress' ); - - $this->summary = '

' . __( 'This feature will empower your website to overcome traditional WordPress comment search and query limitations that can present themselves at scale. This feature is only needed if you are using WP_Comment_Query directly.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#comments', 'elasticpress' ); - $this->requires_install_reindex = true; Indexables::factory()->register( new Indexable\Comment\Comment(), false ); @@ -49,6 +43,21 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Comments', 'elasticpress' ); + + $this->summary = '

' . __( 'This feature will empower your website to overcome traditional WordPress comment search and query limitations that can present themselves at scale. This feature is only needed if you are using WP_Comment_Query directly.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#comments', 'elasticpress' ); + } + + /** * Setup search functionality * diff --git a/includes/classes/Feature/DidYouMean/DidYouMean.php b/includes/classes/Feature/DidYouMean/DidYouMean.php index 63e60d4e1a..8b28771b5c 100644 --- a/includes/classes/Feature/DidYouMean/DidYouMean.php +++ b/includes/classes/Feature/DidYouMean/DidYouMean.php @@ -21,12 +21,6 @@ class DidYouMean extends Feature { public function __construct() { $this->slug = 'did-you-mean'; - $this->title = esc_html__( 'Did You Mean', 'elasticpress' ); - - $this->summary = '

' . __( '"Did You Mean" search feature provides alternative suggestions for misspelled or ambiguous search queries, enhancing search accuracy and user experience. To display suggestions in your theme, please follow this tutorial.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/did-you-mean/', 'elasticpress' ); - $this->requires_install_reindex = true; $this->available_during_installation = true; @@ -40,6 +34,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Did You Mean', 'elasticpress' ); + + $this->summary = '

' . __( '"Did You Mean" search feature provides alternative suggestions for misspelled or ambiguous search queries, enhancing search accuracy and user experience. To display suggestions in your theme, please follow this tutorial.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/did-you-mean/', 'elasticpress' ); + } + /** * Setup search functionality. * diff --git a/includes/classes/Feature/Documents/Documents.php b/includes/classes/Feature/Documents/Documents.php index f70602125c..4785f9444c 100644 --- a/includes/classes/Feature/Documents/Documents.php +++ b/includes/classes/Feature/Documents/Documents.php @@ -25,15 +25,23 @@ class Documents extends Feature { public function __construct() { $this->slug = 'documents'; + $this->requires_install_reindex = false; + + parent::__construct(); + } + + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { $this->title = esc_html__( 'Documents', 'elasticpress' ); $this->summary = '

' . __( 'Website search results will include popular document file types, using file names as well as their content. Supported file types include: ppt, pptx, doc, docx, xls, xlsx, pdf, csv, txt.', 'elasticpress' ) . '

'; $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#documents', 'elasticpress' ); - - $this->requires_install_reindex = false; - - parent::__construct(); } /** diff --git a/includes/classes/Feature/Facets/Facets.php b/includes/classes/Feature/Facets/Facets.php index 72e0868cd5..76e636b485 100644 --- a/includes/classes/Feature/Facets/Facets.php +++ b/includes/classes/Feature/Facets/Facets.php @@ -38,24 +38,6 @@ class Facets extends Feature { public function __construct() { $this->slug = 'facets'; - $this->title = esc_html__( 'Filters', 'elasticpress' ); - - $this->summary = '

' . - ( wp_is_block_theme() - ? sprintf( - /* translators: Site Editor URL */ - __( 'Adds filter blocks that administrators can add to the website’s templates and template parts, so that visitors can filter applicable content and search results by one or more taxonomy terms, metafields, and date ranges.', 'elasticpress' ), - esc_url( admin_url( 'site-editor.php' ) ) - ) - : sprintf( - /* translators: Widgets Edit Screen URL */ - __( 'Adds filter widgets that administrators can add to the website’s sidebars (widgetized areas), so that visitors can filter applicable content and search results by one or more taxonomy terms, metafields, and date ranges.', 'elasticpress' ), - esc_url( admin_url( 'widgets.php' ) ) - ) - ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#filters', 'elasticpress' ); - $this->requires_install_reindex = false; $this->default_settings = [ @@ -103,6 +85,32 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Filters', 'elasticpress' ); + + $this->summary = '

' . + ( wp_is_block_theme() + ? sprintf( + /* translators: Site Editor URL */ + __( 'Adds filter blocks that administrators can add to the website’s templates and template parts, so that visitors can filter applicable content and search results by one or more taxonomy terms, metafields, and date ranges.', 'elasticpress' ), + esc_url( admin_url( 'site-editor.php' ) ) + ) + : sprintf( + /* translators: Widgets Edit Screen URL */ + __( 'Adds filter widgets that administrators can add to the website’s sidebars (widgetized areas), so that visitors can filter applicable content and search results by one or more taxonomy terms, metafields, and date ranges.', 'elasticpress' ), + esc_url( admin_url( 'widgets.php' ) ) + ) + ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#filters', 'elasticpress' ); + } + /** * Setup hooks and filters for feature * diff --git a/includes/classes/Feature/InstantResults/InstantResults.php b/includes/classes/Feature/InstantResults/InstantResults.php index 4635089e14..50aa3995c0 100644 --- a/includes/classes/Feature/InstantResults/InstantResults.php +++ b/includes/classes/Feature/InstantResults/InstantResults.php @@ -67,15 +67,6 @@ class InstantResults extends Feature { public function __construct() { $this->slug = 'instant-results'; - $this->title = esc_html__( 'Instant Results', 'elasticpress' ); - - $this->short_title = esc_html__( 'Instant Results', 'elasticpress' ); - - $this->summary = '

' . __( 'WordPress search forms will display results instantly. When the search query is submitted, a modal will open that populates results by querying ElasticPress directly, bypassing WordPress. As the user refines their search, results are refreshed.', 'elasticpress' ) . '

' . - '

' . __( 'Requires an ElasticPress.io plan or a custom proxy to function.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#instant-results', 'elasticpress' ); - $this->host = trailingslashit( Utils\get_host() ); $this->index = Indexables::factory()->get( 'post' )->get_index_name(); @@ -102,6 +93,24 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Instant Results', 'elasticpress' ); + + $this->short_title = esc_html__( 'Instant Results', 'elasticpress' ); + + $this->summary = '

' . __( 'WordPress search forms will display results instantly. When the search query is submitted, a modal will open that populates results by querying ElasticPress directly, bypassing WordPress. As the user refines their search, results are refreshed.', 'elasticpress' ) . '

' . + '

' . __( 'Requires an ElasticPress.io plan or a custom proxy to function.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#instant-results', 'elasticpress' ); + } + + /** * Output detailed feature description. * diff --git a/includes/classes/Feature/ProtectedContent/ProtectedContent.php b/includes/classes/Feature/ProtectedContent/ProtectedContent.php index d8c197368a..96e47562fa 100644 --- a/includes/classes/Feature/ProtectedContent/ProtectedContent.php +++ b/includes/classes/Feature/ProtectedContent/ProtectedContent.php @@ -30,13 +30,6 @@ class ProtectedContent extends Feature { public function __construct() { $this->slug = 'protected_content'; - $this->title = esc_html__( 'Protected Content', 'elasticpress' ); - - $this->summary = '

' . __( 'Syncs unpublished content — including private, draft, and scheduled posts — improving load times in places like the administrative dashboard where WordPress needs to include protected content in a query.', 'elasticpress' ) . '

' . - '

' . __( 'We recommend using a secured Elasticsearch setup, such as ElasticPress.io, to prevent potential exposure of content not intended for the public.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#protected-content', 'elasticpress' ); - $this->requires_install_reindex = true; $this->available_during_installation = true; @@ -44,6 +37,21 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Protected Content', 'elasticpress' ); + + $this->summary = '

' . __( 'Syncs unpublished content — including private, draft, and scheduled posts — improving load times in places like the administrative dashboard where WordPress needs to include protected content in a query.', 'elasticpress' ) . '

' . + '

' . __( 'We recommend using a secured Elasticsearch setup, such as ElasticPress.io, to prevent potential exposure of content not intended for the public.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#protected-content', 'elasticpress' ); + } + /** * Setup all feature filters * diff --git a/includes/classes/Feature/RelatedPosts/RelatedPosts.php b/includes/classes/Feature/RelatedPosts/RelatedPosts.php index e3806d95cf..0ba809d052 100644 --- a/includes/classes/Feature/RelatedPosts/RelatedPosts.php +++ b/includes/classes/Feature/RelatedPosts/RelatedPosts.php @@ -26,15 +26,23 @@ class RelatedPosts extends Feature { public function __construct() { $this->slug = 'related_posts'; + $this->requires_install_reindex = false; + + parent::__construct(); + } + + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { $this->title = esc_html__( 'Related Posts', 'elasticpress' ); $this->summary = '

' . __( 'Instantly deliver engaging and precise related content with no impact on site performance. Output related content using our block or directly in your theme using our API functions.', 'elasticpress' ) . '

'; $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#related-posts', 'elasticpress' ); - - $this->requires_install_reindex = false; - - parent::__construct(); } /** @@ -157,12 +165,19 @@ public function find_related( $post_id, $return = 5 ) { return $query->posts; } + /** * Setup all feature filters * * @since 2.1 */ public function setup() { + $this->title = esc_html__( 'Related Posts', 'elasticpress' ); + + $this->summary = '

' . __( 'Instantly deliver engaging and precise related content with no impact on site performance. Output related content using our block or directly in your theme using our API functions.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#related-posts', 'elasticpress' ); + add_action( 'widgets_init', [ $this, 'register_widget' ] ); add_filter( 'widget_types_to_hide_from_legacy_widget_block', [ $this, 'hide_legacy_widget' ] ); add_filter( 'ep_formatted_args', [ $this, 'formatted_args' ], 10, 2 ); diff --git a/includes/classes/Feature/Search/Search.php b/includes/classes/Feature/Search/Search.php index 9bdf44cd47..219e75676d 100644 --- a/includes/classes/Feature/Search/Search.php +++ b/includes/classes/Feature/Search/Search.php @@ -52,13 +52,6 @@ class Search extends Feature { public function __construct() { $this->slug = 'search'; - $this->title = esc_html__( 'Post Search', 'elasticpress' ); - - $this->summary = '

' . __( 'Instantly find the content you’re looking for. The first time.', 'elasticpress' ) . '

' . - '

' . __( 'Overcome higher-end performance and functional limits posed by the traditional WordPress structured (SQL) database to deliver superior keyword search, instantly. ElasticPress indexes custom fields, tags, and other metadata to improve search results. Fuzzy matching accounts for misspellings and verb tenses.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#post-search', 'elasticpress' ); - $this->requires_install_reindex = false; $this->default_settings = [ @@ -74,6 +67,21 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Post Search', 'elasticpress' ); + + $this->summary = '

' . __( 'Instantly find the content you’re looking for. The first time.', 'elasticpress' ) . '

' . + '

' . __( 'Overcome higher-end performance and functional limits posed by the traditional WordPress structured (SQL) database to deliver superior keyword search, instantly. ElasticPress indexes custom fields, tags, and other metadata to improve search results. Fuzzy matching accounts for misspellings and verb tenses.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#post-search', 'elasticpress' ); + } + /** * We need to delay search setup up since it will fire after protected content and protected * content filters into the search setup @@ -81,6 +89,9 @@ public function __construct() { * @since 2.2 */ public function setup() { + + Indexables::factory()->activate( 'post' ); + add_action( 'init', [ $this, 'search_setup' ] ); add_filter( 'ep_sanitize_feature_settings', [ $this, 'sanitize_highlighting_settings' ] ); diff --git a/includes/classes/Feature/SearchOrdering/SearchOrdering.php b/includes/classes/Feature/SearchOrdering/SearchOrdering.php index 3dde596494..41d2b14007 100644 --- a/includes/classes/Feature/SearchOrdering/SearchOrdering.php +++ b/includes/classes/Feature/SearchOrdering/SearchOrdering.php @@ -52,12 +52,6 @@ class SearchOrdering extends Feature { public function __construct() { $this->slug = 'searchordering'; - $this->title = esc_html__( 'Custom Search Results', 'elasticpress' ); - - $this->summary = '

' . __( 'Selected posts will be inserted into search results in the specified position.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#custom-search-results', 'elasticpress' ); - $this->requires_install_reindex = false; $this->requires_feature = 'search'; @@ -65,6 +59,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Custom Search Results', 'elasticpress' ); + + $this->summary = '

' . __( 'Selected posts will be inserted into search results in the specified position.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#custom-search-results', 'elasticpress' ); + } + /** * Setup Feature Functionality */ diff --git a/includes/classes/Feature/Terms/Terms.php b/includes/classes/Feature/Terms/Terms.php index f81998885a..fde8661560 100644 --- a/includes/classes/Feature/Terms/Terms.php +++ b/includes/classes/Feature/Terms/Terms.php @@ -33,12 +33,6 @@ class Terms extends Feature { public function __construct() { $this->slug = 'terms'; - $this->title = esc_html__( 'Terms', 'elasticpress' ); - - $this->summary = '

' . __( 'This feature will empower your website to overcome traditional WordPress term search and query limitations that can present themselves at scale. This feature is only needed if you are using WP_Term_Query directly.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#terms', 'elasticpress' ); - $this->requires_install_reindex = true; Indexables::factory()->register( new Indexable\Term\Term(), false ); @@ -46,6 +40,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'Terms', 'elasticpress' ); + + $this->summary = '

' . __( 'This feature will empower your website to overcome traditional WordPress term search and query limitations that can present themselves at scale. This feature is only needed if you are using WP_Term_Query directly.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#terms', 'elasticpress' ); + } + /** * Setup search functionality * diff --git a/includes/classes/Feature/WooCommerce/WooCommerce.php b/includes/classes/Feature/WooCommerce/WooCommerce.php index 689840c61e..b87ed6663c 100644 --- a/includes/classes/Feature/WooCommerce/WooCommerce.php +++ b/includes/classes/Feature/WooCommerce/WooCommerce.php @@ -54,12 +54,6 @@ class WooCommerce extends Feature { public function __construct() { $this->slug = 'woocommerce'; - $this->title = esc_html__( 'WooCommerce', 'elasticpress' ); - - $this->summary = '

' . __( 'Most caching and performance tools can’t keep up with the nearly infinite ways your visitors might filter or navigate your products. No matter how many products, filters, or customers you have, ElasticPress will keep your online store performing quickly. If used in combination with the Protected Content feature, ElasticPress will also accelerate order searches and back end product management.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#woocommerce', 'elasticpress' ); - $this->requires_install_reindex = true; $this->setting_requires_install_reindex = 'orders'; @@ -77,6 +71,20 @@ public function __construct() { parent::__construct(); } + /** + * Sets i18n strings. + * + * @return void + * @since 5.2.0 + */ + public function set_i18n_strings(): void { + $this->title = esc_html__( 'WooCommerce', 'elasticpress' ); + + $this->summary = '

' . __( 'Most caching and performance tools can’t keep up with the nearly infinite ways your visitors might filter or navigate your products. No matter how many products, filters, or customers you have, ElasticPress will keep your online store performing quickly. If used in combination with the Protected Content feature, ElasticPress will also accelerate order searches and back end product management.', 'elasticpress' ) . '

'; + + $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#woocommerce', 'elasticpress' ); + } + /** * Setup all feature filters * diff --git a/includes/classes/Features.php b/includes/classes/Features.php index c0231bb603..103100719d 100644 --- a/includes/classes/Features.php +++ b/includes/classes/Features.php @@ -330,6 +330,8 @@ public function setup_features() { do_action( 'ep_setup_features' ); foreach ( $this->registered_features as $feature_slug => $feature ) { + $feature->set_i18n_strings(); + if ( $feature->is_active() ) { $feature->setup(); } diff --git a/includes/classes/Indexable/Comment/Comment.php b/includes/classes/Indexable/Comment/Comment.php index 49ad4082ad..08082cd4f6 100644 --- a/includes/classes/Indexable/Comment/Comment.php +++ b/includes/classes/Indexable/Comment/Comment.php @@ -33,24 +33,17 @@ class Comment extends Indexable { public $slug = 'comment'; /** - * Create indexable and initialize dependencies + * Instantiate the indexable SyncManager and QueryIntegration, the main responsibles for the WP integration. * - * @since 3.6.0 + * @since 4.5.0 + * @return void */ - public function __construct() { + public function setup() { $this->labels = [ 'plural' => esc_html__( 'Comments', 'elasticpress' ), 'singular' => esc_html__( 'Comment', 'elasticpress' ), ]; - } - /** - * Instantiate the indexable SyncManager and QueryIntegration, the main responsibles for the WP integration. - * - * @since 4.5.0 - * @return void - */ - public function setup() { $this->sync_manager = new SyncManager( $this->slug ); $this->query_integration = new QueryIntegration(); } diff --git a/includes/classes/Indexable/Post/Post.php b/includes/classes/Indexable/Post/Post.php index f3ff530de4..c02201fd13 100644 --- a/includes/classes/Indexable/Post/Post.php +++ b/includes/classes/Indexable/Post/Post.php @@ -42,11 +42,12 @@ class Post extends Indexable { public $support_indexing_advanced_pagination = true; /** - * Create indexable and initialize dependencies + * Instantiate the indexable SyncManager and QueryIntegration * - * @since 3.0 + * @since 5.2.0 + * @return void */ - public function __construct() { + public function setup() { $this->labels = [ 'plural' => esc_html__( 'Posts', 'elasticpress' ), 'singular' => esc_html__( 'Post', 'elasticpress' ), diff --git a/includes/classes/Indexable/Term/Term.php b/includes/classes/Indexable/Term/Term.php index 0f67fa0b1a..bb2d35545f 100644 --- a/includes/classes/Indexable/Term/Term.php +++ b/includes/classes/Indexable/Term/Term.php @@ -32,24 +32,17 @@ class Term extends Indexable { public $slug = 'term'; /** - * Create indexable and initialize dependencies + * Instantiate the indexable SyncManager and QueryIntegration, the main responsibles for the WP integration. * - * @since 3.1 + * @since 4.5.0 + * @return void */ - public function __construct() { + public function setup() { $this->labels = [ 'plural' => esc_html__( 'Terms', 'elasticpress' ), 'singular' => esc_html__( 'Term', 'elasticpress' ), ]; - } - /** - * Instantiate the indexable SyncManager and QueryIntegration, the main responsibles for the WP integration. - * - * @since 4.5.0 - * @return void - */ - public function setup() { $this->sync_manager = new SyncManager( $this->slug ); $this->query_integration = new QueryIntegration( $this->slug ); } diff --git a/tests/php/features/TestAutosuggest.php b/tests/php/features/TestAutosuggest.php index 953da07c05..e4501dad41 100644 --- a/tests/php/features/TestAutosuggest.php +++ b/tests/php/features/TestAutosuggest.php @@ -68,6 +68,7 @@ protected function get_feature() { */ public function testConstruct() { $instance = new ElasticPress\Feature\Autosuggest\Autosuggest(); + $instance->set_i18n_strings(); $this->assertEquals( 'autosuggest', $instance->slug ); $this->assertEquals( 'Autosuggest', $instance->title ); diff --git a/tests/php/features/TestComments.php b/tests/php/features/TestComments.php index f6e8309ca1..89cd70eaa9 100644 --- a/tests/php/features/TestComments.php +++ b/tests/php/features/TestComments.php @@ -73,6 +73,7 @@ protected function get_feature() { */ public function testConstruct() { $instance = new ElasticPress\Feature\Comments\Comments(); + $instance->set_i18n_strings(); $this->assertEquals( 'comments', $instance->slug ); $this->assertEquals( 'Comments', $instance->title ); diff --git a/tests/php/features/TestDidYouMean.php b/tests/php/features/TestDidYouMean.php index befbe8926b..ff30159242 100644 --- a/tests/php/features/TestDidYouMean.php +++ b/tests/php/features/TestDidYouMean.php @@ -43,6 +43,7 @@ public function set_up() { */ public function testConstruct() { $instance = new ElasticPress\Feature\DidYouMean\DidYouMean(); + $instance->set_i18n_strings(); $this->assertEquals( 'did-you-mean', $instance->slug ); $this->assertEquals( 'Did You Mean', $instance->title ); diff --git a/tests/php/features/TestSearchOrdering.php b/tests/php/features/TestSearchOrdering.php index 2f25546720..924f899603 100644 --- a/tests/php/features/TestSearchOrdering.php +++ b/tests/php/features/TestSearchOrdering.php @@ -73,6 +73,8 @@ public function get_feature() { */ public function testConstruct() { $instance = new \ElasticPress\Feature\SearchOrdering\SearchOrdering(); + $instance->set_i18n_strings(); + $this->assertSame( 'searchordering', $instance->slug ); $this->assertSame( 'Custom Search Results', $instance->title ); } diff --git a/tests/php/indexables/TestPost.php b/tests/php/indexables/TestPost.php index d48e8d46dc..b6c16fedde 100644 --- a/tests/php/indexables/TestPost.php +++ b/tests/php/indexables/TestPost.php @@ -6167,6 +6167,7 @@ function ( $args ) { public function testPostConstructor() { $post = new \ElasticPress\Indexable\Post\Post(); + $post->setup(); $this->assertSame( 'Posts', $post->labels['plural'] ); $this->assertSame( 'Post', $post->labels['singular'] ); diff --git a/tests/php/screen/TestStatusReport.php b/tests/php/screen/TestStatusReport.php index cebc284d67..8162830289 100644 --- a/tests/php/screen/TestStatusReport.php +++ b/tests/php/screen/TestStatusReport.php @@ -64,7 +64,7 @@ public function testGetReportsSkipped() { $reports = $status_report->get_reports(); $this->assertSame( - [ 'failed-queries', 'elasticpress', 'indices', 'last-sync', 'features' ], + [ 'failed-queries', 'wordpress', 'elasticpress', 'indices', 'last-sync', 'features' ], array_keys( $reports ) ); } From b1fb90f53ff8f59600d5a899f37673edd486011b Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Fri, 24 Jan 2025 16:57:47 +0500 Subject: [PATCH 2/5] Fix linting --- includes/classes/Feature/RelatedPosts/RelatedPosts.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/classes/Feature/RelatedPosts/RelatedPosts.php b/includes/classes/Feature/RelatedPosts/RelatedPosts.php index 0ba809d052..b53756ff50 100644 --- a/includes/classes/Feature/RelatedPosts/RelatedPosts.php +++ b/includes/classes/Feature/RelatedPosts/RelatedPosts.php @@ -165,7 +165,6 @@ public function find_related( $post_id, $return = 5 ) { return $query->posts; } - /** * Setup all feature filters * From ff6c2fee456c032f9b93cb8fbdd1bedda9e898d8 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Fri, 24 Jan 2025 17:15:16 +0500 Subject: [PATCH 3/5] Fix tests --- tests/php/screen/TestStatusReport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/php/screen/TestStatusReport.php b/tests/php/screen/TestStatusReport.php index 8162830289..cebc284d67 100644 --- a/tests/php/screen/TestStatusReport.php +++ b/tests/php/screen/TestStatusReport.php @@ -64,7 +64,7 @@ public function testGetReportsSkipped() { $reports = $status_report->get_reports(); $this->assertSame( - [ 'failed-queries', 'wordpress', 'elasticpress', 'indices', 'last-sync', 'features' ], + [ 'failed-queries', 'elasticpress', 'indices', 'last-sync', 'features' ], array_keys( $reports ) ); } From a811b6c03c4b7a9a4901a0e0b68c92e9a0817277 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Fri, 24 Jan 2025 17:31:00 +0500 Subject: [PATCH 4/5] Adjust feedback --- includes/classes/Feature/RelatedPosts/RelatedPosts.php | 6 ------ includes/classes/Feature/Search/Search.php | 1 - includes/classes/Indexable.php | 5 ++++- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/includes/classes/Feature/RelatedPosts/RelatedPosts.php b/includes/classes/Feature/RelatedPosts/RelatedPosts.php index b53756ff50..e5c321c569 100644 --- a/includes/classes/Feature/RelatedPosts/RelatedPosts.php +++ b/includes/classes/Feature/RelatedPosts/RelatedPosts.php @@ -171,12 +171,6 @@ public function find_related( $post_id, $return = 5 ) { * @since 2.1 */ public function setup() { - $this->title = esc_html__( 'Related Posts', 'elasticpress' ); - - $this->summary = '

' . __( 'Instantly deliver engaging and precise related content with no impact on site performance. Output related content using our block or directly in your theme using our API functions.', 'elasticpress' ) . '

'; - - $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#related-posts', 'elasticpress' ); - add_action( 'widgets_init', [ $this, 'register_widget' ] ); add_filter( 'widget_types_to_hide_from_legacy_widget_block', [ $this, 'hide_legacy_widget' ] ); add_filter( 'ep_formatted_args', [ $this, 'formatted_args' ], 10, 2 ); diff --git a/includes/classes/Feature/Search/Search.php b/includes/classes/Feature/Search/Search.php index 219e75676d..9bcc1711d9 100644 --- a/includes/classes/Feature/Search/Search.php +++ b/includes/classes/Feature/Search/Search.php @@ -89,7 +89,6 @@ public function set_i18n_strings(): void { * @since 2.2 */ public function setup() { - Indexables::factory()->activate( 'post' ); add_action( 'init', [ $this, 'search_setup' ] ); diff --git a/includes/classes/Indexable.php b/includes/classes/Indexable.php index 75b9f318c5..a76561c906 100644 --- a/includes/classes/Indexable.php +++ b/includes/classes/Indexable.php @@ -76,7 +76,10 @@ abstract class Indexable { * @since 4.5.0 * @var array */ - public $labels = []; + public $labels = [ + 'plural' => '', + 'singular' => '', + ]; /** * Get number of bulk items to index per page From 66534fe9ae093cbab601dedfd6b903abfe02e88a Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Fri, 24 Jan 2025 17:36:53 +0500 Subject: [PATCH 5/5] Remove extra new line --- includes/classes/Feature/Comments/Comments.php | 1 - includes/classes/Feature/InstantResults/InstantResults.php | 1 - 2 files changed, 2 deletions(-) diff --git a/includes/classes/Feature/Comments/Comments.php b/includes/classes/Feature/Comments/Comments.php index 81813aebe2..c8e07cb7e8 100644 --- a/includes/classes/Feature/Comments/Comments.php +++ b/includes/classes/Feature/Comments/Comments.php @@ -57,7 +57,6 @@ public function set_i18n_strings(): void { $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#comments', 'elasticpress' ); } - /** * Setup search functionality * diff --git a/includes/classes/Feature/InstantResults/InstantResults.php b/includes/classes/Feature/InstantResults/InstantResults.php index 50aa3995c0..de5fbc8bee 100644 --- a/includes/classes/Feature/InstantResults/InstantResults.php +++ b/includes/classes/Feature/InstantResults/InstantResults.php @@ -110,7 +110,6 @@ public function set_i18n_strings(): void { $this->docs_url = __( 'https://www.elasticpress.io/documentation/article/configuring-elasticpress-via-the-plugin-dashboard/#instant-results', 'elasticpress' ); } - /** * Output detailed feature description. *