• Resolved tunyk

    (@tunyk)


    Could you please provide more examples of using the filter.

    I don’t understand php. Tell me how to add several paths to this filter at the same time. In addition to the /cart/, there are 5 other ways (/checkout/, /thank-you/ etc).

    add_filter(
    ‘plsr_speculation_rules_href_exclude_paths’,
    function ( $exclude_paths ) {
    $exclude_paths[] = ‘/cart/*’;
    return $exclude_paths;
    }
    );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    @tunyk Certainly. Here’s an example that excludes /cart/, /checkout/, and /thank-you/:

    <?php
    /**
    * Plugin Name: Exclude Shop URLs from Speculative Loading
    * Version: 0.1.0
    * Author: Weston Ruter
    * Plugin URI: https://www.ads-software.com/support/topic/more-examples-of-using-the-filter/
    * License: GPLv2 or later
    * Update URI: false
    */

    add_filter(
    'plsr_speculation_rules_href_exclude_paths',
    function ( $exclude_paths ) {
    $exclude_paths[] = '/cart/*';
    $exclude_paths[] = '/checkout/*';
    $exclude_paths[] = '/thank-you/*';
    return $exclude_paths;
    }
    );

    You can duplicate the $exclude_path[] = '...'; line for each additional path you want to exclude.

    Put this code into a text file and save the file as something like speculative-loading-shop-exclusions.php and then add that PHP file to a ZIP archive. You can then upload that ZIP file (e.g. speculative-loading-shop-exclusions.zip) to install as a plugin in your WordPress site.

    Thread Starter tunyk

    (@tunyk)

    Thank you! Awesome

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.