开发者 |
nateconley
brandondove jeffreyzinn |
---|---|
更新时间 | 2022年1月15日 08:47 |
PHP版本: | 5.6 及以上 |
WordPress版本: | 5.8.3 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
[gdpr_visitor_consent]
to create a user preferences page. Using this shortcode, a user can change their GDPR preferences at a later date.
Developer API
You can add your script in a dropdown in the admin screen using the filter gdprvc_third_party_script( $scripts );
Example (PHP):
`function add_third_party_script( $scripts ) {
$scripts[] = array(
'slug' => 'third-party-script',
'label' => 'Script Label',
);
return $scripts;
}
add_filter( 'gdprvc_third_party_scripts', 'add_third_party_script', 10, 1 );
`
You can then use the JavaScript API in the browser to control your scripts on the front-end
Example (JavaScript):
`window.gdprvc_is_accepted( 'slug' );
// returns true/false`
You can also use our helper function to parse your script containing <script>
and <img>
tags. This will automatically place your JavaScript in a conditional and remove src
attributes until a user has consented.
Example (PHP):
`
add_action( 'wp_head', 'your_wp_head' );
function your_wp_head() {
// Check for GDPR Visitor Consent Plugin
if ( function_exists( 'gdprvc_parse_script' ) ) {
echo gdprvc_parse_script( 'your script as a string', 'slug' );
return;
}
// Echo normally if plugin is not active
echo 'your script as a string';
}
`
Browser Compatibility
Chrome
✓ Admin Editing
✓ Front-end functionality
✓ Front-end styles
Firefox
✓ Admin Editing
✓ Front-end functionality
✓ Front-end styles
Safari
✓ Admin Editing
✓ Front-end functionality
✓ Front-end styles
Edge
✓ Admin Editing
✓ Front-end functionality
✓ Front-end styles
IE11
✘ Admin Editing
✓ Front-end functionality
✓ Front-end styles
IE10
✘ Admin Editing
✓ Front-end functionality
✘ Front-end styles
IE9
✘ Admin Editing
✓ Front-end functionality
✘ Front-end styles
gdpr-visitor-consent.php
to the /wp-content/plugins/
directory= Does this plugin control scripts from other plugins? GDPR Visitor Consent provides an API for third-party developers to integrate their scripts into this plugin. = What happens if I add a new script after I have already published my scripts? Simply check "Force users to re-consent" before saving your scripts. This will force users who have already saved their preferences to opt-in to your new scripts. Re-consenting still loads a user's previous preferences. As of version 1.1.0, yes! GDPR Visitor Consent is JavaScript-based and uses the localStorage API.
You may insert <script>
tags and <img>
tags. Sometimes, <img>
tags are surrounded by <noscript>
. This works, too.