Simple Banner - Version 2.11.0

Version Description

  • New feature: ability to change expiration date by specific time
Download this release

Release Info

Developer rpetersen29
Plugin Icon 128x128 Simple Banner
Version 2.11.0
Comparing to
See all releases

Code changes from version 2.10.9 to 2.11.0

Files changed (3) hide show
  1. readme.txt +10 -2
  2. simple-banner.js +14 -6
  3. simple-banner.php +5 -5
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/rpetersenDev
4
  Tags: banner, simple, top, bar, announcement, top bar, topbar, bulletin, notification, notice, cta, free
5
  Requires at least: 3.0.1
6
  Tested up to: 5.9.0
7
- Stable tag: 2.10.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -85,9 +85,11 @@ If cookies are disabled on the user's browser, the banners close button expirati
85
 
86
  You can clear your browser's cookies or in the browser's console you can execute:
87
 
88
- `document.cookie = "simplebannerclosed=; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/";
89
  `
90
 
 
 
91
  = How do I disable the banner in my posts? =
92
 
93
  This feature is being actively developed, in the meantime you can use this custom JavaScript:
@@ -118,6 +120,9 @@ Set your banner position to <code>relative</code> and try this in 'Website Custo
118
 
119
  == Changelog ==
120
 
 
 
 
121
  = 2.10.9 =
122
  * Bug fix in preview banner.
123
 
@@ -292,6 +297,9 @@ Set your banner position to <code>relative</code> and try this in 'Website Custo
292
 
293
  == Upgrade Notice ==
294
 
 
 
 
295
  = 2.10.9 =
296
  * Bug fix in preview banner.
297
 
4
  Tags: banner, simple, top, bar, announcement, top bar, topbar, bulletin, notification, notice, cta, free
5
  Requires at least: 3.0.1
6
  Tested up to: 5.9.0
7
+ Stable tag: 2.11.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
85
 
86
  You can clear your browser's cookies or in the browser's console you can execute:
87
 
88
+ `document.cookie = "simplebannerclosed=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
89
  `
90
 
91
+ You can also set your Close button expiration to blank, 0, or a date in the past. This method may require a refresh or two of the browser on your website page.
92
+
93
  = How do I disable the banner in my posts? =
94
 
95
  This feature is being actively developed, in the meantime you can use this custom JavaScript:
120
 
121
  == Changelog ==
122
 
123
+ = 2.11.0 =
124
+ * New feature: ability to change expiration date by specific time
125
+
126
  = 2.10.9 =
127
  * Bug fix in preview banner.
128
 
297
 
298
  == Upgrade Notice ==
299
 
300
+ = 2.11.0 =
301
+ * New feature: ability to change expiration date by specific time
302
+
303
  = 2.10.9 =
304
  * Bug fix in preview banner.
305
 
simple-banner.js CHANGED
@@ -46,14 +46,16 @@ jQuery(document).ready(function ($) {
46
 
47
  if (isSimpleBannerVisible) {
48
  var sbCookie = "simplebannerclosed";
 
49
  if (simpleBannerScriptParams.close_button_enabled){
50
  if (getCookie(sbCookie) === "true") {
51
  closeBanner();
 
 
52
  } else {
53
- var expiration = parseInt(simpleBannerScriptParams.close_button_expiration) || 30;
54
  document.getElementById("simple-banner-close-button").onclick = function() {
55
  closeBanner();
56
- setCookie(sbCookie, "true", expiration);
57
  };
58
  }
59
  } else {
@@ -65,10 +67,16 @@ jQuery(document).ready(function ($) {
65
  }
66
 
67
  // Cookie Getter/Setter
68
- function setCookie(cname,cvalue,exdays) {
69
- var d = new Date();
70
- d.setTime(d.getTime() + (exdays*24*60*60*1000));
71
- var expires = "expires=" + d.toGMTString();
 
 
 
 
 
 
72
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
73
  }
74
  function getCookie(cname) {
46
 
47
  if (isSimpleBannerVisible) {
48
  var sbCookie = "simplebannerclosed";
49
+
50
  if (simpleBannerScriptParams.close_button_enabled){
51
  if (getCookie(sbCookie) === "true") {
52
  closeBanner();
53
+ // Set cookie again here in case the expiration has changed
54
+ setCookie(sbCookie, "true", simpleBannerScriptParams.close_button_expiration);
55
  } else {
 
56
  document.getElementById("simple-banner-close-button").onclick = function() {
57
  closeBanner();
58
+ setCookie(sbCookie, "true", simpleBannerScriptParams.close_button_expiration);
59
  };
60
  }
61
  } else {
67
  }
68
 
69
  // Cookie Getter/Setter
70
+ function setCookie(cname,cvalue,expiration) {
71
+ var d;
72
+ if (expiration === '' || expiration === '0' || parseInt(expiration)) {
73
+ var exdays = parseInt(expiration) || 0;
74
+ d = new Date();
75
+ d.setTime(d.getTime() + (exdays*24*60*60*1000));
76
+ } else {
77
+ d = new Date(expiration);
78
+ }
79
+ var expires = "expires=" + d.toUTCString();
80
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
81
  }
82
  function getCookie(cname) {
simple-banner.php CHANGED
@@ -3,16 +3,16 @@
3
  * Plugin Name: Simple Banner
4
  * Plugin URI: https://github.com/rpetersen29/simple-banner
5
  * Description: Display a simple banner at the top of your website.
6
- * Version: 2.10.9
7
  * Author: Ryan Petersen
8
  * Author URI: http://rpetersen29.github.io/
9
  * License: GPL2
10
  *
11
  * @package Simple Banner
12
- * @version 2.10.9
13
  * @author Ryan Petersen <rpetersen.dev@gmail.com>
14
  */
15
- define ('VERSION', '2.10.9');
16
 
17
  register_activation_hook( __FILE__, 'simple_banner_activate' );
18
  function simple_banner_activate() {
@@ -476,11 +476,11 @@ function simple_banner_settings_page() {
476
  Close button expiration
477
  <br>
478
  <span style="font-weight:400;">
479
- The amount of days until the close button action will expire. Default is 30.
480
  </span>
481
  </th>
482
  <td>
483
- <input type="number" min="1" max="30" id="close_button_expiration" name="close_button_expiration"
484
  value="<?php echo esc_attr( get_option('close_button_expiration') ); ?>" />
485
  </td>
486
  </tr>
3
  * Plugin Name: Simple Banner
4
  * Plugin URI: https://github.com/rpetersen29/simple-banner
5
  * Description: Display a simple banner at the top of your website.
6
+ * Version: 2.11.0
7
  * Author: Ryan Petersen
8
  * Author URI: http://rpetersen29.github.io/
9
  * License: GPL2
10
  *
11
  * @package Simple Banner
12
+ * @version 2.11.0
13
  * @author Ryan Petersen <rpetersen.dev@gmail.com>
14
  */
15
+ define ('VERSION', '2.11.0');
16
 
17
  register_activation_hook( __FILE__, 'simple_banner_activate' );
18
  function simple_banner_activate() {
476
  Close button expiration
477
  <br>
478
  <span style="font-weight:400;">
479
+ The amount of time until the close button action will expire. Enter the amount of days until the close button action will expire, e.g. <code>14</code> or the exact day and time, e.g. <code>Mon, 21 Feb 2022 15:53:22 GMT</code>. Default is 0.
480
  </span>
481
  </th>
482
  <td>
483
+ <input id="close_button_expiration" name="close_button_expiration"
484
  value="<?php echo esc_attr( get_option('close_button_expiration') ); ?>" />
485
  </td>
486
  </tr>