PluginProbe
wpForo Forum / 3.1.6
wpForo Forum v3.1.6
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
← All changes | classes/AIWordPressIndexer.php +35 -21 3.0.73.1.6 View file →
@@ -198,15 +198,11 @@
198 198 *
199 199 * @return array Array of post type objects with name, label, and count
200 200 */
201 201 public function get_public_post_types() {
202 - $post_types = get_post_types(
203 - [
204 - 'public' => true,
205 - 'publicly_queryable' => true,
206 - ],
207 - 'objects'
208 - );
202 + // 'publicly_queryable' => true, 'public' => true
203 + $post_type_arguments = apply_filters('wpforo_ai_wp_indexing_post_types', [ 'public' => true ]);
204 + $post_types = get_post_types($post_type_arguments, 'objects');
209 205
210 206 // Also include 'page' which has publicly_queryable = false by default
211 207 $page_type = get_post_type_object( 'page' );
212 208 if ( $page_type ) {
@@ -280,25 +276,34 @@
280 276 // For small result sets, check all posts
281 277 // For large sets, sample to estimate (check first 500)
282 278 $post_ids = $query->posts;
283 279 $total_posts = count( $post_ids );
284 - $sample_size = min( 500, $total_posts );
285 - $indexable_count = 0;
280 +
281 + if( apply_filters('wpforo_ai_filter_indexable_post_types', false, $post_ids, $post_type, $total_posts) ){
282 + $sample_size = min( 100, $total_posts );
283 + $indexable_count = 0;
286 284
287 - // Check sample of posts
288 - for ( $i = 0; $i < $sample_size; $i++ ) {
289 - $post = get_post( $post_ids[ $i ] );
290 - if ( $post && $this->is_content_indexable( $post ) ) {
291 - $indexable_count++;
292 - }
293 - }
285 + // Check sample of posts
286 + for ( $i = 0; $i < $sample_size; $i++ ) {
287 + $post = get_post( $post_ids[ $i ] );
288 + if ( $post && $this->is_content_indexable( $post ) ) {
289 + $indexable_count++;
290 + }
291 + }
294 292
295 - // If we sampled, extrapolate the count
296 - if ( $sample_size < $total_posts ) {
297 - $ratio = $indexable_count / $sample_size;
298 - $indexable_count = (int) round( $total_posts * $ratio );
299 - }
293 + // If we sampled, extrapolate the count
294 + if ( $sample_size < $total_posts ) {
295 + $ratio = $indexable_count / $sample_size;
296 + $indexable_count = (int) round( $total_posts * $ratio );
297 + }
298 + } else {
300 299
300 + // Keep the original number of post type items
301 + $indexable_count = $total_posts;
302 + }
303 +
304 +
305 +
301 306 set_transient( $cache_key, $indexable_count, 5 * MINUTE_IN_SECONDS );
302 307
303 308 return $indexable_count;
304 309 }
@@ -578,8 +583,12 @@
578 583 $query = new \WP_Query( $args );
579 584 $posts = [];
580 585
581 586 foreach ( $query->posts as $post ) {
587 + // Skip password-protected posts - their content should not be searchable
588 + if ( ! empty( $post->post_password ) ) {
589 + continue;
590 + }
582 591 $posts[] = $this->format_post_for_indexing( $post );
583 592 }
584 593
585 594 return [
@@ -948,8 +957,13 @@
948 957
949 958 foreach ( $post_ids as $post_id ) {
950 959 $post = get_post( $post_id );
951 960 if ( $post && $post->post_status === 'publish' ) {
961 + // Skip password-protected posts - their content should not be searchable
962 + if ( ! empty( $post->post_password ) ) {
963 + $skipped++;
964 + continue;
965 + }
952 966 // Skip posts with non-indexable content (shortcodes only, binary, too short)
953 967 if ( ! $this->is_content_indexable( $post ) ) {
954 968 $skipped++;
955 969 continue;