Adding filters with MU Plugins. Quick & Easy

More functionalities for Complianz

Aert

Aert

Junior Developer & Support

Categories

Most Popular Articles

Subscribe to our newsletter

    For EU Subscribers | Privacy Statement
    For USA Subcribers | Privacy Statement

  • This field is for validation purposes and should be left unchanged.

You might want to change your Cookie Banner Read more URL or have your placeholders when using Complianz. To edit some features of Complianz, you will need to apply some extra code to your WordPress installation. Below we will explain how you can use so-called Must-Use plugins to apply these filters.

Do you want to know which functionalities you can add to Complianz? Visit our overview of the features and code snippets.

How to implement filters with Must-Use plugins.

Must-Use plugins, in short, is a folder in WP-Content called ‘mu-plugins’ which is a collection of files which are activated by default and cannot be deactivated in your WordPress dashboard. These files will stay put and activated even if you’re updating your WordPress installation or theme.

If you don’t have a mu-plugins folder in wp-content, you can simply open your FTP client, then add the folder under the wp-content directory. The result should look like */wp-content/mu-plugins/

To add a filter described in our hooks and filters overview you can copy/paste the code to your favorite text editor and change the variables as described in the code. 

For example:

Do you want to unset a service from the Cookie Blocker so it will load before consent? You should copy/paste the below code in your text editor and change my-blocked-script-tag.js to the social marker you would like to unset.

/**
 function cmplz_edit_script_tags($script_tags){
    if (($key = array_search('my-blocked-script-tag.js',
        $script_tags)) !== false) {
        unset($script_tags[$key]);
    }
    return $script_tags;
}
add_filter('cmplz_known_script_tags', 'cmplz_edit_script_tags');

How to find you marker?

For Chrome:

  1. Right click
  2. Click Inspect
  3. Find “Sources” in the top navigation.
  4. Search for the URL corresponding to your service on the left hand side under “Page”.
  5. Find the URL in our list markers, see below for markers by category.
  6. Use the URL to unset this specific service.

Social Markers | Google Services

google.com/recaptcha
grecaptcha
recaptcha.js
recaptcha/api.js
www.google-analytics.com/analytics.js
google-analytics.com/ga.js
new google.maps.
maps.googleapis.com
gmw.map.min.js
gmw.js
new GMW_Map
google_ad_client //google adsense
pagead/js/adsbygoogle.js //google adsense
doubleclick.net //google adsense
googlesyndication.com //google adsense
googletagmanager.com/gtag/js
googleads.g.doubleclick.net
google.com/maps/embed
maps.google.com

Social Markers | LinkedIn

platform.linkedin.com

NB. This is an async script tag and needs another filter.

Social Markers | Twitter

platform.twitter.com/widgets.js

twitter-widgets.js

platform.twitter.com

Social Markers | Facebook

connect.facebook.net

www.facebook.com/plugins

facebook.com/plugins

Social Markers | Pinterest

assets.pinterest.com

Social Markers | Instagram

instawidget.net/js/instawidget.js

cdninstagram.com

instagram.com

www.instagram.com/embed.js

instagram.com/embed.js

plugins/instagram-feed/js/sb-instagram.min.js

Social Markers | Disqus

disqus.com

Social Markers | Other

w.soundcloud.com/player
player.vimeo.com
youtube.com
videopress.com/embed
videopress.com/videopress-iframe.js
dailymotion.com/embed/video/
static.hotjar.com
open.spotify.com/embed
fonts.googleapis.com
super-socializer //super socializer
theChampFBKey //super socializer
addthis.com
sharethis.com
advads_tracking_ads
cdn.livechatinc.com/tracking.js
dataset.sumoSiteId

Saving your new filter and uploading it with FTP

  1. After editing the filter, save your file ending with .php. For example unsetservice.php
  2. Upload unsetservice.php to wp-content/mu-plugins/ via FTP
  3. Check if the service will be set before consent.

 Done!

Below you can find an example of the code you need if you want to prevent Complianz from blocking Dailymotion. The string as listed above is inserted in the code, then this code is placed in a mu-plugin.

Not sure what to add in the variables? Ask support, we are happy to help!

/**
 function cmplz_edit_script_tags($script_tags){
    if (($key = array_search('dailymotion.com/embed/video/',
        $script_tags)) !== false) {
        unset($script_tags[$key]);
    }
    return $script_tags;
}
add_filter('cmplz_known_script_tags', 'cmplz_edit_script_tags');
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.

© Copyright - Complianz 2019
×

Complianz Privacy Suite 3.1 is live!

See our new features and available documentation. Read more