Italy Cookie Choices (for EU Cookie Law) - Version 2.4.0

Version Description

Release Date: August 31th, 2015

Dev time: 11h

  • Added import/export functionality
  • Maybe fixed #133
  • Fixed PHP check for lang functions #128
Download this release

Release Info

Developer overclokk
Plugin Icon Italy Cookie Choices (for EU Cookie Law)
Version 2.4.0
Comparing to
See all releases

Code changes from version 2.3.5 to 2.4.0

admin/class-italy-cookie-choices-admin-pointer-init.php CHANGED
@@ -45,7 +45,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Pointer_Init' ) ) {
45
  * @return mixed
46
  */
47
  function custom_initial_pointers( $pointers, $prefix ) {
48
-
49
  // * Default parameters:
50
  // $defaults = array(
51
  // 'class' => 'pointerplus',
@@ -60,22 +60,51 @@ if ( !class_exists( 'Italy_Cookie_Choices_Pointer_Init' ) ) {
60
  // );
61
 
62
 
63
- return array_merge( $pointers, array(
64
- $prefix . '_settings' => array(
65
- 'selector' => '#active',
66
- 'title' => __( 'Radio 1', 'italy-cookie-choices' ),
67
- 'text' => __( 'The plugin is active and ready to start working.', 'italy-cookie-choices' ),
68
- 'width' => 260,
69
- 'icon_class' => 'dashicons-admin-settings',
70
- 'jsnext' => "button = jQuery('<a id=\"pointer-close\" class=\"button action thickbox\" href=\"#TB_inline?width=700&height=500&inlineId=menu-popup\">" . __( 'Open Popup' ) . "</a>');
71
- button.bind('click.pointer', function () {
72
- t.element.pointer('close');
73
- });
74
- return button;",
75
- 'phpcode' => $this->custom_phpcode_thickbox()
76
- ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  $prefix . '_posts' => array(
78
- 'selector' => '#menu-posts',
79
  'title' => __( 'Italy_Cookie_Choices_Pointer for Posts', 'italy-cookie-choices' ),
80
  'text' => __( 'One more pointer.', 'italy-cookie-choices' ),
81
  'post_type' => array( 'post' ),
@@ -96,7 +125,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Pointer_Init' ) ) {
96
  'pages' => array( 'users.php' ),
97
  'icon_class' => 'dashicons-admin-users'
98
  ),
99
- $prefix . '_settings_tab' => array(
100
  'selector' => '#show-settings-link',
101
  'title' => __( 'Italy_Cookie_Choices_Pointer Help', 'italy-cookie-choices' ),
102
  'text' => __( 'A pointer with action.', 'italy-cookie-choices' ),
@@ -110,14 +139,18 @@ if ( !class_exists( 'Italy_Cookie_Choices_Pointer_Init' ) ) {
110
  });
111
  return button;"
112
  ),
113
- $prefix . '_contextual_tab' => array(
114
- 'selector' => '#contextual-help-link',
 
 
 
 
115
  'title' => __( 'Italy_Cookie_Choices_Pointer Help', 'italy-cookie-choices' ),
116
  'text' => __( 'A pointer for help tab.<br>Go to Posts, Pages or Users for other pointers.', 'italy-cookie-choices' ),
117
  'edge' => 'top',
118
  'align' => 'right',
119
  'icon_class' => 'dashicons-welcome-learn-more',
120
- 'show' => 'close'
121
  )
122
  ) );
123
  }
@@ -130,18 +163,16 @@ if ( !class_exists( 'Italy_Cookie_Choices_Pointer_Init' ) ) {
130
  * @link https://codex.wordpress.org/Javascript_Reference/ThickBox
131
  * @return string Return modal fro thickbox
132
  */
133
- function custom_phpcode_thickbox() {
134
- add_thickbox();
135
- echo '<div id="menu-popup" style="display:none;">
136
- <p style="text-align: center;">
137
- This is my hidden content! It will appear in ThickBox when the link is clicked.
138
- <iframe width="560" height="315" src="https://www.youtube.com/embed/EaWfDuXQfo0" frameborder="0" allowfullscreen></iframe>
139
- </p>
140
- </div>';
141
  }
142
 
143
-
144
-
145
-
146
  }
 
147
  }
45
  * @return mixed
46
  */
47
  function custom_initial_pointers( $pointers, $prefix ) {
48
+
49
  // * Default parameters:
50
  // $defaults = array(
51
  // 'class' => 'pointerplus',
60
  // );
61
 
62
 
63
+ return array_merge( $pointers, array(
64
+ $prefix . '_settings' => array(
65
+ 'selector' => '#active',
66
+ 'title' => __( 'Radio 1', 'italy-cookie-choices' ),
67
+ 'text' => __( 'The plugin is active and ready to start working.', 'italy-cookie-choices' ),
68
+ 'width' => 260,
69
+ 'icon_class' => 'dashicons-admin-settings',
70
+ 'jsnext' => "button = jQuery('<a id=\"pointer-close\" class=\"button action\">" . __( 'Next' ) . "</a>');
71
+ button.bind('click.pointer', function () {
72
+ t.element.pointer('close');
73
+ jQuery('#label_radio_1').pointer('open');
74
+ });
75
+ return button;",
76
+ // 'phpcode' => $this->custom_phpcode_thickbox( 'https://www.youtube.com/embed/EaWfDuXQfo0' )
77
+ ),
78
+ $prefix . '_settings1' => array(
79
+ 'selector' => '#label_radio_1',
80
+ 'title' => __( 'Radio 1', 'italy-cookie-choices' ),
81
+ 'text' => __( 'The plugin is active and ready to start working.', 'italy-cookie-choices' ),
82
+ 'width' => 260,
83
+ 'icon_class' => 'dashicons-admin-settings',
84
+ // 'jsnext' => "button = jQuery('<a id=\"pointer-close\" class=\"button action\">" . __( 'Next' ) . "</a>');
85
+ // button.bind('click.pointer', function () {
86
+ // t.element.pointer('close');
87
+ // jQuery('#contextual-help-link').pointer('open');
88
+ // });
89
+ // return button;",
90
+ // 'phpcode' => $this->custom_phpcode_thickbox()
91
+ 'show' => 'close'
92
+ ),
93
+ $prefix . '_settings11' => array(
94
+ 'selector' => '#label_radio_111',
95
+ 'title' => __( 'Radio 2', 'italy-cookie-choices' ),
96
+ 'text' => __( 'The plugin is active and ready to start working.', 'italy-cookie-choices' ),
97
+ 'width' => 260,
98
+ 'icon_class' => 'dashicons-admin-settings',
99
+ 'jsnext' => "button = jQuery('<a id=\"pointer-close\" class=\"button action thickbox\" href=\"#TB_inline?width=700&height=500&inlineId=menu-popup\">" . __( 'Open Popup' ) . "</a>');
100
+ button.bind('click.pointer', function () {
101
+ t.element.pointer('close');
102
+ });
103
+ return button;",
104
+ 'phpcode' => $this->custom_phpcode_thickbox( 'https://www.youtube.com/embed/EaWfDuXQfo0' )
105
+ ),
106
  $prefix . '_posts' => array(
107
+ 'selector' => '#radio_1',
108
  'title' => __( 'Italy_Cookie_Choices_Pointer for Posts', 'italy-cookie-choices' ),
109
  'text' => __( 'One more pointer.', 'italy-cookie-choices' ),
110
  'post_type' => array( 'post' ),
125
  'pages' => array( 'users.php' ),
126
  'icon_class' => 'dashicons-admin-users'
127
  ),
128
+ $prefix . '_settings_tab1' => array(
129
  'selector' => '#show-settings-link',
130
  'title' => __( 'Italy_Cookie_Choices_Pointer Help', 'italy-cookie-choices' ),
131
  'text' => __( 'A pointer with action.', 'italy-cookie-choices' ),
139
  });
140
  return button;"
141
  ),
142
+ /**
143
+ * $prefix . '_my_custom_id'
144
+ * per ogni pointer deve essere univoco
145
+ */
146
+ $prefix . '_contextual_tab1' => array(
147
+ 'selector' => '#contextual-help-link', // Il selettore css dove appendere il pointer, può essere un ID o una classe CSS
148
  'title' => __( 'Italy_Cookie_Choices_Pointer Help', 'italy-cookie-choices' ),
149
  'text' => __( 'A pointer for help tab.<br>Go to Posts, Pages or Users for other pointers.', 'italy-cookie-choices' ),
150
  'edge' => 'top',
151
  'align' => 'right',
152
  'icon_class' => 'dashicons-welcome-learn-more',
153
+ 'show' => 'close' // Serve per non visualizzare il pointer nella pagina, utile per usarlo insieme al pulsante next
154
  )
155
  ) );
156
  }
163
  * @link https://codex.wordpress.org/Javascript_Reference/ThickBox
164
  * @return string Return modal fro thickbox
165
  */
166
+ function custom_phpcode_thickbox( $url = '' ) {
167
+ add_thickbox();
168
+ echo '<div id="menu-popup" style="display:none;">
169
+ <p style="text-align: center;">
170
+ This is my hidden content! It will appear in ThickBox when the link is clicked.
171
+ <iframe width="560" height="315" src="' . $url . '" frameborder="0" allowfullscreen></iframe>
172
+ </p>
173
+ </div>';
174
  }
175
 
 
 
 
176
  }
177
+
178
  }
admin/class-italy-cookie-choices-admin-pointer.php CHANGED
@@ -1,13 +1,11 @@
1
  <?php
2
-
3
  /**
4
  * Class Italy_Cookie_Choices_Pointer based on QL_Pointer to facilitate creation of WP Pointers
5
  * @author QueryLoop
6
  */
7
  // Exit if accessed directly
8
- if ( !defined( 'ABSPATH' ) ) {
9
  exit;
10
- }
11
 
12
  class Italy_Cookie_Choices_Pointer {
13
 
@@ -15,7 +13,7 @@ class Italy_Cookie_Choices_Pointer {
15
  * Prefix strings like styles, scripts and pointers IDs
16
  * @var string
17
  */
18
- protected $prefix = 'pointerplus';
19
  protected $pointers = array();
20
 
21
  function __construct( $args = array() ) {
1
  <?php
 
2
  /**
3
  * Class Italy_Cookie_Choices_Pointer based on QL_Pointer to facilitate creation of WP Pointers
4
  * @author QueryLoop
5
  */
6
  // Exit if accessed directly
7
+ if ( !defined( 'ABSPATH' ) )
8
  exit;
 
9
 
10
  class Italy_Cookie_Choices_Pointer {
11
 
13
  * Prefix strings like styles, scripts and pointers IDs
14
  * @var string
15
  */
16
+ protected $prefix = 'italy-cookie-choices';
17
  protected $pointers = array();
18
 
19
  function __construct( $args = array() ) {
admin/class-italy-cookie-choices-admin.php CHANGED
@@ -80,6 +80,11 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
80
  */
81
  add_filter( 'plugin_action_links_' . ITALY_COOKIE_CHOICES_BASENAME, array( $this, 'plugin_action_links' ) );
82
 
 
 
 
 
 
83
  }
84
 
85
  /**
@@ -155,20 +160,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
155
  if ( !current_user_can( $this->capability ) )
156
  wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
157
 
158
- ?>
159
- <div class="wrap">
160
-
161
- <form action='options.php' method='post' id='italy-cookie-choices-ID'>
162
-
163
- <?php
164
- settings_fields( 'italy_cl_options_group' );
165
- do_settings_sections( 'italy_cl_options_group' );
166
- submit_button();
167
- ?>
168
-
169
- </form>
170
- </div>
171
- <?php
172
 
173
  }
174
 
@@ -555,7 +547,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
555
 
556
  <input name="italy_cookie_choices[banner]" type="radio" value="1" id="radio_1" <?php checked( '1', $banner ); ?> />
557
 
558
- <label for="radio_1">
559
  <?php _e( 'Top Bar (Default, Display a top bar with your message)', 'italy-cookie-choices' ); ?>
560
  </label>
561
 
@@ -563,7 +555,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
563
 
564
  <input name="italy_cookie_choices[banner]" type="radio" value="2" id="radio_2" <?php checked( '2', $banner ); ?> />
565
 
566
- <label for="radio_2">
567
  <?php _e( 'Dialog (Display an overlay with your message)', 'italy-cookie-choices' ); ?>
568
  </label>
569
 
@@ -571,7 +563,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
571
 
572
  <input name="italy_cookie_choices[banner]" type="radio" value="3" id="radio_3" <?php checked( '3', $banner ); ?> />
573
 
574
- <label for="radio_3">
575
  <?php _e( 'Bottom Bar (Display a bar in the footer with your message)', 'italy-cookie-choices' ); ?>
576
  </label>
577
 
@@ -1041,6 +1033,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
1041
  <?php _e( 'Cookie from any embed in your widget area (Beta) (DEPRECATED)', 'italy-cookie-choices' ); ?>
1042
  </label>
1043
  <br>
 
1044
  <input type='checkbox' name='italy_cookie_choices[all_block]' <?php checked( $all_block, 1 ); ?> value='1' id="italy_cookie_choices[all_block]">
1045
  <label for="italy_cookie_choices[all_block]">
1046
  <?php _e( 'Cookie from any embed in all body, except head and footer (Beta)', 'italy-cookie-choices' ); ?>
@@ -1068,7 +1061,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
1068
  /**
1069
  * Template with list of code example
1070
  */
1071
- require(ITALY_COOKIE_CHOICES_PLUGIN_PATH . 'admin/template/code-example.php');
1072
 
1073
  ?>
1074
  <style type="text/css" media="screen">
@@ -1083,7 +1076,9 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
1083
  }*/
1084
  </style>
1085
  <!-- <div id="editor"><?php echo esc_textarea( $custom_script_block_body_exclude ); ?></div> -->
1086
-
 
 
1087
  <textarea rows="5" cols="70" name="italy_cookie_choices[custom_script_block_body_exclude]" id="italy_cookie_choices[custom_script_block_body_exclude]" placeholder="<?php _e( '&lt;script src=&quot;http://domain.com/widget-example.js&quot;&gt;&lt;/script&gt;'."\n".'&lt;---------SEP---------&gt;'."\n".'&lt;script src=&quot;http://otherdomain.com/script-example.js&quot;&gt;&lt;/script&gt;'."\n".'&lt;---------SEP---------&gt;'."\n".'&lt;script src=&quot;http://lastdomain.com/gadget-example.js&quot;&gt;&lt;/script&gt;', 'italy-cookie-choices' ) ?>" class="textarea"><?php echo esc_textarea( $custom_script_block_body_exclude ); ?></textarea>
1088
  <br>
1089
  <a id="SEP" class="button button-secondary add-sep" data-value="<---------SEP--------->">&lt;---------SEP---------&gt;</a>
@@ -1390,6 +1385,13 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
1390
  // wp_register_script('ace', '//cdn.jsdelivr.net/ace/1.1.9/min/ace.js', false, null, true);
1391
  // wp_enqueue_script('ace');
1392
 
 
 
 
 
 
 
 
1393
  wp_enqueue_script(
1394
  'italy-cookie-choices-script',
1395
  plugins_url('admin/js/src/script.js', ITALY_COOKIE_CHOICES_FILE ),
@@ -1421,5 +1423,92 @@ if ( !class_exists( 'Italy_Cookie_Choices_Admin' ) ){
1421
  return $links;
1422
  }// plugin_action_links()
1423
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1424
  }// class
1425
  }//endif
80
  */
81
  add_filter( 'plugin_action_links_' . ITALY_COOKIE_CHOICES_BASENAME, array( $this, 'plugin_action_links' ) );
82
 
83
+ //Add the export settings method
84
+ add_action( 'admin_init', array( $this, 'settings_export' ) );
85
+ //Add the import settings method
86
+ add_action( 'admin_init', array( $this, 'settings_import' ) );
87
+
88
  }
89
 
90
  /**
160
  if ( !current_user_can( $this->capability ) )
161
  wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
162
 
163
+ include_once( 'template/admin.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
164
 
165
  }
166
 
547
 
548
  <input name="italy_cookie_choices[banner]" type="radio" value="1" id="radio_1" <?php checked( '1', $banner ); ?> />
549
 
550
+ <label for="radio_1" id="label_radio_1">
551
  <?php _e( 'Top Bar (Default, Display a top bar with your message)', 'italy-cookie-choices' ); ?>
552
  </label>
553
 
555
 
556
  <input name="italy_cookie_choices[banner]" type="radio" value="2" id="radio_2" <?php checked( '2', $banner ); ?> />
557
 
558
+ <label for="radio_2" id="label_radio_2">
559
  <?php _e( 'Dialog (Display an overlay with your message)', 'italy-cookie-choices' ); ?>
560
  </label>
561
 
563
 
564
  <input name="italy_cookie_choices[banner]" type="radio" value="3" id="radio_3" <?php checked( '3', $banner ); ?> />
565
 
566
+ <label for="radio_3" id="label_radio_3">
567
  <?php _e( 'Bottom Bar (Display a bar in the footer with your message)', 'italy-cookie-choices' ); ?>
568
  </label>
569
 
1033
  <?php _e( 'Cookie from any embed in your widget area (Beta) (DEPRECATED)', 'italy-cookie-choices' ); ?>
1034
  </label>
1035
  <br>
1036
+ <br>
1037
  <input type='checkbox' name='italy_cookie_choices[all_block]' <?php checked( $all_block, 1 ); ?> value='1' id="italy_cookie_choices[all_block]">
1038
  <label for="italy_cookie_choices[all_block]">
1039
  <?php _e( 'Cookie from any embed in all body, except head and footer (Beta)', 'italy-cookie-choices' ); ?>
1061
  /**
1062
  * Template with list of code example
1063
  */
1064
+ // require(ITALY_COOKIE_CHOICES_PLUGIN_PATH . 'admin/template/code-example.php');
1065
 
1066
  ?>
1067
  <style type="text/css" media="screen">
1076
  }*/
