PluginProbe
ElasticPress / 5.3.5
ElasticPress v5.3.5
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
← All changes | includes/classes/Indexable/Comment/QueryIntegration.php +29 -14 4.4.05.3.5 View file →
@@ -7,11 +7,11 @@
7 7 */
8 8
9 9 namespace ElasticPress\Indexable\Comment;
10 10
11 -use ElasticPress\Indexables as Indexables;
12 -use \WP_Comment_Query as WP_Comment_Query;
13 -use ElasticPress\Utils as Utils;
11 +use WP_Comment_Query;
12 +use ElasticPress\Indexables;
13 +use ElasticPress\Utils;
14 14
15 15 if ( ! defined( 'ABSPATH' ) ) {
16 16 exit; // Exit if accessed directly.
17 17 }
@@ -37,13 +37,27 @@
37 37
38 38 /**
39 39 * Sets up the appropriate actions and filters.
40 40 *
41 + * @param string $indexable_slug Indexable slug. Optional.
42 + *
41 43 * @since 3.6.0
42 44 */
43 - public function __construct() {
45 + public function __construct( $indexable_slug = 'comment' ) {
46 + /**
47 + * Filter whether to enable query integration during indexing
48 + *
49 + * @since 4.5.2
50 + * @hook ep_enable_query_integration_during_indexing
51 + *
52 + * @param {bool} $enable To allow query integration during indexing
53 + * @param {string} $indexable_slug Indexable slug
54 + * @return {bool} New value
55 + */
56 + $allow_query_integration_during_indexing = apply_filters( 'ep_enable_query_integration_during_indexing', false, $indexable_slug );
57 +
44 58 // Check if we are currently indexing
45 - if ( Utils\is_indexing() ) {
59 + if ( Utils\is_indexing() && ! $allow_query_integration_during_indexing ) {
46 60 return;
47 61 }
48 62
49 63 // Add header
@@ -122,17 +136,19 @@
122 136 $site__in = [];
123 137 $site__not_in = [];
124 138
125 139 if ( ! empty( $query->query_vars['sites'] ) ) {
126 -
127 140 _deprecated_argument( __FUNCTION__, '4.4.0', esc_html__( 'sites is deprecated. Use site__in instead.', 'elasticpress' ) );
128 - $site__in = (array) $query->query_vars['sites'];
129 - $scope = 'all' === $query->query_vars['sites'] ? 'all' : $site__in;
130 141 }
131 142
132 - if ( ! empty( $query->query_vars['site__in'] ) ) {
133 - $site__in = (array) $query->query_vars['site__in'];
134 - $scope = 'all' === $query->query_vars['site__in'] ? 'all' : $site__in;
143 + if ( ! empty( $query->query_vars['site__in'] ) || ! empty( $query->query_vars['sites'] ) ) {
144 + $site__in = ! empty( $query->query_vars['site__in'] ) ? (array) $query->query_vars['site__in'] : (array) $query->query_vars['sites'];
145 +
146 + if ( in_array( 'all', $site__in, true ) ) {
147 + $scope = 'all';
148 + } elseif ( in_array( 'current', $site__in, true ) ) {
149 + $site__in = (array) get_current_blog_id();
150 + }
135 151 }
136 152
137 153 if ( ! empty( $query->query_vars['site__not_in'] ) ) {
138 154 $site__not_in = (array) $query->query_vars['site__not_in'];
@@ -165,9 +181,9 @@
165 181
166 182 $this->index = implode( ',', $this->index );
167 183 } elseif ( ! empty( $site__not_in ) ) {
168 184
169 - $sites = get_sites(
185 + $sites = \get_sites(
170 186 array(
171 187 'fields' => 'ids',
172 188 'site__not_in' => $site__not_in,
173 189 )
@@ -314,9 +330,9 @@
314 330 $child_comments[] = $level_comment;
315 331 }
316 332 }
317 333
318 - $level ++;
334 + ++$level;
319 335 $levels[ $level ] = $child_comments;
320 336 } while ( $child_comments );
321 337
322 338 // Pull out just the descendant comments
@@ -355,6 +371,5 @@
355 371 }
356 372
357 373 return $comments;
358 374 }
359 -
360 375 }