Changeset 3378427
- Timestamp:
- 10/14/2025 08:30:52 PM (3 months ago)
- Location:
- ymc-smart-filter/tags
- Files:
-
- 2 deleted
- 1 edited
-
2.9.60 (deleted)
-
2.9.65 (deleted)
-
2.9.71/includes/core/frontend/Get_Posts.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ymc-smart-filter/tags/2.9.71/includes/core/frontend/Get_Posts.php
r3349706 r3378427 162 162 if( !empty($keyword) ) { 163 163 164 add_filter( 'posts_join', array($this,'search_join') );165 add_filter( 'posts_where', array($this,'search_where') );166 add_filter( 'posts_distinct', array($this,'search_distinct') );164 //add_filter( 'posts_join', array($this,'search_join') ); 165 //add_filter( 'posts_where', array($this,'search_where') ); 166 //add_filter( 'posts_distinct', array($this,'search_distinct') ); 167 167 168 168 $args['sentence'] = true; … … 521 521 */ 522 522 public function search_where( $where ) { 523 524 523 global $wpdb; 525 524 526 $where = preg_replace( 527 "/\(\s*$wpdb->posts.post_title\s+LIKE\s*(\'[^\']+\')\s*\)/", 528 "($wpdb->posts.post_title LIKE $1) OR (pm.meta_value LIKE $1)", $where ); 525 $pattern = "/\(\s*{$wpdb->posts}.post_title\s+LIKE\s*'([^']*)'\s*\)/"; 526 527 $where = preg_replace_callback( $pattern, function( $matches ) use ( $wpdb ) { 528 $raw = $matches[1]; 529 530 $raw = wp_unslash( $raw ); 531 $like = $wpdb->esc_like( $raw ); 532 533 $quoted_like = $wpdb->prepare( "'%s'", '%' . $like . '%' ); 534 535 return "({$wpdb->posts}.post_title LIKE {$quoted_like}) OR (pm.meta_value LIKE {$quoted_like})"; 536 }, $where ); 529 537 530 538 return $where; … … 552 560 */ 553 561 public function autocomplete_search() { 554 555 if ( ! isset($_POST['nonce_code']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce_code'])), Plugin::$instance->token_f) ) exit; 562 //if ( ! isset($_POST['nonce_code']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce_code'])), Plugin::$instance->token_f) ) exit; 563 564 check_ajax_referer( Plugin::$instance->token_f, 'nonce_code' ); 556 565 557 566 $output = ''; … … 561 570 $id = ''; 562 571 563 if(!empty($_POST['phrase'])) { 564 $phrase = trim(mb_strtolower(sanitize_text_field(wp_unslash($_POST['phrase'])))); 565 } 566 if(!empty($_POST['choices_posts'])) { 567 $choices_posts = sanitize_text_field(wp_unslash($_POST['choices_posts'])); 568 } 569 if(!empty($_POST['exclude_posts'])) { 570 $exclude_posts = sanitize_text_field(wp_unslash($_POST['exclude_posts'])); 571 } 572 if(!empty($_POST['post_id'])) { 573 $id = (int) sanitize_text_field(wp_unslash($_POST['post_id'])); 574 } 575 576 $term_ids = !empty($_POST['terms_ids']) ? explode(',', sanitize_text_field(wp_unslash($_POST['terms_ids']))) : ""; 572 if ( ! empty( $_POST['phrase'] ) ) { 573 $phrase = trim( mb_strtolower( sanitize_text_field( wp_unslash( $_POST['phrase'] ) ) ) ); 574 $phrase = mb_substr( $phrase, 0, 50 ); 575 } 576 577 if ( ! empty( $_POST['choices_posts'] ) ) { 578 $choices_posts = sanitize_text_field( wp_unslash( $_POST['choices_posts'] ) ); 579 } 580 if ( ! empty( $_POST['exclude_posts'] ) ) { 581 $exclude_posts = sanitize_text_field( wp_unslash( $_POST['exclude_posts'] ) ); 582 } 583 if ( ! empty( $_POST['post_id'] ) ) { 584 $id = (int) sanitize_text_field( wp_unslash( $_POST['post_id'] ) ); 585 } 586 587 588 $term_ids = ! empty( $_POST['terms_ids'] ) ? explode( ',', sanitize_text_field( wp_unslash( $_POST['terms_ids'] ) ) ) : ""; 577 589 578 590 $per_page = 20; … … 582 594 require YMC_SMART_FILTER_DIR . '/includes/core/util/variables.php'; 583 595 584 add_filter( 'posts_join', array($this,'search_join') );585 add_filter( 'posts_where', array($this,'search_where') );586 add_filter( 'posts_distinct', array($this,'search_distinct') );596 //add_filter( 'posts_join', array( $this, 'search_join' ) ); 597 //add_filter( 'posts_where', array( $this, 'search_where' ) ); 598 //add_filter( 'posts_distinct', array( $this, 'search_distinct' ) ); 587 599 588 600 $args = [
Note: See TracChangeset
for help on using the changeset viewer.