This document explains how the CookieBot plugin can be expanded with addons to block cookies set by specific third-party WordPress Themes and Plugins.
Every addon is contained in its own class.
- All addon classes should be located in a subdirectory of src/addons/controller/addons
- Addon classes for third party plugins should extend the
Base_Cookiebot_Plugin_Addon
abstract class. - Addon classes for third party themes should extend the
Base_Cookiebot_Theme_Addon
abstract class. - There is also a miscellaneous
Base_Cookiebot_Other_Addon
abstract class, which is used for WordPress core features like embedded videos.
Addons can return a different addon class for each incompatible version.
- The
ALTERNATIVE_ADDON_VERSIONS
class constant should contain an array of strings. - Each array key should correspond to a valid semver version number of the plugin or theme.
- Each array value should point to the classname of the addon for that previous plugin/theme version.
- One example is the Custom_Facebook_Feed addon, which had to block its cookies in a different manner for an older version
- Add a new addon to src/addons/addons.php
- Create a directory in src/addons/controller/addons
- Create a class in that new directory (copy class from another addon and adjust the namespace, classname, interfaces and methods.)
- Edit the
load_addon_configuration
method. This is the only method that needs to be worked on in order to block the cookies. - Update all variables and methods according to the addon plugin.
- Test
- Create integration test if you did use dependencies from the addon plugin. (We run daily tests to see if the dependencies from the addons plugin are still valid.)
- Send a pull-request in github
-
New addon to src/addons/addons.php
Litespeed_Cache::class, matomo::class, Instagram_Feed::class, Add_To_Any::class,
-
Create directory 'add_to_any' in src/addons/controller/addons
-
Create a class 'Add_To_Any' in 'add_to_any' directory (copy class from another addon and rename everything accordingly)
-
Go to 'load_addon_configuration' method. Write your cookie-blocking logic in that function. You can find more information about how to block cookies in how-to-block-cookies.
-
Test if the cookies are blocked.
-
Create integration test for the addon dependencies: https://github.com/CybotAS/CookiebotAddons/blob/develop/tests/integration/addons/test-add-to-any.php
-
Send a pull-request to our github repository.