Below, you’ll find a detailed guide on how to add the GDPR 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 GDPR Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the GDPR Plugin and the shortcodes it provides:
"GDPR is a vital WordPress plugin designed to ensure your website's compliance with EU's General Data Protection Regulation. It simplifies privacy and consent management, giving users control over their data."
- [gdpr_preferences]
- [gdpr_request_form]
GDPR [gdpr_preferences] Shortcode
The ‘gdpr_preferences’ shortcode is a crucial part of the GDPR plugin. It allows users to manage their privacy preferences on the website. This shortcode generates a ‘Privacy Preferences’ button, which when clicked, opens a tab (‘gdpr-consent-management’) where users can customize their privacy settings.
Shortcode: [gdpr_preferences]
Parameters
Here is a list of all possible gdpr_preferences shortcode parameters and attributes:
text
– Defines the display text for the privacy preference link.tab
– Specifies the default tab to show when privacy preferences are opened.
Examples and Usage
Basic example – Showcases the default usage of the GDPR preferences shortcode.
[gdpr_preferences]
With this basic usage, the shortcode will display the GDPR preferences with the default text “Privacy Preferences” and the default tab “gdpr-consent-management”.
Advanced examples
Customizing the GDPR preferences shortcode by changing the ‘text’ attribute.
[gdpr_preferences text="My Privacy Settings"]
In this example, the text that appears for the GDPR preferences will be “My Privacy Settings” instead of the default “Privacy Preferences”.
Further customization of the GDPR preferences shortcode by changing both ‘text’ and ‘tab’ attributes.
[gdpr_preferences text="My Privacy Settings" tab="my-custom-tab"]
This advanced usage changes both the text and the tab that is displayed by default. The text will now be “My Privacy Settings” and the tab will be “my-custom-tab” instead of the default “gdpr-consent-management”.
PHP Function Code
In case you have difficulties debugging what causing issues with [gdpr_preferences]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'gdpr_preferences', 'gdpr_preferences_shortcode' );
Shortcode PHP function:
function gdpr_preferences_shortcode( $atts ) {
$atts = shortcode_atts(
array(
'text' => esc_html__( 'Privacy Preferences', 'gdpr' ),
'tab' => 'gdpr-consent-management',
), $atts, 'gdpr_preferences'
);
ob_start();
gdpr_preferences( $atts['text'], $atts['tab'] );
return ob_get_clean();
}
Code file location:
gdpr/gdpr/includes/helper-functions.php
GDPR [gdpr_request_form] Shortcode
The GDPR Request Form shortcode allows users to create a customizable GDPR request form. This shortcode is adaptable, allowing users to specify the type of request and text displayed. The PHP code associated with this shortcode uses the ‘shortcode_atts’ function to define the attributes ‘type’ and ‘text’. These attributes are then passed to the ‘GDPR_Requests_Public::request_form’ function, generating a GDPR request form as per user specifications.
Shortcode: [gdpr_request_form]
Parameters
Here is a list of all possible gdpr_request_form shortcode parameters and attributes:
type
– Determines the type of GDPR request to be madetext
– Provides additional text to be displayed with the form
Examples and Usage
Basic example – A GDPR request form shortcode without any parameters. It will use the default values set in the function.
[gdpr_request_form /]
Advanced examples
1. Specifying the type of GDPR request form. The ‘type’ attribute allows you to define the type of GDPR request form to display. For example, you can specify ‘data_erasure’ to display a data erasure request form.
[gdpr_request_form type='data_erasure' /]
2. Customizing the text in the GDPR request form. The ‘text’ attribute allows you to customize the text displayed on the form. For instance, you can specify ‘Please delete my data’ to display this message on the form.
[gdpr_request_form text='Please delete my data' /]
3. Combining multiple attributes. You can also combine multiple attributes to customize your GDPR request form. Here is an example of a data erasure request form with a custom text.
[gdpr_request_form type='data_erasure' text='Please delete my data' /]
PHP Function Code
In case you have difficulties debugging what causing issues with [gdpr_request_form]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'gdpr_request_form', 'gdpr_request_form_shortcode' );
Shortcode PHP function:
function gdpr_request_form_shortcode( $atts ) {
$atts = shortcode_atts(
array(
'type' => '',
'text' => '',
), $atts, 'gdpr_request_form'
);
return GDPR_Requests_Public::request_form( $atts['type'], $atts['text'] );
}
Code file location:
gdpr/gdpr/includes/helper-functions.php
Conclusion
Now that you’ve learned how to embed the GDPR 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.
Leave a Reply