1077
  </style>
1078
  <!-- <div id="editor"><?php echo esc_textarea( $custom_script_block_body_exclude ); ?></div> -->
1079
+
1080
+ <!-- <input type='checkbox' name='italy_cookie_choices[ppp]' <?php checked( $block, 1 ); ?> value='1' id="italy_cookie_choices[ppp]"> -->
1081
+ <!-- <br> -->
1082
  <textarea rows="5" cols="70" name="italy_cookie_choices[custom_script_block_body_exclude]" id="italy_cookie_choices[custom_script_block_body_exclude]" placeholder="<?php _e( '&lt;script src=&quot;http://domain.com/widget-example.js&quot;&gt;&lt;/script&gt;'."\n".'&lt;---------SEP---------&gt;'."\n".'&lt;script src=&quot;http://otherdomain.com/script-example.js&quot;&gt;&lt;/script&gt;'."\n".'&lt;---------SEP---------&gt;'."\n".'&lt;script src=&quot;http://lastdomain.com/gadget-example.js&quot;&gt;&lt;/script&gt;', 'italy-cookie-choices' ) ?>" class="textarea"><?php echo esc_textarea( $custom_script_block_body_exclude ); ?></textarea>
1083
  <br>
1084
  <a id="SEP" class="button button-secondary add-sep" data-value="<---------SEP--------->">&lt;---------SEP---------&gt;</a>
1385
  // wp_register_script('ace', '//cdn.jsdelivr.net/ace/1.1.9/min/ace.js', false, null, true);
1386
  // wp_enqueue_script('ace');
1387
 
1388
+ // wp_enqueue_style(
1389
+ // 'italy-cookie-choices-css',
1390
+ // plugins_url('admin/css/admin.css', ITALY_COOKIE_CHOICES_FILE ),
1391
+ // array( 'dashicons' ),
1392
+ // null
1393
+ // );
1394
+
1395
  wp_enqueue_script(
1396
  'italy-cookie-choices-script',
1397
  plugins_url('admin/js/src/script.js', ITALY_COOKIE_CHOICES_FILE ),
1423
  return $links;
1424
  }// plugin_action_links()
1425
 
