diff --git a/includes/classes/Indexable/Comment/QueryIntegration.php b/includes/classes/Indexable/Comment/QueryIntegration.php index 9cf1bc781f..e145506bbf 100644 --- a/includes/classes/Indexable/Comment/QueryIntegration.php +++ b/includes/classes/Indexable/Comment/QueryIntegration.php @@ -38,11 +38,25 @@ class QueryIntegration { /** * Sets up the appropriate actions and filters. * + * @param string $indexable_slug Indexable slug. Optional. + * * @since 3.6.0 */ - public function __construct() { + public function __construct( $indexable_slug = 'comment' ) { + /** + * Filter whether to enable query integration during indexing + * + * @since 4.5.2 + * @hook ep_enable_query_integration_during_indexing + * + * @param {bool} $enable To allow query integration during indexing + * @param {string} $indexable_slug Indexable slug + * @return {bool} New value + */ + $allow_query_integration_during_indexing = apply_filters( 'ep_enable_query_integration_during_indexing', false, $indexable_slug ); + // Check if we are currently indexing - if ( Utils\is_indexing() ) { + if ( Utils\is_indexing() && ! $allow_query_integration_during_indexing ) { return; } diff --git a/includes/classes/Indexable/Post/QueryIntegration.php b/includes/classes/Indexable/Post/QueryIntegration.php index 4067bc2ec0..ecf9230d7b 100644 --- a/includes/classes/Indexable/Post/QueryIntegration.php +++ b/includes/classes/Indexable/Post/QueryIntegration.php @@ -39,9 +39,21 @@ class QueryIntegration { * @since 3.6.0 Added $indexable_slug */ public function __construct( $indexable_slug = 'post' ) { + /** + * Filter whether to enable query integration during indexing + * + * @since 4.5.2 + * @hook ep_enable_query_integration_during_indexing + * + * @param {bool} $enable To allow query integration during indexing + * @param {string} $indexable_slug Indexable slug + * @return {bool} New value + */ + $allow_query_integration_during_indexing = apply_filters( 'ep_enable_query_integration_during_indexing', false, $indexable_slug ); + // Ensure that we are currently allowing ElasticPress to override the normal WP_Query // Indexable->is_full_reindexing() is not available at this point yet, so using the IndexHelper version of it. - if ( \ElasticPress\IndexHelper::factory()->is_full_reindexing( $indexable_slug, get_current_blog_id() ) ) { + if ( \ElasticPress\IndexHelper::factory()->is_full_reindexing( $indexable_slug, get_current_blog_id() ) && ! $allow_query_integration_during_indexing ) { return; } diff --git a/includes/classes/Indexable/Term/QueryIntegration.php b/includes/classes/Indexable/Term/QueryIntegration.php index 60d33a77c6..abc57caec8 100644 --- a/includes/classes/Indexable/Term/QueryIntegration.php +++ b/includes/classes/Indexable/Term/QueryIntegration.php @@ -30,9 +30,21 @@ class QueryIntegration { * @since 3.6.0 Added $indexable_slug */ public function __construct( $indexable_slug = 'term' ) { + /** + * Filter whether to enable query integration during indexing + * + * @since 4.5.2 + * @hook ep_enable_query_integration_during_indexing + * + * @param {bool} $enable To allow query integration during indexing + * @param {string} $indexable_slug Indexable slug + * @return {bool} New value + */ + $allow_query_integration_during_indexing = apply_filters( 'ep_enable_query_integration_during_indexing', false, $indexable_slug ); + // Ensure that we are currently allowing ElasticPress to override the normal WP_Query // Indexable->is_full_reindexing() is not available at this point yet, so using the IndexHelper version of it. - if ( \ElasticPress\IndexHelper::factory()->is_full_reindexing( $indexable_slug, get_current_blog_id() ) ) { + if ( \ElasticPress\IndexHelper::factory()->is_full_reindexing( $indexable_slug, get_current_blog_id() ) && ! $allow_query_integration_during_indexing ) { return; } diff --git a/includes/classes/Indexable/User/QueryIntegration.php b/includes/classes/Indexable/User/QueryIntegration.php index 2699af301d..66809f9a4f 100644 --- a/includes/classes/Indexable/User/QueryIntegration.php +++ b/includes/classes/Indexable/User/QueryIntegration.php @@ -30,9 +30,21 @@ class QueryIntegration { * @since 3.6.0 Added $indexable_slug */ public function __construct( $indexable_slug = 'user' ) { + /** + * Filter whether to enable query integration during indexing + * + * @since 4.5.2 + * @hook ep_enable_query_integration_during_indexing + * + * @param {bool} $enable To allow query integration during indexing + * @param {string} $indexable_slug Indexable slug + * @return {bool} New value + */ + $allow_query_integration_during_indexing = apply_filters( 'ep_enable_query_integration_during_indexing', false, $indexable_slug ); + // Ensure that we are currently allowing ElasticPress to override the normal WP_Query // Indexable->is_full_reindexing() is not available at this point yet, so using the IndexHelper version of it. - if ( \ElasticPress\IndexHelper::factory()->is_full_reindexing( $indexable_slug ) ) { + if ( \ElasticPress\IndexHelper::factory()->is_full_reindexing( $indexable_slug ) && ! $allow_query_integration_during_indexing ) { return; }