Cookie Notice by dFactory - Version 1.2.28

Version Description

  • New: Option to set on scroll offset
Download this release

Release Info

Developer dfactory
Plugin Icon 128x128 Cookie Notice by dFactory
Version 1.2.28
Comparing to
See all releases

Code changes from version 1.2.27 to 1.2.28

Files changed (4) hide show
  1. cookie-notice.php +22 -15
  2. js/admin.js +9 -0
  3. js/front.js +2 -2
  4. readme.txt +7 -4
cookie-notice.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Cookie Notice
4
  Description: Cookie Notice allows you to elegantly inform users that your site uses cookies and to comply with the EU cookie law regulations.
5
- Version: 1.2.27
6
  Author: dFactory
7
  Author URI: http://www.dfactory.eu/
8
  Plugin URI: http://www.dfactory.eu/plugins/cookie-notice/
@@ -34,7 +34,7 @@ include_once( plugin_dir_path( __FILE__ ) . 'includes/update.php' );
34
  * Cookie Notice class.
35
  *
36
  * @class Cookie_Notice
37
- * @version 1.2.27
38
  */
39
  class Cookie_Notice {
40
 
@@ -54,6 +54,7 @@ class Cookie_Notice {
54
  'time' => 'month',
55
  'hide_effect' => 'fade',
56
  'on_scroll' => false,
 
57
  'colors' => array(
58
  'text' => '#fff',
59
  'bar' => '#000',
@@ -68,7 +69,7 @@ class Cookie_Notice {
68
  'translate' => true,
69
  'deactivation_delete' => 'no'
70
  ),
71
- 'version' => '1.2.27'
72
  );
73
  private $positions = array();
74
  private $styles = array();
@@ -481,12 +482,14 @@ class Cookie_Notice {
481
  */
482
  public function cn_on_scroll() {
483
  echo '
484
- <div id="cn_on_scroll">
485
  <fieldset>
486
  <label><input id="cn_on_scroll" type="checkbox" name="cookie_notice_options[on_scroll]" value="1" ' . checked( 'yes', $this->options['general']['on_scroll'], false ) . ' />' . __( 'Enable cookie notice acceptance when users scroll.', 'cookie-notice' ) . '</label>';
487
  echo '
488
- </fieldset>
489
- </div>';
 
 
 
490
  }
491
 
492
  /**
@@ -568,6 +571,9 @@ class Cookie_Notice {
568
 
569
  // on scroll
570
  $input['on_scroll'] = (bool) isset( $input['on_scroll'] ) ? 'yes' : 'no';
 
 
 
571
 
572
  // deactivation
573
  $input['deactivation_delete'] = (bool) isset( $input['deactivation_delete'] ) ? 'yes' : 'no';
@@ -720,7 +726,7 @@ class Cookie_Notice {
720
 
721
  wp_localize_script(
722
  'cookie-notice-admin', 'cnArgs', array(
723
- 'resetToDefaults' => __( 'Are you sure you want to reset these settings to defaults?', 'cookie-notice' ),
724
  )
725
  );
726
 
@@ -739,14 +745,15 @@ class Cookie_Notice {
739
 
740
  wp_localize_script(
741
  'cookie-notice-front', 'cnArgs', array(
742
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
743
- 'hideEffect' => $this->options['general']['hide_effect'],
744
- 'onScroll' => $this->options['general']['on_scroll'],
745
- 'cookieName' => self::$cookie['name'],
746
- 'cookieValue' => self::$cookie['value'],
747
- 'cookieTime' => $this->times[$this->options['general']['time']][1],
748
- 'cookiePath' => ( defined( 'COOKIEPATH' ) ? COOKIEPATH : '' ),
749
- 'cookieDomain' => ( defined( 'COOKIE_DOMAIN' ) ? COOKIE_DOMAIN : '' )
 
750
  )
751
  );
752
 
2
  /*
3
  Plugin Name: Cookie Notice
4
  Description: Cookie Notice allows you to elegantly inform users that your site uses cookies and to comply with the EU cookie law regulations.
5
+ Version: 1.2.28
6
  Author: dFactory
7
  Author URI: http://www.dfactory.eu/
8
  Plugin URI: http://www.dfactory.eu/plugins/cookie-notice/
34
  * Cookie Notice class.
35
  *
36
  * @class Cookie_Notice
37
+ * @version 1.2.28
38
  */
39
  class Cookie_Notice {
40
 
54
  'time' => 'month',
55
  'hide_effect' => 'fade',
56
  'on_scroll' => false,
57
+ 'on_scroll_offset' => 100,
58
  'colors' => array(
59
  'text' => '#fff',
60
  'bar' => '#000',
69
  'translate' => true,
70
  'deactivation_delete' => 'no'
71
  ),
72
+ 'version' => '1.2.28'
73
  );
74
  private $positions = array();
75
  private $styles = array();
482
  */
483
  public function cn_on_scroll() {
484
  echo '
 
485
  <fieldset>
486
  <label><input id="cn_on_scroll" type="checkbox" name="cookie_notice_options[on_scroll]" value="1" ' . checked( 'yes', $this->options['general']['on_scroll'], false ) . ' />' . __( 'Enable cookie notice acceptance when users scroll.', 'cookie-notice' ) . '</label>';
487
  echo '
488
+ <div id="cn_on_scroll_offset"' . ( $this->options['general']['on_scroll'] === 'no' ? ' style="display: none;"' : '' ) . '>
489
+ <input type="text" class="text" name="cookie_notice_options[on_scroll_offset]" value="' . esc_attr( $this->options['general']['on_scroll_offset'] ) . '" /> <span>px</span>
490
+ <p class="description">' . __( 'Number of pixels user has to scroll to accept the usage of the cookies and make the notification disappear.', 'cookie-notice' ) . '</p>
491
+ </div>
492
+ </fieldset>';
493
  }
494
 
495
  /**
571
 
572
  // on scroll
573
  $input['on_scroll'] = (bool) isset( $input['on_scroll'] ) ? 'yes' : 'no';
574
+
575
+ // on scroll offset
576
+ $input['on_scroll_offset'] = absint( isset( $input['on_scroll_offset'] ) && $input['on_scroll_offset'] !== '' ? $input['on_scroll_offset'] : $this->defaults['general']['on_scroll_offset'] );
577
 
578
  // deactivation
579
  $input['deactivation_delete'] = (bool) isset( $input['deactivation_delete'] ) ? 'yes' : 'no';
726
 
727
  wp_localize_script(
728
  'cookie-notice-admin', 'cnArgs', array(
729
+ 'resetToDefaults' => __( 'Are you sure you want to reset these settings to defaults?', 'cookie-notice' )
730
  )
731
  );
732
 
745
 
746
  wp_localize_script(
747
  'cookie-notice-front', 'cnArgs', array(
748
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
749
+ 'hideEffect' => $this->options['general']['hide_effect'],
750
+ 'onScroll' => $this->options['general']['on_scroll'],
751
+ 'onScrollOffset' => $this->options['general']['on_scroll_offset'],
752
+ 'cookieName' => self::$cookie['name'],
753
+ 'cookieValue' => self::$cookie['value'],
754
+ 'cookieTime' => $this->times[$this->options['general']['time']][1],
755
+ 'cookiePath' => ( defined( 'COOKIEPATH' ) ? COOKIEPATH : '' ),
756
+ 'cookieDomain' => ( defined( 'COOKIE_DOMAIN' ) ? COOKIE_DOMAIN : '' )
757
  )
758
  );
759
 
js/admin.js CHANGED
@@ -22,6 +22,15 @@
22
  $( '#cn_see_more_opt' ).slideUp( 'fast' );
23
  }
24
  } );
 
 
 
 
 
 
 
 
 
25
 
26
  // read more link
27
  $( '#cn_see_more_link-custom, #cn_see_more_link-page' ).change( function () {
22
  $( '#cn_see_more_opt' ).slideUp( 'fast' );
23
  }
24
  } );
25
+
26
+ // read more option
27
+ $( '#cn_on_scroll' ).change( function () {
28
+ if ( $( this ).is(':checked') ) {
29
+ $( '#cn_on_scroll_offset' ).slideDown( 'fast' );
30
+ } else {
31
+ $( '#cn_on_scroll_offset' ).slideUp( 'fast' );
32
+ }
33
+ } );
34
 
35
  // read more link
36
  $( '#cn_see_more_link-custom, #cn_see_more_link-page' ).change( function () {
js/front.js CHANGED
@@ -12,8 +12,8 @@
12
  // handle on scroll
13
  if( cnArgs.onScroll == 'yes' ) {
14
  var cnHandleScroll = function () {
15
- var win = $(this);
16
- if (win.scrollTop() > 100) {
17
  // If user scrolls at least 100 pixels
18
  win.setCookieNotice( 'accept' );
19
  win.off( 'scroll', cnHandleScroll ); //remove itself after cookie accept
12
  // handle on scroll
13
  if( cnArgs.onScroll == 'yes' ) {
14
  var cnHandleScroll = function () {
15
+ var win = $( this );
16
+ if ( win.scrollTop() > parseInt( cnArgs.onScrollOffset ) ) {
17
  // If user scrolls at least 100 pixels
18
  win.setCookieNotice( 'accept' );
19
  win.off( 'scroll', cnHandleScroll ); //remove itself after cookie accept
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://www.dfactory.eu/
4
  Tags: cookie, cookies, notice, notification, notify, cookie, cookie compliance, cookie law, eu cookie, privacy, privacy directive, consent, Bootstrap
5
  Requires at least: 3.3
6
  Tested up to: 4.2.2
7
- Stable tag: 1.2.27
8
  License: MIT License
9
  License URI: http://opensource.org/licenses/MIT
10
 
@@ -23,6 +23,7 @@ For more information, check out plugin page at [dFactory](http://www.dfactory.eu
23
  * Set cookie expiry
24
  * Link to more info page
25
  * Option to accept cookies on scroll
 
26
  * Option to refuse functional cookies
27
  * Select the position of the cookie message box
28
  * Animate the message box after cookie is accepted
@@ -77,6 +78,9 @@ No questions yet.
77
 
78
  == Changelog ==
79
 
 
 
 
80
  = 1.2.27 =
81
  * Tweak: Correctly remove scroll event, limit possible conflicts
82
  * Tweak: Italian translation update
@@ -191,6 +195,5 @@ Initial release
191
 
192
  == Upgrade Notice ==
193
 
194
- = 1.2.27 =
195
- * Tweak: Correctly remove scroll event, limit possible conflicts
196
- * Tweak: Italian translation update
4
  Tags: cookie, cookies, notice, notification, notify, cookie, cookie compliance, cookie law, eu cookie, privacy, privacy directive, consent, Bootstrap
5
  Requires at least: 3.3
6
  Tested up to: 4.2.2
7
+ Stable tag: 1.2.28
8
  License: MIT License
9
  License URI: http://opensource.org/licenses/MIT
10
 
23
  * Set cookie expiry
24
  * Link to more info page
25
  * Option to accept cookies on scroll
26
+ * Option to set on scroll offset
27
  * Option to refuse functional cookies
28
  * Select the position of the cookie message box
29
  * Animate the message box after cookie is accepted
78
 
79
  == Changelog ==
80
 
81
+ = 1.2.28 =
82
+ * New: Option to set on scroll offset
83
+
84
  = 1.2.27 =
85
  * Tweak: Correctly remove scroll event, limit possible conflicts
86
  * Tweak: Italian translation update
195
 
196
  == Upgrade Notice ==
197
 
198
+ = 1.2.28 =
199
+ * New: Option to set on scroll offset