Title: GDPR iframe blocking
Last modified: March 30, 2018

---

# GDPR iframe blocking

 *  [marties](https://wordpress.org/support/users/marties/)
 * (@marties)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/gdpr-iframe-blocking/)
 * hi, first of all thanks a lot for your cool plugin, i’ve been strugling to find
   a GDPR compliant cookie banner which could allow to block **everything i want**.
 * i use a forecast weather iframe that i used to insert _via_ a widget on some 
   website and guess what, it puts a damn cookie just after loading…
 * the solution here is to create a plugin (i am largeeely inspired by [Ottopress](http://ottopress.com/2017/on-the-topic-of-that-pesky-widget/))
   and make the test inside :
 * `if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) { echo'
   the code of your iframe or whatever you want to output';}`
 * **Here is the full plugin code:**
 *     ```
       <?php
       /*
       Plugin Name: the name of your plugin to work with Cookie notice by dFactory
       */
       add_action( 'widgets_init', 'ottopress_widget_register' );
       function ottopress_widget_register() {
           register_widget( 'Ottopress_Widget' );
       }
       class Ottopress_Widget extends WP_Widget {
           function __construct() {     
               $class = 'widget_youriframe';
               $name = 'Widget Youriframe';         
               $widget_ops = array('classname' => $class, 'description' => $name);
               $control_ops = array('width' => 400, 'height' => 350);
               parent::__construct('', $name, $widget_ops, $control_ops);
           }
   
           function widget( $args, $instance ) {
               extract($args);
               if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) {
               echo $before_widget; 
               echo 'YOUR IFRAME CODE'; 
               echo $after_widget;
               }
           }
       }
       ```
   
 * Hope that helps

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [8 years, 2 months ago](https://wordpress.org/support/topic/gdpr-iframe-blocking/#post-10132051)
 * I would suggest that you don’t use “ottopress”. I used that in my examples because
   it’s something I own the domain for.
 * Switch it out to your own domain instead, so you don’t run into conflicts with
   others. Your domain is unique to you, after all. Best to keep custom things unique
   to you and your site.
 *  Thread Starter [marties](https://wordpress.org/support/users/marties/)
 * (@marties)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/gdpr-iframe-blocking/#post-10132179)
 * yes of course, it was just for the example but it’s always better to give good
   examples.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘GDPR iframe blocking’ is closed to new replies.

 * ![](https://ps.w.org/cookie-notice/assets/icon-256x256.png?rev=3549327)
 * [Compliance by Hu-manity.co](https://wordpress.org/plugins/cookie-notice/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cookie-notice/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cookie-notice/)
 * [Active Topics](https://wordpress.org/support/plugin/cookie-notice/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cookie-notice/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cookie-notice/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [marties](https://wordpress.org/support/users/marties/)
 * Last activity: [8 years, 2 months ago](https://wordpress.org/support/topic/gdpr-iframe-blocking/#post-10132179)
 * Status: not a support question