chore: add `TAINACAN_DISABLE_CONTENT_RELATIONSHIP_SEARCH`

This commit is contained in:
vnmedeiros 2023-03-21 08:48:58 -03:00
parent 3a7a9c6b8b
commit c150f137e4
1 changed files with 2 additions and 1 deletions

View File

@ -125,7 +125,8 @@ class Search_Engine {
foreach ( $terms as $term ) {
$esc_term = $wpdb->prepare("%s", $not_exact ? "%".$term."%" : $term);
if ( !empty( $this->relationships ) ) {
$searchQuery .= "{$seperator}($wpdb->posts.post_title LIKE {$esc_term} OR $wpdb->posts.post_content LIKE {$esc_term} OR p2.post_title LIKE {$esc_term} OR p2.post_content LIKE {$esc_term})";
$relation_content = (defined('TAINACAN_DISABLE_CONTENT_RELATIONSHIP_SEARCH') && TAINACAN_DISABLE_CONTENT_RELATIONSHIP_SEARCH === true) ? "" : "OR p2.post_content LIKE {$esc_term}";
$searchQuery .= "{$seperator}($wpdb->posts.post_title LIKE {$esc_term} OR $wpdb->posts.post_content LIKE {$esc_term} OR p2.post_title LIKE {$esc_term} $relation_content)";
} else {
$searchQuery .= "{$seperator}($wpdb->posts.post_title LIKE {$esc_term} OR $wpdb->posts.post_content LIKE {$esc_term})";
}