consentmanager Shortcodes

Below, you’ll find a detailed guide on how to add the consentmanager Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the consentmanager Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the consentmanager Plugin and the shortcodes it provides:

Plugin Icon
consentmanager

"ConsentManager is a WordPress plugin designed to simplify user consent management. It ensures GDPR compliance by helping you track and manage user permissions efficiently."

★★★✩✩ (7) Active Installs: 4000+ Tested with: 6.2.3 PHP Version: 5.4
Included Shortcodes:
  • [consentmanager_vendors]
  • [consentmanager_cookies]

consentmanager [consentmanager_vendors] Shortcode

The Consent Manager shortcode facilitates vendor list display. It fetches vendor details from the specified host or ‘delivery.consentmanager.net’ if no host is defined. The shortcode retrieves data based on the Consent Manager ID or Code ID. It then embeds this data within a div element for display, ensuring compliance with user consent laws.

Shortcode: [consentmanager_vendors]

Parameters

Here is a list of all possible consentmanager_vendors shortcode parameters and attributes:

  • cmpID – Numerical value representing the consent manager’s ID.
  • cmpCodeID – String value used to identify the consent manager’s code.
  • host – String value representing the host of the consent manager.

Examples and Usage

Basic example – The shortcode displays a list of vendors managed by the consent manager plugin.

[consentmanager_vendors /]

Advanced examples

The first advanced example shows how to use the shortcode with a specific Consent Manager ID. The list of vendors will be retrieved based on this ID.

[consentmanager_vendors id=123 /]

The second advanced example shows how to use the shortcode with a specific Consent Manager Code ID. The list of vendors will be retrieved based on this Code ID.

[consentmanager_vendors cdid="abc123" /]

Lastly, this example shows how to use the shortcode with a specific host. The list of vendors will be retrieved from this host.

[consentmanager_vendors host="delivery.consentmanager.net" /]

Note: These examples assume that the ‘consentmanager_vendors’ shortcode is registered and the related function ‘consentmanager_vendorlist_shortcode’ is properly defined in your theme’s functions.php file or in a custom plugin.

PHP Function Code

In case you have difficulties debugging what causing issues with [consentmanager_vendors] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('consentmanager_vendors', 'consentmanager_vendorlist_shortcode');

Shortcode PHP function:

function consentmanager_vendorlist_shortcode()
    {
        $cmpID = intval(get_option(ConsentManagerMain::getOptionID(), 0));
        $cmpCodeID = esc_attr(get_option(ConsentManagerMain::getOptionCodeID(), ''));
        $host = esc_attr(get_option(ConsentManagerMain::getOptionHost(), ''));
        if ($host == '') {
            $host = esc_attr(get_option(ConsentManagerMain::getHost(), 'delivery.consentmanager.net'));
        }

        if ($cmpCodeID != '') {
            $src = esc_url('https://' . $host . '/delivery/vendorlist.php?cdid=' . $cmpCodeID);
            return esc_html('<div id="cmpvendorlist"></div><script src="' . $src . '" type="text/javascript" async></script>');
        } else if ($cmpID > 0) {
            $src = esc_url('https://' . $host . '/delivery/vendorlist.php?id=' . $cmpID);
            return esc_html('<div id="cmpvendorlist"></div><script src="' . $src . '" type="text/javascript" async></script>');
        }
    }

Code file location:

consent-manager/consent-manager/consentmanager.php

consentmanager [consentmanager_cookies] Shortcode

The Consent Manager shortcode is a tool that fetches and displays cookie information. It retrieves data from the Consent Manager’s server, based on the given cmpID or cmpCodeID. It utilizes the WordPress esc_attr and esc_url functions to sanitize the URL, ensuring a secure connection. If no host is specified, it defaults to ‘delivery.consentmanager.net’.

Shortcode: [consentmanager_cookies]

Parameters

Here is a list of all possible consentmanager_cookies shortcode parameters and attributes:

  • cmpID – unique identifier for the consent manager plugin
  • cmpCodeID – specific code for the consent manager plugin
  • host – the host server for the consent manager plugin

Examples and Usage

Basic example – Utilize the default settings of the consent manager to display cookie information.

[consentmanager_cookies /]

PHP Function Code

In case you have difficulties debugging what causing issues with [consentmanager_cookies] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('consentmanager_cookies', 'consentmanager_cookie_list_shortcode');

Shortcode PHP function:

function consentmanager_cookie_list_shortcode()
    {
        $cmpID = intval(get_option(ConsentManagerMain::getOptionID(), 0));
        $cmpCodeID = esc_attr(get_option(ConsentManagerMain::getOptionCodeID(), ''));
        $host = esc_attr(get_option(ConsentManagerMain::getOptionHost(), ''));
        if ($host == '') {
            $host = esc_attr(get_option(ConsentManagerMain::getHost(), 'delivery.consentmanager.net'));
        }

        if ($cmpCodeID != '') {
            $src = esc_url('https://' . $host . '/delivery/cookieinfo.php?cdid=' . $cmpCodeID);
            return esc_html('<div id="cmpcookieinfo"></div><script src="' . $src . '" type="text/javascript" async></script>');
        } else if ($cmpID > 0) {
            $src = esc_url('https://' . $host . '/delivery/cookieinfo.php?id=' . $cmpID);
            return esc_html('<div id="cmpcookieinfo"></div><script src="' . $src . '" type="text/javascript" async></script>');
        }
    }

Code file location:

consent-manager/consent-manager/consentmanager.php

Conclusion

Now that you’ve learned how to embed the consentmanager Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *