Array ( [0] => GDPR Cookie Consent [1] => CCPA [2] => Getting Started [3] => Changelog [4] => GDPR [5] => Add and Categorise Cookies [8] => Auto-block cookies with Script Blocker [13] => Create Privacy Policy Page [15] => Customize Cookie Notice [18] => Customize Settings Pop up [19] => Change Toggle button color [21] => Display Cookie List [22] => FAQ [23] => Getting Started [24] => Multilingual Support [25] => Overview [26] => Import Export Suite for WooCommerce [28] => Order / Coupon / Subscription Export Import Plugin for WooCommerce [29] => PayPal Express Checkout Payment Gateway for WooCommerce [30] => Changelog [31] => Getting Started [32] => Issue Refund [34] => Video Tutorial [35] => Print Invoice, Packing Slip, Delivery Note & Label for WooCommerce [36] => Address Label [39] => Changelog [41] => Credit Note [43] => Delivery Note [45] => Dispatch Label [47] => FAQ [48] => Invoice [49] => Adding meta data [50] => Customizations [51] => Email PDF Invoice [52] => FAQ [53] => Getting Started [54] => Invoice Number [55] => Multilingual Support [56] => Overview [57] => Packing Slip [58] => Customizations [59] => Getting Started [60] => Pick List [62] => Proforma Invoice [65] => Shipping Label [68] => Product Import Export Plugin for WooCommerce [69] => Smart Coupons for WooCommerce [70] => Abandoned Cart Discount [71] => Advanced Coupon Options [72] => Bulk Generate [73] => Changelog [76] => Getting Started [78] => Import Coupon [80] => Sales Countdown Timer [81] => SignUp Coupon [82] => Store Credit [84] => Volume/Quantity based coupon [85] => Stripe Payment Gateway for WooCommerce [86] => Alipay [87] => Apple Pay [88] => Changelog [89] => Compatibility with Subscription [90] => Getting Started [93] => SCA Ready [94] => Stripe Checkout [95] => Stripe Overview [96] => Stripe via Credit Card [97] => Troubleshoot [98] => Video Tutorial [99] => Subscriptions for WooCommerce [100] => Changelog [101] => Email Notifications [102] => FAQ [103] => Getting Started [104] => Manually Add or Modify Subscriptions [105] => Subscriptions Payment Gateway Guide [106] => URL Coupons for WooCommerce [107] => Changelog [108] => FAQ [109] => Getting Started [110] => Import URL Coupons [111] => QR Code Coupon [112] => WordPress Users & WooCommerce Customers Import Export )

Documentation/GDPR Cookie Consent/How to add custom script blocker in WordPress

How to add custom script blocker in WordPress

Script Blocking is of vital importance when it comes to GDPR Cookie compliance. The GDPR Cookie Consent plugin has the capability to automatically block the active scripts that inject cookies on the website until the users give their explicit consent. The inbuilt script blocker in this plugin is capable of blocking cookies from the following third-party scripts:

GDPR Cookie consent-Manage Script blocker

GDPR Cookie consent-Manage Script blocker

Blocking Custom Scripts

Apart from the above-listed pre-defined scripts, the GDPR Cookie consent plugin also allows adding a custom script blocker extension whereby the user can explicitly block scripts of their choice.

To achieve this simply add the below code snippet to the active child theme function.php.

The above code snippet inserts two new script blockers from Google Translator and Recaptcha. Likewise, you can insert scripts accordingly by entering appropriate values for the array fields id, label, key, category, and status.

  • id: Key in the name of the script.
  • label: Enter an appropriate label name for the script blocker that will appear in the interface.
  • key: Specify any number of unique strings separated with commas that can be used to identify your script(an array of strings).
  • category: The plugin maintains necessary and non-necessary as two default categories. Assign the category slug of an existing category for the script. If such a category does not exist then create a new cookie category and assign its slug.
    Note: Ensure that the correct slug (lower case) of the corresponding category is placed in the code snippet.
  • status: Set the status as ‘yes’ to make it active by default else set as ‘no’.

On inserting the above code snippet to the function.php file, the script blocker interface will be as shown below:

GDPR Cookie consent-Adding custom script blocker

GDPR Cookie consent-Adding custom script blocker

Two new additional script blockers namely Google Translator and Recaptcha are appended along with the existing service script blockers.
  • Was this article helpful ?
  • YesNo