Refers to FiboSearch Pro only

The search endpoint URL is blocked

Reason

FiboSearch Pro uses a custom AJAX endpoint URL to send requests for search results. This endpoint has the following URL structure:

https://your-domain.com/wp-content/plugins/ajax-search-for-woocommerce-premium/includes/Engines/TNTSearchMySQL/Endpo'ints/search.php?s=test

Some security plugins or firewalls such as Securi Security or firewall from GoDaddy WordPress hosting might prevent the execution of PHP files that are located in wp-content or wp-content/plugins directories.

Solution

We have come up with some solutions for popular security plugins. If you use iThemes Security, Sucuri Security, or WP Defender and your endpoint is blocked, learn more about possible solutions for these plugins. If you don’t have these plugins and your endpoint is still blocked, read on.

The solution is to create another endpoint in the root directory where your WordPress is installed and set FiboSearch to use the new endpoint URL. 

Step 1 – Create a new directory /fibosearch in the WordPress root directory and add there index.php file

Create a directory with the name fibosearch in the WordPress root directory. It should be the same level where you have the wp-config.php For many hosting providers, this will be public_html/fibosearch

Go to the directory /fibosearch and create an empty index.php. The path should be /fibosearch/index.php.

Step 2 – Add the following snippet to the /fibosearch/index.php file

<?php
/**
 * Custom FiboSearch endpoint
 */

define( 'SHORTINIT', true );

$wp_load = '../wp-load.php';

if ( file_exists( $wp_load ) ) {
    require_once $wp_load;
    $endpoint = '../wp-content/plugins/ajax-search-for-woocommerce-premium/includes/Engines/TNTSearchMySQL/Endpoints/search.php';
    if ( file_exists( $endpoint ) ) {
        require_once $endpoint;
    }
}

Step 3 – Set the new endpoint

Add the following snippet.

  1. Open the functions.php file in your child theme and add the code at the end
  2. Or install the Code Snippets plugin and apply this code as a snippet.
add_filter( 'dgwt/wcas/endpoint/search', function ( $endpoint ) {
    return home_url( '/fibosearch/' );
} );

Step 4 – Check if the endpoint works

Go to WooCommerceFiboSearch If you don’t see a “Troubleshooting” tab, it means that the problem has been solved. If you see the “Troubleshooting” tabclick the “Check status again” button If everything is ok, this tab should disappear. 

Multisite with different sites in directories and Nginx
The combination of Nginx and Multisite when the sites are different directories requires extra configuration. Otherwise, the search results on every site will return products from the main site. Add the following lines to the Nginx configuration file:

if (!-e $request_filename) {
  rewrite ^(/[^/]+)?(/search\.php) /$2 last;
}

If it still doesn’t work, scroll down to the Alternative solution section.

Alternative solution

If the above solution doesn’t work, we have one more quick fix. You can enable the WooCommerce AJAX endpoint instead of our custom endpoint. Add the following constant to the wp-config.php file:

define( 'DGWT_WCAS_ALTERNATIVE_SEARCH_ENDPOINT', true );

Using this alternative endpoint, you will be able to use all pro features, but the search might be a bit slower.


Why do we use a custom AJAX endpoint instead of using admin-ajax.php or WP REST API? (only for geeks)

Every time someone types something in the FiboSearch bar, JavaScript sends a request to this endpoint for search results. 

Why do we use a custom endpoint instead of using admin-ajax.php or WP REST API? The answer is simple. Speed, speed, and once again speed. 

Using a custom search endpoint, WordPress can be loaded in special SHORTINIT mode by defining a constant define( 'SHORTINIT', true ); Then WordPress reduces initializing to a minimum. No plugins are loaded. No theme is loaded and a lot of WordPress core files aren’t loaded. You can use the $wpdb object and your own scripts. 

This means that every search query doesn’t need to load unnecessary files that are redundant in the search context. It’s a huge benefit. Imagine you have 50 plugins and every search query requires all of these plugins to be loaded as well as plenty of SQLs and calculations that are not related to the search request. It’s ridiculous, but this happens in WordPress by default if you use admin-ajax.php or WP REST API

As a result, the search is always fast, no matter how many plugins you have or how your website is optimized or not optimized.