Plugin Directory

Changeset 3378427


Ignore:
Timestamp:
10/14/2025 08:30:52 PM (3 months ago)
Author:
wssoffice21
Message:

Fixed realis

Location:
ymc-smart-filter/tags
Files:
2 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • ymc-smart-filter/tags/2.9.71/includes/core/frontend/Get_Posts.php

    r3349706 r3378427  
    162162        if( !empty($keyword) ) {
    163163
    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') );
    167167
    168168            $args['sentence'] = true;
     
    521521     */
    522522    public function search_where( $where ) {
    523 
    524523        global $wpdb;
    525524
    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 );
    529537
    530538        return $where;
     
    552560     */
    553561    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' );
    556565
    557566        $output  = '';
     
    561570        $id = '';
    562571
    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'] ) ) ) : "";
    577589
    578590        $per_page  = 20;
     
    582594        require YMC_SMART_FILTER_DIR . '/includes/core/util/variables.php';
    583595
    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' ) );
    587599
    588600        $args = [
Note: See TracChangeset for help on using the changeset viewer.