Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter israel wissotzky

    (@israelmeirwi)

    I made a few more games this is my code

    function cf_search_join( $join ) {
        global $wpdb;
    
        // ????? ??? ?? ????? ?? Admin Columns
        if (!is_admin_columns_filter() || !is_acf_filter()) {
            if ( is_search() ) {    
                $join .= ' LEFT JOIN ' . $wpdb->postmeta . ' AS prefix_pm ON ' . $wpdb->posts . '.ID = prefix_pm.post_id ';
            }
        }
    
        return $join;
    }
    add_filter('posts_join', 'cf_search_join' );
    
    function cf_search_where( $where ) {
        global $pagenow, $wpdb;
    
        // ????? ??? ?? ????? ?? Admin Columns
        if (!is_admin_columns_filter() || !is_acf_filter()) {
            if ( is_search() ) {
                $where = preg_replace(
                    "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
                    "(".$wpdb->posts.".post_title LIKE $1) OR (prefix_pm.meta_value LIKE $1)", $where );
            }
        }
    
        return $where;
    }
    add_filter( 'posts_where', 'cf_search_where' );
    
    
    
    function is_admin_columns_filter() {
        $filters = array(
            'cpac/filter/columns',
            'cpac/filter/terms',
        );
    
        return in_array(current_filter(), $filters);
    }
    function is_acf_filter() {
        if (current_filter() === 'acf/load_field') {
            $field = func_get_arg(0);
            if ($field['key'] === 'field_5fda152076292') {
                return true;
            }
        }
        return false;
    }

    And it works great

    Thread Starter israel wissotzky

    (@israelmeirwi)

    I installed it is the error it raises

    Not unique table/alias: ‘fcm_postmeta’

    Thread Starter israel wissotzky

    (@israelmeirwi)

    Yes I checked it does the problem

    I changed this code but it doesn’t help it only happens in the ACF field

    function cf_search_join( $join ) {
        global $wpdb;
    
        // ????? ??? ?? ????? ?? Admin Columns
        if (!is_admin_columns_filter() || !is_acf_filter()) {
            if ( is_search() ) {    
                $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
            }
        }
    
        return $join;
    }
    add_filter('posts_join', 'cf_search_join' );
    
    function cf_search_where( $where ) {
        global $pagenow, $wpdb;
    
        // ????? ??? ?? ????? ?? Admin Columns
        if (!is_admin_columns_filter() || !is_acf_filter()) {
            if ( is_search() ) {
                $where = preg_replace(
                    "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
                    "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
            }
        }
    
        return $where;
    }
    add_filter( 'posts_where', 'cf_search_where' );
    
    function is_admin_columns_filter() {
        $filters = array(
            'cpac/filter/columns',
            'cpac/filter/terms',
        );
    
        return in_array(current_filter(), $filters);
    }
    function is_acf_filter() {
        if (current_filter() == 'acf/load_field') {
            $field = func_get_arg(0);
            if ($field['key'] == 'field_5fda152076292') {
                return true;
            }
        }
        return false;
    }

    There may be another way to make the search search ACF fields as well

    Thread Starter israel wissotzky

    (@israelmeirwi)

    Yes I have this code

    function cf_search_join( $join ) {
        global $wpdb;
    
        if ( is_search() ) {    
            $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id ';
        }
    
        return $join;
    }
    add_filter('posts_join', 'cf_search_join' );
    
    
    
    function cf_search_where( $where ) {
      global $pagenow, $wpdb;
    
       if ( is_search() ) {
          $where = preg_replace(
            "/\(\s*".$wpdb->posts.".post_title\s+LIKE\s*(\'[^\']+\')\s*\)/",
            "(".$wpdb->posts.".post_title LIKE $1) OR (".$wpdb->postmeta.".meta_value LIKE $1)", $where );
        }
    
       return $where;
       }
    add_filter( 'posts_where', 'cf_search_where' );

    It helps me in searching in META FILDLS. Is there a better way to do it?

    Thread Starter israel wissotzky

    (@israelmeirwi)

    Thank you very much it was really the Elementor Custom Skin plugin

    I have another problem from the information security side

    The user can inject HTML code into the ACF field

    Thread Starter israel wissotzky

    (@israelmeirwi)

    ????

    ????? ?? ????? ??? ???? ???? ?? ???? ?? ????

    ??? ???? ?? ?? ?????? ?? ???

    Thread Starter israel wissotzky

    (@israelmeirwi)

    ????? ??? ???? ?? ?? ???? ????? ???? ?? ????? ?

Viewing 7 replies - 1 through 7 (of 7 total)