Support » Plugin: Cookie Notice for GDPR » 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) 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)

    (@otto42)

    WordPress.org Admin

    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.

    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.