Skip to main content
  1. All Posts/


Tools Open Source PHP WordPress

WordPress Consent Tools Server & Administration for Adretto

A backend for the consent-tools library in WordPress using Adretto.


via composer:

> composer require sillynet/adretto-consent-tools

This library is an extension to the Adretto
Wordpress ADR framework, so you will need to have Adretto installed and set up.
Make sure you have Composer autoload or an alternative class loader present.

Carbon Fields

This packages uses CarbonFields to generate
the settings page. Unfortunately CarbonFields can be somewhat tricky to set up
when used outside a theme’s root directory.
If your theme files live in public/wp-content/themes/<yourtheme>/, and you
have your composer.json and vendor/ directory there, you’re fine.

If you however maintain your Composer dependencies outside of the theme
directory, or use some symlink setup, you might be in trouble. The simplest
solution is to add a step to your setup and build process to make CF’s JS and
CSS assets publicly available at a known path:

  1. As part of your build pipeline, copy the entire vendor/htmlburger/carbon-fields
    directory into public/wp-content (or you could copy just the *.js and
    *.css files, but you’ll have to keep the directory structure). A simple
    solution is to actually use your theme directory, so let’s use
    public/wp-content/themes/<mytheme>/vendor/cf as an example.
  2. Tell CarbonFields where it can find its assets by setting a constant before
    CF is “booted”, somewhere near the top of your functions.php would work
    fine in most scenarios:

    define('Carbon_FieldsDIR', get_theme_file_path('vendor/cf'));


Load the extension in your Adretto configuration file:

# .config.yaml
  - Sillynet\ConsentTools\ConsentToolsExtension

You will find a settings page under the WordPress general settings tab where
you can configure the consent management services for
When setting up consent-tools you can retrieve the configuration via
/wp-json/sillynet/v1/consent-management/config?lang=en, which will return an
object with the following shape:

type ServiceConfig = {
    // regular fields
    prettyName?: string;           // The pretty name for the service as it
                                   // should be shown to user, in placeholder
                                   // templates or settings modals
    cmpServiceId?: string;         // The ID of this service as defined by
                                   // by the CMP used. If you're running
                                   // consent-tools in standalone mode,
                                   // this can simply be ignored.
    privacyPolicySection?: string; // An anchor for linking to this specific
                                   // service's section on the privacy policy
                                   // page.
    // translated fields, these will differ based on the requested language
    // ("en" in this example)
    titleText?: string;             // override for default titleText below
    buttonText?: string;            // override for default buttonText below
    description?: string;           // override for default description below

type ConsentToolsConfig = {
    default: {
        titleText: string;          // Default text to be displayed in the
                                    // placeholder element's heading if not
                                    // overridden by the service's config.
        description: string;        // Default text to be displayed in the
                                    // placeholder element's body. May contain
                                    // %templateTags%.
        buttonText: string;         // Default text to be displayed in the
                                    // placeholder element's "consent" button.
    types: {
        [serviceId: string]: ServiceConfig



  • PHP >= 7.4
  • Composer 2.x
  • NVM and nodeJS LTS (v16.x)
  • Nice to have: GNU Make (or drop-in alternative)


Most everyday development tasks are covered in the Makefile.