• Resolved regisit

    (@regisit)


    Hi, is it possible to enable this for admin search only?

    We’re using Fibo Search (formerly AJAX Search for WooCommerce) for active frontend search but this does nothing to improve the slow admin search. I added Admin Ajax Search which boosts admin search by not reloading the entire page. However, admin search is still slow with 2.5k+ products.

    Relevanssi Lite turbocharges the Ajax admin search. However, it doesn’t play nicely with Fibo Search. Having both enabled breaks frontend search resulting in no results.

    Is there a simple tweak I could make (hook maybe) to enable Relevanssi Lite for admin searches only and leave Fibo Search to handle frontend?

    • This topic was modified 3 years, 6 months ago by regisit.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Yes. Unhook these filters:

    add_filter( 'posts_search', 'relevanssi_light_posts_search', 10, 2 );
    add_filter( 'posts_search_orderby', 'relevanssi_light_posts_search_orderby', 10, 2 );
    add_filter( 'posts_request', 'relevanssi_light_posts_request', 10, 2 );

    These are added on init on priority 10, so adding an action on init priority 11 that removes these filters when necessary should do the trick.

    The tricky part here is that since the Fibo Search is an ajax search, it probably appears like an admin search, so you need to figure out somehow whether you’re doing a real admin search or a Fibo search; I can’t unfortunately help you out with that, but look at the global $wp_query for differences you can use to see where you are.

    Thread Starter regisit

    (@regisit)

    Excellent – thanks! I had just this minute opened the source code to look at the hooks being used to see if these could be deregistered.

    My focus is on the product listings page so should be able to deregister them in general but not when on the admin listing pages.

    Thread Starter regisit

    (@regisit)

    As Fibo has a hook when initiating a search, I added this to functions:

    // Manage search - Relevanssi for admin, Fibo for frontend
    add_filter( 'dgwt/wcas/helpers/is_search_query', 'motor_manage_search' );
    function motor_manage_search( $query_object )
    {
        // Remove Relevanssi hooks
        remove_filter( 'posts_search', 'relevanssi_light_posts_search');
        remove_filter( 'posts_search_orderby', 'relevanssi_light_posts_search_orderby');
        remove_filter( 'posts_request', 'relevanssi_light_posts_request');
    }

    Works a treat! Much faster search front and back now.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Enable for admin search only’ is closed to new replies.