1426
+ /**
1427
+ * Process a settings export from config
1428
+ * @since 1.0.0
1429
+ */
1430
+ function settings_export() {
1431
+
1432
+ if ( empty( $_POST[ 'icc_action' ] ) || 'export_settings' !== $_POST[ 'icc_action' ] )
1433
+ return;
1434
+
1435
+ if ( !wp_verify_nonce( $_POST[ 'icc_export_nonce' ], 'icc_export_nonce' ) )
1436
+ return;
1437
+
1438
+ if ( !current_user_can( $this->capability ) )
1439
+ return;
1440
+
1441
+ $settings[0] = $this->options;
1442
+
1443
+ ignore_user_abort( true );
1444
+
1445
+ nocache_headers();
1446
+
1447
+ // date_default_timezone_set('UTC');
1448
+ header( 'Content-Type: application/json; charset=utf-8' );
1449
+ header( 'Content-Disposition: attachment; filename=italy-cookie-choices-settings-export-' . date( 'm-d-Y' ) . '.json' );
1450
+ header( "Expires: 0" );
1451
+
1452
+ echo $this->wp_json_encode( $settings, JSON_PRETTY_PRINT );
1453
+
1454
+ exit;
1455
+ }
1456
+
1457
+ /**
1458
+ * Process a settings import from a json file
1459
+ * @since 1.0.0
1460
+ */
1461
+ function settings_import() {
1462
+
1463
+ if ( empty( $_POST[ 'icc_action' ] ) || 'import_settings' != $_POST[ 'icc_action' ] )
1464
+ return;
1465
+
1466
+ if ( !wp_verify_nonce( $_POST[ 'icc_import_nonce' ], 'icc_import_nonce' ) )
1467
+ return;
1468
+
1469
+ if ( !current_user_can( $this->capability ) )
1470
+ return;
1471
+
1472
+ /**
1473
+ * Get the extension of import file
1474
+ * @link http://stackoverflow.com/a/19831453 Strict standards: Only variables should be passed by reference
1475
+ * @var string
1476
+ */
1477
+ $file_name = $_FILES[ 'icc_import_file' ][ 'name' ];
1478
+ $exploded = explode( '.', $file_name );
1479
+ $extension = end( $exploded );
1480
+
1481
+ /**
1482
+ * If it is not json than die
1483
+ */
1484
+ if ( $extension !== 'json' )
1485
+ wp_die( __( 'Please upload a valid .json file', 'italy-cookie-choices' ), __( 'No valid json file', 'italy-cookie-choices' ), array( 'back_link' => true ) );
1486
+
1487
+ /**
1488
+ * If the file is empty than die
1489
+ */
1490
+ if ( $_FILES[ 'icc_import_file' ][ 'size' ] === 0 )
1491
+ wp_die( __( 'The json file can\'t be empty', 'italy-cookie-choices' ), __( 'Empty file', 'italy-cookie-choices' ), array( 'back_link' => true ) );
1492
+
1493
+ $import_file = $_FILES[ 'icc_import_file' ][ 'tmp_name' ];
1494
+
1495
+ /**
1496
+ * If $import_file is empty or null than die
1497
+ */
1498
+ if ( empty( $import_file ) )
1499
+ wp_die( __( 'Please upload a file to import', 'italy-cookie-choices' ), __( 'No file import', 'italy-cookie-choices' ), array( 'back_link' => true ) );
1500
+
1501
+ /**
1502
+ * Retrieve the settings from the file and convert the json object to an array.
1503
+ * @var array
1504
+ */
1505
+ $settings = ( array ) json_decode( file_get_contents( $import_file ) );
1506
+
1507
+ update_option( 'italy_cookie_choices', get_object_vars( $settings[0] ) );
1508
+
1509
+ wp_safe_redirect( admin_url( 'options-general.php?page=' . 'italy-cookie-choices' ) );
1510
+ exit;
1511
+ }
1512
+
1513
  }// class
1514
  }//endif
admin/css/admin.css ADDED
@@ -0,0 +1 @@
 
1
+ .ui-state-default{display:inline;border-color:#ccc #ccc #f1f1f1;border-width:1px;border-style:solid;padding:10px;background:none repeat scroll 0% 0% #e4e4e4}.ui-tabs-nav{padding-bottom:7px;padding-left:10px;border-bottom:1px solid #ccc}.ui-tabs-anchor{text-decoration:none;color:black;font-weight:700;font-size:15px;line-height:24px;color:#7f7f7f}.ui-tabs-anchor:hover,.ui-state-active a{color:black}.ui-tabs-active,.ui-tabs-active:hover,.ui-tabs-active:active{color:#000;background:#efefef !important}.postbox h3{padding-left:10px}#dashboard_right_now a.demo-count:before{content:"\f115"}
admin/css/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
admin/css/src/sass/admin.scss ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This stylesheet is used to style the admin option form of the plugin.
2
+
3
+ // Tabs
4
+
5
+ .ui-state-default {
6
+ display: inline;
7
+ border-color: rgb(204, 204, 204) rgb(204, 204, 204) rgb(241, 241, 241);
8
+ border-width: 1px;
9
+ border-style:solid;
10
+ padding: 10px;
11
+ background: none repeat scroll 0% 0% rgb(228, 228, 228);
12
+ }
13
+
14
+ .ui-tabs-nav {
15
+ padding-bottom: 7px;
16
+ padding-left: 10px;
17
+ border-bottom: 1px solid rgb(204, 204, 204);
18
+ }
19
+
20
+ .ui-tabs-anchor {
21
+ text-decoration: none;
22
+ color:black;
23
+ font-weight: 700;
24
+ font-size: 15px;
25
+ line-height: 24px;
26
+ color: rgb(127, 127, 127);
27
+ }
28
+
29
+ .ui-tabs-anchor:hover,.ui-state-active a {
30
+ color:black;
31
+ }
32
+
33
+ .ui-tabs-active, .ui-tabs-active:hover, .ui-tabs-active:active {
34
+ color: rgb(0, 0, 0);
35
+ background: rgb(239, 239, 239) !important;
36
+ }
37
+
38
+ .postbox h3 {
39
+ padding-left: 10px;
40
+ }
41
+
42
+ #dashboard_right_now a.demo-count:before {
43
+ content: "\f115";
44
+ }
admin/css/src/sass/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php // Silence is golden
admin/js/src/script.js CHANGED
@@ -24,6 +24,12 @@
24
  }
