/*
Theme Name:   Xstore child
Theme URI:    https://xstore.8theme.com
Description:  XStore is a multi-purpose theme that offers the ultimate WordPress and WooCommerce synergy, providing a comprehensive, all-in-one solution.
Author:       8theme
Author URI:   https://www.8theme.com
Template:     xstore
Version:      1.0
Text Domain:  xstore-child
Tags: e-commerce, two-columns, left-sidebar, right-sidebar, custom-background, custom-colors, custom-header, custom-menu, custom-logo, featured-images, full-width-template, threaded-comments, accessibility-ready, rtl-language-support, footer-widgets, sticky-post, theme-options, translation-ready, ecommerce, woocommerce, shop, elementor, business, corporate, blog, news, light, dark
*/

add_filter( 'posts_search', 'custom_partial_product_search', 10, 2 );

function custom_partial_product_search( $search, $wp_query ) {

    if ( is_admin() || ! $wp_query->is_search() ) {
        return $search;
    }

    $search_term = $wp_query->get( 's' );

    if ( empty( $search_term ) ) {
        return $search;
    }

    global $wpdb;

    $like = '%' . $wpdb->esc_like( $search_term ) . '%';

    $search = $wpdb->prepare(
        " AND (
            {$wpdb->posts}.post_title LIKE %s
            OR {$wpdb->posts}.post_content LIKE %s
            OR {$wpdb->posts}.post_excerpt LIKE %s
        ) ",
        $like,
        $like,
        $like
    );

    return $search;
}