Support Forum › Support Forum › GDPR Cookie Compliance › iframe support when created by shortcode or javascript
- AuthorPosts
- September 09, 2021 @ 7:06 pm
We have some PHP code and html in a template that creates iframes for youtube and twitter. How do we convert these as they are not in the WP editor? The code snippets are:
<?php echo do_shortcode(“[embedyt] https://www.youtube.com/embed?listType=playlist&list=xxxxxxxxxxxxxx&layout=gallery%5B/embedyt%5D”); ?>
and
Tweets by xxxxxxx <script async src=”https://platform.twitter.com/widgets.js” charset=”utf-8″></script>
Both create iframes that we want to have disabled via GDPR Cookie plugin when the website is first loaded
Moove Agency
September 10, 2021 @ 5:52 amHi Mike,
Thanks for using our plugins.
You try one of the following methods:
1. You can use a shortcode
[gdpr_iframe_blocker] Put youtube iframe or URL here [/gdpr_iframe_blocker]
if the Custom Field you are using supports shortcodes.2. In your code where you display the custom field value, you can use the following action:
$content = apply_filters( ‘gdpr_iframe_blocker_filter’, $content );
where$content
is your custom field value.3. If the above doesn’t work, you can try to add the following code snippet to your theme’s functions.php file:
add_filter( 'the_content', array( 'Moove_GDPR_Addon_Actions', 'gdpr_block_content_iframes' ), 100, 1 );
Hope this helps.
ThanksPremiumSeptember 10, 2021 @ 7:56 amHi,
Thanks for reply I have just noticed that the forum editor has mashed up my original post a bit.
The first iframe I have is already in a do_shortcode i.e. echo do_shortcode(“[embedyt]…… How can I wrap the existing do_shortcode with your [gdpr_iframe_blocker] shortcode?
The second iframe content is hard coded HTML in a php file so I tried option 2 and put the text into a variable then try to apply the filter. That did not work. The HTML is Tweets by xxxx <script async src=”https://platform.twitter.com/widgets.js” charset=”utf-8″></script>
PremiumSeptember 10, 2021 @ 8:00 amSorry the editor is wiping out my HTML it is actually an “a” tag with the twitter link in the href and a script file invoking a twitter js file. I have put the whole of that into a PHP variable and applied the filter. The twitter cookie has still been laid down.
Moove Agency
September 13, 2021 @ 6:52 amHi Mike,
More info about Twitter iframe is here:
Hope this helps.
- AuthorPosts
The topic ‘iframe support when created by shortcode or javascript’ is closed to new replies.