25
 
26
  $(document).ready(function() {
 
 
 
 
 
 
27
  /**
28
  * Snippet per il color picker di WordPress
29
  */
24
  }
25
 
26
  $(document).ready(function() {
27
+
28
+ /**
29
+ * Funzione per le tab nel pannello admin
30
+ */
31
+ // $('#tabs').tabs();
32
+
33
  /**
34
  * Snippet per il color picker di WordPress
35
  */
admin/template/admin.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Represents the view for the administration dashboard.
4
+ *
5
+ * This includes the header, options, and other information that should provide
6
+ * The User Interface to the end user.
7
+ *
8
+ * @package Plugin_Name
9
+ * @author Your Name <email@example.com>
10
+ * @license GPL-2.0+
11
+ * @link http://example.com
12
+ * @copyright 2015 Your Name or Company Name
13
+ */
14
+
15
+ ?>
16
+ <div class="wrap">
17
+
18
+ <form action='options.php' method='post' id='italy-cookie-choices-ID'>
19
+
20
+ <?php
21
+ settings_fields( 'italy_cl_options_group' );
22
+ do_settings_sections( 'italy_cl_options_group' );
23
+ submit_button();
24
+ ?>
25
+
26
+ </form>
27
+
28
+ <div id="tabs-3" class="metabox-holder">
29
+ <div class="postbox">
30
+ <h3 class="hndle"><span><?php _e( 'Export Settings'); ?></span></h3>
31
+ <div class="inside">
32
+ <p><?php _e( 'Export the plugin settings for this site as a .json file. This allows you to easily import the configuration into another site.' ); ?></p>
33
+ <form method="post">
34
+ <p>
35
+ <input type="hidden" name="icc_action" value="export_settings" />
36
+ </p>
37
+ <p>
38
+ <?php wp_nonce_field( 'icc_export_nonce', 'icc_export_nonce' ); ?>
39
+ <?php submit_button( __( 'Export' ), 'secondary', 'submit', false ); ?>
40
+ </p>
41
+ </form>
42
+ </div>
43
+ </div>
44
+
45
+ <div class="postbox">
46
+ <h3 class="hndle"><span><?php _e( 'Import Settings' ); ?></span></h3>
47
+ <div class="inside">
48
+ <p><?php _e( 'Import the plugin settings from a .json file. This file can be obtained by exporting the settings on another site using the form above.' ); ?></p>
49
+ <form method="post" enctype="multipart/form-data">
50
+ <p>
51
+ <input type="file" name="icc_import_file"/>
52
+ </p>
53
+ <p>
54
+ <input type="hidden" name="icc_action" value="import_settings" />
55
+ <?php wp_nonce_field( 'icc_import_nonce', 'icc_import_nonce' ); ?>
56
+ <?php submit_button( __( 'Import' ), 'secondary', 'submit', false ); ?>
57
+ </p>
58
+ </form>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ </div>
admin/template/code-example.php CHANGED
@@ -3,7 +3,7 @@
3
  <!-- <br> -->
4
 
5
 
6
- <div id="code-example" style="display:none;">
7
  <h1><?php _e( 'Script inline example', 'italy-cookie-choices' ); ?></h1>
8
  <p>
9
  <pre>
3
  <!-- <br> -->
4
 
5
 
6
+ <div id="code-example">
7
  <h1><?php _e( 'Script inline example', 'italy-cookie-choices' ); ?></h1>
8
  <p>
9
  <pre>
classes/class-italy-cookie-choices-front-end.php CHANGED
@@ -102,6 +102,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Front_End' ) ){
102
  * Shortcode to put a button in policy page
103
  */
104
  add_shortcode( 'accept_button', array( $this, 'accept_button' ) );
 
105
 
106
  if ( !isset( $_COOKIE[ $this->options['cookie_name'] ] ) && !$secondView ){
107
 
@@ -248,7 +249,7 @@ if ( !class_exists( 'Italy_Cookie_Choices_Front_End' ) ){
248
 
249
  if(
250
  // if is an HTML request (alternative methods???)
251
- ( strpos( $_SERVER["HTTP_ACCEPT"],'html' ) !== false ) &&
252
  //if the page isn't privacy page
253
  // ( $_SERVER['REQUEST_URI'] != $this->slug ) &&
254
  ( $this->CurrentPageURL() !== $this->url ) &&
@@ -752,6 +753,21 @@ if ( !class_exists( 'Italy_Cookie_Choices_Front_End' ) ){
752
 
753
  }
754
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
755
  /**
756
  * Display cookie, only for internal use
757
  * @return string
102
  * Shortcode to put a button in policy page
103
  */
104
  add_shortcode( 'accept_button', array( $this, 'accept_button' ) );
105
+ add_shortcode( 'delete_cookie', array( $this, '_delete_cookie' ) );
106
 
107
  if ( !isset( $_COOKIE[ $this->options['cookie_name'] ] ) && !$secondView ){
108
 
249
 
250
  if(
251
  // if is an HTML request (alternative methods???)
252
+ ( strpos( $_SERVER['HTTP_ACCEPT'],'html' ) !== false ) &&
253
  //if the page isn't privacy page
254
  // ( $_SERVER['REQUEST_URI'] != $this->slug ) &&
255
  ( $this->CurrentPageURL() !== $this->url ) &&
753
 
754
  }
755
 
756
+ /**
757
+ * Shortcode per stampare il bottone nella pagina della policy
758
+ * @param array $atts Array con gli attributi dello shortcode
759
+ * @param string $content content of shortcode
760
+ * @return string Button per l'accettazione
761
+ */
762
+ public function _delete_cookie( $atts, $content = null ) {
763
+
764
+ // $button_text = ( isset( $this->options['button_text'] ) ) ? $this->options['button_text'] : '' ;
765
+ $button_text = 'Delete cookie';
766
+
767
+ return '<span class="ele"><button onclick="deleteCookie()">' . esc_attr( $button_text ) . '</button></span>';
768
+
769
+ }
770
+
771
  /**
772
  * Display cookie, only for internal use
773
  * @return string
italy-cookie-choices.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Italy Cookie Choices (for EU Cookie Law)
4
  * Plugin URI: https://plus.google.com/u/0/communities/109254048492234113886
5
  * Description: Italy Cookie Choices allows you to easily comply with the european cookie law and block third part cookie in your page.
6
- * Version: 2.3.5
7
  * Author: Enea Overclokk, Andrea Pernici, Andrea Cardinale
8
  * Author URI: https://github.com/ItalyCookieChoices/italy-cookie-choices
9
  * Text Domain: italy-cookie-choices
@@ -74,9 +74,9 @@ require(ITALY_COOKIE_CHOICES_PLUGIN_PATH . 'admin/class-italy-cookie-choices-adm
74
 
75
  require(ITALY_COOKIE_CHOICES_PLUGIN_PATH . 'classes/class-italy-cookie-choices-front-end.php');
76
  /**
77
- * Requier multilingual functions
78
  */
79
- require(ITALY_COOKIE_CHOICES_PLUGIN_PATH . 'includes/functions-italy-cookie-choices-lang.php');
80
 
81
  /**
82
  * Initialize plugin
@@ -109,6 +109,11 @@ if ( ! class_exists( 'Italy_Cookie_Choices' ) ) {
109
  */
110
  if ( $this->is_compatible_version() && is_admin() ){
111
 
 
 
 
 
 
112
  new Italy_Cookie_Choices_Admin;
113
  // new Italy_Cookie_Choices_Pointer_Init;
114
 
@@ -124,13 +129,19 @@ if ( ! class_exists( 'Italy_Cookie_Choices' ) ) {
124
  // If is not sitemaps.xml by Yoast
125
  && !$this->is_sitemaps_xml()
126
 
127
- )
 
 
 
 
 
 
128
  if ( function_exists('pll__') )// Compatibility with Polylang
129
  add_action( 'plugins_loaded', array( $this, 'dependency_init' ), 11 );
130
  else
131
  new Italy_Cookie_Choices_Front_End;
132
 
133
- else
134
  add_action( 'admin_notices', array( $this, 'load_plugin_admin_notices' ) );
135
 
136
  /**
3
  * Plugin Name: Italy Cookie Choices (for EU Cookie Law)
4
  * Plugin URI: https://plus.google.com/u/0/communities/109254048492234113886
5
  * Description: Italy Cookie Choices allows you to easily comply with the european cookie law and block third part cookie in your page.
6
+ * Version: 2.4.0
7
  * Author: Enea Overclokk, Andrea Pernici, Andrea Cardinale
8
  * Author URI: https://github.com/ItalyCookieChoices/italy-cookie-choices
9
  * Text Domain: italy-cookie-choices
74
 
75
  require(ITALY_COOKIE_CHOICES_PLUGIN_PATH . 'classes/class-italy-cookie-choices-front-end.php');
76
  /**
77
+ * Required multilingual functions
78
  */
79
+ // require(ITALY_COOKIE_CHOICES_PLUGIN_PATH . 'includes/functions-italy-cookie-choices-lang.php');
80
 
81
  /**
82
  * Initialize plugin
109
  */
110
  if ( $this->is_compatible_version() && is_admin() ){
111
 
112
+ /**
113
+ * Required multilingual functions
114
+ */
115
+ require(ITALY_COOKIE_CHOICES_PLUGIN_PATH . 'includes/functions-italy-cookie-choices-lang.php');
116
+
117
  new Italy_Cookie_Choices_Admin;
118
  // new Italy_Cookie_Choices_Pointer_Init;
119
 
129
  // If is not sitemaps.xml by Yoast
130
  && !$this->is_sitemaps_xml()
131
 
132
+ ){
133
+
134
+ /**
135
+ * Required multilingual functions
136
+ */
137
+ require(ITALY_COOKIE_CHOICES_PLUGIN_PATH . 'includes/functions-italy-cookie-choices-lang.php');
138
+
139
  if ( function_exists('pll__') )// Compatibility with Polylang
140
  add_action( 'plugins_loaded', array( $this, 'dependency_init' ), 11 );
141
  else
142
  new Italy_Cookie_Choices_Front_End;
143
 
144
+ }else
145
  add_action( 'admin_notices', array( $this, 'load_plugin_admin_notices' ) );
146
 
147
  /**
js/default/cookiechoices.js CHANGED
@@ -91,6 +91,15 @@ function appendJS(script){
91
  }
92
  }
93
 
 
 
 
 
 
 
 
 
 
94
  (function(window) {
95
 
96
  if (!!window.cookieChoices) {
91
  }
92
  }
93
 
94
+ function deleteCookie() {
95
+ // Set the cookie expiry to 40 year before today.
96
+ var expiryDate = new Date();
97
+ expiryDate.setFullYear(expiryDate.getFullYear() - 40);
98
+ // document.cookie = cookieName + '=y; expires=' + expiryDate.toGMTString();
99
+ document.cookie = cookieName + '=' + coVA + '; expires=' + expiryDate.toGMTString() + ';path=/';
100
+ document.location.reload();
101
+ }
102
+
103
  (function(window) {
104
 
105
  if (!!window.cookieChoices) {
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: overclokk, andreapernici, cardinaleandrea
3
  Donate link:
4
  Tags: compliance, cookie law, cookies, eu cookie law, eu law, eu privacy directive, privacy, privacy directive, notification, privacy law, cookie law banner, implied consent, third party script, third party cookie
5
  Requires at least: 3.5
6
- Tested up to: 4.3.0
7
- Stable tag: 2.3.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -115,12 +115,21 @@ if it doesn't work activate standard theme and try
115
 
116
  == Changelog ==
117
 
 
 
 
 
 
 
 
 
 
118
  = 2.3.5 =
119
  Release Date: July 25th, 2015
120
 
121
  Dev time: 3h
122
 
123
- * Add filter for js_array `icc_js_array`
124
  * Fixed performance issue in sites with many posts
125
  * [Fixed Parse error issue #124](https://github.com/ItalyCookieChoices/italy-cookie-choices/issues/124#issuecomment-122952940)
126
 
@@ -206,7 +215,7 @@ Dev time: 100h
206
  * [Added uninstall.php](https://github.com/ItalyCookieChoices/italy-cookie-choices/issues/34)
207
  * Added text area for custom CSS
208
  * [Added input for custom CSS class](https://github.com/ItalyCookieChoices/italy-cookie-choices/issues/16)
209
- * Added filter `icc_output_html` on snippet output for developer
210
 
211
  = 2.1.0 =
212
  Release Date: June 5th, 2015
@@ -338,4 +347,4 @@ a notice to the user only the very first time that visits your website without d
338
  * [www.cookiechoices.org](https://www.cookiechoices.org/)
339
  * [Loghino piccolo](http://www.posizionamento-seo.com/)
340
  * Romanian lang: [Florin Lungu](http://www.florinlungu.it/)
341
- * [Some code for WordPress Plugin Boilerplate Powered by Mte90](https://github.com/Mte90/WordPress-Plugin-Boilerplate-Powered)
3
  Donate link:
4
  Tags: compliance, cookie law, cookies, eu cookie law, eu law, eu privacy directive, privacy, privacy directive, notification, privacy law, cookie law banner, implied consent, third party script, third party cookie
5
  Requires at least: 3.5
6
+ Tested up to: 4.4.0
7
+ Stable tag: 2.4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
115
 
116
  == Changelog ==
117
 
118
+ = 2.4.0 =
119
+ Release Date: August 31th, 2015
120
+
121
+ Dev time: 11h
122
+
123
+ * Added import/export functionality
124
+ * Maybe fixed [#133](https://github.com/ItalyCookieChoices/italy-cookie-choices/issues/133)
125
+ * Fixed PHP check for lang functions [#128](https://github.com/ItalyCookieChoices/italy-cookie-choices/issues/128)
126
+
127
  = 2.3.5 =
128
  Release Date: July 25th, 2015
129
 
130
  Dev time: 3h
131
 
132
+ * [Add filter for js_array `icc_js_array`](https://github.com/ItalyCookieChoices/italy-cookie-choices/wiki/Filters-Hook#modificare-larray-con-tutti-gli-embed-trovati-disponibile-dalla-versione-235)
133
  * Fixed performance issue in sites with many posts
134
  * [Fixed Parse error issue #124](https://github.com/ItalyCookieChoices/italy-cookie-choices/issues/124#issuecomment-122952940)
135
 
215
  * [Added uninstall.php](https://github.com/ItalyCookieChoices/italy-cookie-choices/issues/34)
216
  * Added text area for custom CSS
217
  * [Added input for custom CSS class](https://github.com/ItalyCookieChoices/italy-cookie-choices/issues/16)
218
+ * [Added filter `icc_output_html` on snippet output for developer](https://github.com/ItalyCookieChoices/italy-cookie-choices/wiki/Filters-Hook#modificare-loutput)
219
 
220
  = 2.1.0 =
221
  Release Date: June 5th, 2015
347
  * [www.cookiechoices.org](https://www.cookiechoices.org/)
348
  * [Loghino piccolo](http://www.posizionamento-seo.com/)
349
  * Romanian lang: [Florin Lungu](http://www.florinlungu.it/)
350
+ * [Some code comes from the WordPress Plugin Boilerplate Powered by Mte90](https://github.com/Mte90/WordPress-Plugin-Boilerplate-Powered)