Settings'; array_unshift($links, $settings_link); return $links; } $plugin = plugin_basename(__FILE__); add_filter("plugin_action_links_$plugin", 'ph_ajax_pro_search_settings_link' ); function ph_ajax_pro_search_setting() { require_once(dirname(__FILE__).'/admin-setting.php'); } function ph_ajax_pro_search_head() { wp_enqueue_script( 'script-ph-ajax-pro-search-request', ph_ajax_pro_search_plugin_dir_url. '/assets/js/custom.js', array( 'jquery' ) ); wp_localize_script( 'script-ph-ajax-pro-search-request', 'pro_search_ajax', array( 'pro_search_ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); $loader_image = get_option( 'phoe_s_loader_image' ); if( empty( $loader_image ) ) { ?> query->get_catalog_ordering_args( 'title', 'asc' ); $search_results = array(); $args = array( 's' => $search_keyword, 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $ordering_args['orderby'], 'order' => $ordering_args['order'], 'posts_per_page' => get_option( 'max_num_of_result' ), /* 'suppress_filters' => false, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array( 'search', 'visible' ), 'compare' => 'IN' ) )*/ ); $products = get_posts( $args ); if ( !empty( $products ) ) { foreach ( $products as $post ) { $product = wc_get_product( $post ); $search_results[] = array( 'id' => $product->id, 'value' => strip_tags($product->get_title()), 'url' => $product->get_permalink() ); } } else { $search_results[] = array( 'id' => 0, 'value' => __( 'No results', 'ph-ajax-pro-search' ), 'url' => '#', ); } wp_reset_postdata(); $search_results = array( 'search_results' => $search_results ); echo json_encode( $search_results ); die(); } } else { add_action('admin_notices', 'product_search_admin_notice'); function product_search_admin_notice() { global $current_user ; $user_id = $current_user->ID; /* Check that the user hasn't already clicked to ignore the message */ if ( ! get_user_meta($user_id, 'product_search_ignore_notice') ) { echo '

'; printf(__('Woocommerce product search could not detect an active Woocommerce plugin. Make sure you have activated it. | Hide Notice'), '?product_search_nag_ignore=0'); echo "

"; } } add_action('admin_init', 'product_search_nag_ignore'); function product_search_nag_ignore() { global $current_user; $user_id = $current_user->ID; /* If user clicks to ignore the notice, add that to their user meta */ if ( isset($_GET['product_search_nag_ignore']) && '0' == $_GET['product_search_nag_ignore'] ) { add_user_meta($user_id, 'product_search_ignore_notice', 'true', true); } } }