Version Description
- Custom capability bug fix.
- Keep closed bug fix.
Download this release
Release Info
Developer | syammohanm |
Plugin | WPFront Notification Bar |
Version | 2.3.0 |
Comparing to | |
See all releases |
Code changes from version 2.2.0 to 2.3.0
- classes/class-wpfront-notification-bar.php +9 -2
- js/wpfront-notification-bar.js +36 -40
- js/wpfront-notification-bar.min.js +2 -2
- readme.txt +9 -2
- wpfront-notification-bar.php +1 -1
classes/class-wpfront-notification-bar.php
CHANGED
@@ -35,7 +35,7 @@ if (!class_exists('WPFront_Notification_Bar')) {
|
|
35 |
class WPFront_Notification_Bar {
|
36 |
|
37 |
//Constants
|
38 |
-
const VERSION = '2.
|
39 |
const OPTIONS_GROUP_NAME = 'wpfront-notification-bar-options-group';
|
40 |
const OPTION_NAME = 'wpfront-notification-bar-options';
|
41 |
const PLUGIN_SLUG = 'wpfront-notification-bar';
|
@@ -79,6 +79,7 @@ if (!class_exists('WPFront_Notification_Bar')) {
|
|
79 |
$this->cap = WPFRONT_NOTIFICATION_BAR_EDIT_CAPABILITY;
|
80 |
}
|
81 |
$this->cap = apply_filters('wpfront_notification_bar_edit_capability', $this->cap);
|
|
|
82 |
|
83 |
add_action('admin_init', array($this, 'admin_init'));
|
84 |
add_action('admin_menu', array($this, 'admin_menu'));
|
@@ -270,7 +271,9 @@ if (!class_exists('WPFront_Notification_Bar')) {
|
|
270 |
}
|
271 |
|
272 |
header('Content-Type: text/css; charset=UTF-8');
|
273 |
-
|
|
|
|
|
274 |
|
275 |
$template = new WPFront_Notification_Bar_Custom_CSS_Template();
|
276 |
$template->write($this);
|
@@ -762,6 +765,10 @@ if (!class_exists('WPFront_Notification_Bar')) {
|
|
762 |
return 'wpfront-notification-bar';
|
763 |
}
|
764 |
|
|
|
|
|
|
|
|
|
765 |
}
|
766 |
|
767 |
}
|
35 |
class WPFront_Notification_Bar {
|
36 |
|
37 |
//Constants
|
38 |
+
const VERSION = '2.3.0.102911';
|
39 |
const OPTIONS_GROUP_NAME = 'wpfront-notification-bar-options-group';
|
40 |
const OPTION_NAME = 'wpfront-notification-bar-options';
|
41 |
const PLUGIN_SLUG = 'wpfront-notification-bar';
|
79 |
$this->cap = WPFRONT_NOTIFICATION_BAR_EDIT_CAPABILITY;
|
80 |
}
|
81 |
$this->cap = apply_filters('wpfront_notification_bar_edit_capability', $this->cap);
|
82 |
+
add_filter('option_page_capability_' . self::OPTIONS_GROUP_NAME, array($this, 'option_page_capability_callback'), 10);
|
83 |
|
84 |
add_action('admin_init', array($this, 'admin_init'));
|
85 |
add_action('admin_menu', array($this, 'admin_menu'));
|
271 |
}
|
272 |
|
273 |
header('Content-Type: text/css; charset=UTF-8');
|
274 |
+
$e = strtotime('+1 year');
|
275 |
+
header('Expires: ' . gmdate('D, d M Y H:i:s ', $e) . 'GMT');
|
276 |
+
header('Cache-Control: public, max-age=' . $e);
|
277 |
|
278 |
$template = new WPFront_Notification_Bar_Custom_CSS_Template();
|
279 |
$template->write($this);
|
765 |
return 'wpfront-notification-bar';
|
766 |
}
|
767 |
|
768 |
+
public function option_page_capability_callback() {
|
769 |
+
return $this->cap;
|
770 |
+
}
|
771 |
+
|
772 |
}
|
773 |
|
774 |
}
|
js/wpfront-notification-bar.js
CHANGED
@@ -10,24 +10,24 @@
|
|
10 |
|
11 |
*/
|
12 |
|
13 |
-
(function() {
|
14 |
//displays the notification bar
|
15 |
-
window.wpfront_notification_bar = function(data, process) {
|
16 |
-
var log = function(msg) {
|
17 |
-
if(data.log)
|
18 |
console.log('[WPFront Notification Bar] ' + msg);
|
19 |
};
|
20 |
|
21 |
-
if(typeof jQuery !== "function" || (data.keep_closed && typeof Cookies !== "function")) {
|
22 |
log('Waiting for ' + (typeof jQuery !== "function" ? 'jQuery.' : 'Cookies.'));
|
23 |
-
setTimeout(function(){
|
24 |
wpfront_notification_bar(data, process);
|
25 |
}, 100);
|
26 |
return;
|
27 |
}
|
28 |
|
29 |
-
if(data.position == 2 && process !== true) {
|
30 |
-
jQuery(function(){
|
31 |
wpfront_notification_bar(data, true);
|
32 |
});
|
33 |
return;
|
@@ -58,20 +58,19 @@
|
|
58 |
open_button.css("top", top + "px");
|
59 |
spacer.css("top", data.position_offset + "px");
|
60 |
var $body = $("body").prepend(spacer);
|
61 |
-
$(function(){
|
62 |
-
if(!$body.children().first().is(spacer)) {
|
63 |
$body.prepend(spacer);
|
64 |
}
|
65 |
});
|
66 |
-
}
|
67 |
-
else {
|
68 |
log('Setting notification bar at bottom.');
|
69 |
var $body = $("body");
|
70 |
-
if(!$body.children().last().is(spacer)) {
|
71 |
$body.append(spacer);
|
72 |
}
|
73 |
-
$(function(){
|
74 |
-
if(!$body.children().last().is(spacer)) {
|
75 |
$body.append(spacer);
|
76 |
}
|
77 |
});
|
@@ -99,22 +98,28 @@
|
|
99 |
if (closed)
|
100 |
return;
|
101 |
closed = true;
|
102 |
-
}
|
103 |
-
else {
|
104 |
if (!closed)
|
105 |
return;
|
106 |
closed = false;
|
107 |
}
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
var fn = callback;
|
110 |
-
callback = function() {
|
111 |
fn();
|
112 |
if (height > 0) {
|
113 |
//set height to auto if in case content wraps on resize
|
114 |
if (data.height == 0)
|
115 |
bar.height("auto");
|
116 |
|
117 |
-
if(data.display_open_button) {
|
118 |
log('Setting reopen button state to hidden.');
|
119 |
open_button.addClass('hidden');
|
120 |
}
|
@@ -125,16 +130,10 @@
|
|
125 |
log('Setting reopen button state to visible.');
|
126 |
open_button.removeClass('hidden');
|
127 |
}
|
128 |
-
if (height == 0 && data.keep_closed && userclosed) {
|
129 |
-
if (data.keep_closed_for > 0)
|
130 |
-
Cookies.set(keep_closed_cookie, 1, {path: "/", expires: data.keep_closed_for});
|
131 |
-
else
|
132 |
-
Cookies.set(keep_closed_cookie, 1, {path: "/"});
|
133 |
-
}
|
134 |
};
|
135 |
|
136 |
//set animation
|
137 |
-
if(height > 0)
|
138 |
log('Setting notification bar state to visible.');
|
139 |
else
|
140 |
log('Setting notification bar state to hidden.');
|
@@ -143,8 +142,7 @@
|
|
143 |
bar.stop().animate({"height": height + "px"}, data.animate_delay * 1000, "swing", callback);
|
144 |
if (data.fixed_position)
|
145 |
spacer.stop().animate({"height": height + "px"}, data.animate_delay * 1000);
|
146 |
-
}
|
147 |
-
else {
|
148 |
bar.height(height);
|
149 |
if (data.fixed_position)
|
150 |
spacer.height(height);
|
@@ -154,20 +152,20 @@
|
|
154 |
}
|
155 |
|
156 |
if (data.close_button) {
|
157 |
-
spacer.on('click', '.wpfront-close', function() {
|
158 |
setHeight(0, null, true);
|
159 |
});
|
160 |
}
|
161 |
|
162 |
//close button action
|
163 |
if (data.button_action_close_bar) {
|
164 |
-
spacer.on('click', '.wpfront-button', function() {
|
165 |
setHeight(0, null, true);
|
166 |
});
|
167 |
}
|
168 |
|
169 |
if (data.display_open_button) {
|
170 |
-
spacer.on('click', '#wpfront-notification-bar-open-button', function() {
|
171 |
setHeight(height);
|
172 |
});
|
173 |
}
|
@@ -185,27 +183,25 @@
|
|
185 |
if (data.display_scroll) {
|
186 |
log('Display on scroll enabled. Hiding notification bar.');
|
187 |
setHeight(0);
|
188 |
-
|
189 |
-
$(window).on('scroll', function() {
|
190 |
if (user_closed)
|
191 |
return;
|
192 |
|
193 |
if ($(this).scrollTop() > data.display_scroll_offset) {
|
194 |
setHeight(height);
|
195 |
-
}
|
196 |
-
else {
|
197 |
setHeight(0);
|
198 |
}
|
199 |
});
|
200 |
-
}
|
201 |
-
else {
|
202 |
//set open after seconds and auto close seconds.
|
203 |
log('Setting notification bar open event after ' + data.display_after + ' second(s).');
|
204 |
-
setTimeout(function() {
|
205 |
-
setHeight(height, function() {
|
206 |
if (data.auto_close_after > 0) {
|
207 |
log('Setting notification bar auto close event after ' + data.auto_close_after + ' second(s).');
|
208 |
-
setTimeout(function() {
|
209 |
setHeight(0, null, true);
|
210 |
}, data.auto_close_after * 1000);
|
211 |
}
|
10 |
|
11 |
*/
|
12 |
|
13 |
+
(function () {
|
14 |
//displays the notification bar
|
15 |
+
window.wpfront_notification_bar = function (data, process) {
|
16 |
+
var log = function (msg) {
|
17 |
+
if (data.log)
|
18 |
console.log('[WPFront Notification Bar] ' + msg);
|
19 |
};
|
20 |
|
21 |
+
if (typeof jQuery !== "function" || (data.keep_closed && typeof Cookies !== "function")) {
|
22 |
log('Waiting for ' + (typeof jQuery !== "function" ? 'jQuery.' : 'Cookies.'));
|
23 |
+
setTimeout(function () {
|
24 |
wpfront_notification_bar(data, process);
|
25 |
}, 100);
|
26 |
return;
|
27 |
}
|
28 |
|
29 |
+
if (data.position == 2 && process !== true) {
|
30 |
+
jQuery(function () {
|
31 |
wpfront_notification_bar(data, true);
|
32 |
});
|
33 |
return;
|
58 |
open_button.css("top", top + "px");
|
59 |
spacer.css("top", data.position_offset + "px");
|
60 |
var $body = $("body").prepend(spacer);
|
61 |
+
$(function () {
|
62 |
+
if (!$body.children().first().is(spacer)) {
|
63 |
$body.prepend(spacer);
|
64 |
}
|
65 |
});
|
66 |
+
} else {
|
|
|
67 |
log('Setting notification bar at bottom.');
|
68 |
var $body = $("body");
|
69 |
+
if (!$body.children().last().is(spacer)) {
|
70 |
$body.append(spacer);
|
71 |
}
|
72 |
+
$(function () {
|
73 |
+
if (!$body.children().last().is(spacer)) {
|
74 |
$body.append(spacer);
|
75 |
}
|
76 |
});
|
98 |
if (closed)
|
99 |
return;
|
100 |
closed = true;
|
101 |
+
} else {
|
|
|
102 |
if (!closed)
|
103 |
return;
|
104 |
closed = false;
|
105 |
}
|
106 |
|
107 |
+
if (height == 0 && data.keep_closed && userclosed) {
|
108 |
+
if (data.keep_closed_for > 0)
|
109 |
+
Cookies.set(keep_closed_cookie, 1, {path: "/", expires: data.keep_closed_for});
|
110 |
+
else
|
111 |
+
Cookies.set(keep_closed_cookie, 1, {path: "/"});
|
112 |
+
}
|
113 |
+
|
114 |
var fn = callback;
|
115 |
+
callback = function () {
|
116 |
fn();
|
117 |
if (height > 0) {
|
118 |
//set height to auto if in case content wraps on resize
|
119 |
if (data.height == 0)
|
120 |
bar.height("auto");
|
121 |
|
122 |
+
if (data.display_open_button) {
|
123 |
log('Setting reopen button state to hidden.');
|
124 |
open_button.addClass('hidden');
|
125 |
}
|
130 |
log('Setting reopen button state to visible.');
|
131 |
open_button.removeClass('hidden');
|
132 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
};
|
134 |
|
135 |
//set animation
|
136 |
+
if (height > 0)
|
137 |
log('Setting notification bar state to visible.');
|
138 |
else
|
139 |
log('Setting notification bar state to hidden.');
|
142 |
bar.stop().animate({"height": height + "px"}, data.animate_delay * 1000, "swing", callback);
|
143 |
if (data.fixed_position)
|
144 |
spacer.stop().animate({"height": height + "px"}, data.animate_delay * 1000);
|
145 |
+
} else {
|
|
|
146 |
bar.height(height);
|
147 |
if (data.fixed_position)
|
148 |
spacer.height(height);
|
152 |
}
|
153 |
|
154 |
if (data.close_button) {
|
155 |
+
spacer.on('click', '.wpfront-close', function () {
|
156 |
setHeight(0, null, true);
|
157 |
});
|
158 |
}
|
159 |
|
160 |
//close button action
|
161 |
if (data.button_action_close_bar) {
|
162 |
+
spacer.on('click', '.wpfront-button', function () {
|
163 |
setHeight(0, null, true);
|
164 |
});
|
165 |
}
|
166 |
|
167 |
if (data.display_open_button) {
|
168 |
+
spacer.on('click', '#wpfront-notification-bar-open-button', function () {
|
169 |
setHeight(height);
|
170 |
});
|
171 |
}
|
183 |
if (data.display_scroll) {
|
184 |
log('Display on scroll enabled. Hiding notification bar.');
|
185 |
setHeight(0);
|
186 |
+
|
187 |
+
$(window).on('scroll', function () {
|
188 |
if (user_closed)
|
189 |
return;
|
190 |
|
191 |
if ($(this).scrollTop() > data.display_scroll_offset) {
|
192 |
setHeight(height);
|
193 |
+
} else {
|
|
|
194 |
setHeight(0);
|
195 |
}
|
196 |
});
|
197 |
+
} else {
|
|
|
198 |
//set open after seconds and auto close seconds.
|
199 |
log('Setting notification bar open event after ' + data.display_after + ' second(s).');
|
200 |
+
setTimeout(function () {
|
201 |
+
setHeight(height, function () {
|
202 |
if (data.auto_close_after > 0) {
|
203 |
log('Setting notification bar auto close event after ' + data.auto_close_after + ' second(s).');
|
204 |
+
setTimeout(function () {
|
205 |
setHeight(0, null, true);
|
206 |
}, data.auto_close_after * 1000);
|
207 |
}
|
js/wpfront-notification-bar.min.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
(function(){window.wpfront_notification_bar=function(a,q){function b(g,b,f){b=b||d.noop;f&&(r=!0);if(0==g){if(l)return;l=!0}else{if(!l)return;l=!1}var h=b;b=function(){h();0<g&&(0==a.height&&k.height("auto"),a.display_open_button&&(e("Setting reopen button state to hidden."),m.addClass("hidden")),l=!1);0==g&&a.display_open_button&&(e("Setting reopen button state to visible."),
|
2 |
-
|
3 |
typeof jQuery?"jQuery.":"Cookies.")),setTimeout(function(){wpfront_notification_bar(a,q)},100);else if(2==a.position&&!0!==q)jQuery(function(){wpfront_notification_bar(a,!0)});else{var d=jQuery,p=a.keep_closed_cookie,c=d("#wpfront-notification-bar-spacer").removeClass("hidden"),k=d("#wpfront-notification-bar"),m=d("#wpfront-notification-bar-open-button");if(1==a.position){e("Setting notification bar at top.");var f=0;a.fixed_position&&a.is_admin_bar_showing&&(f=d("html").css("margin-top"),"0px"==
|
4 |
f&&(f=d("html").css("padding-top")),f=parseInt(f));a.fixed_position&&(f+=a.position_offset);k.css("top",f+"px");m.css("top",f+"px");c.css("top",a.position_offset+"px");var h=d("body").prepend(c);d(function(){h.children().first().is(c)||h.prepend(c)})}else e("Setting notification bar at bottom."),h=d("body"),h.children().last().is(c)||h.append(c),d(function(){h.children().last().is(c)||h.append(c)});var n=k.height();0<a.height&&(n=a.height,k.find("table, tbody, tr").css("height","100%"));k.height(0).css({position:a.fixed_position?
|
5 |
"fixed":"relative",visibility:"visible"});m.css({position:a.fixed_position?"fixed":"absolute"});var l=!1,r=!1;if(a.close_button)c.on("click",".wpfront-close",function(){b(0,null,!0)});if(a.button_action_close_bar)c.on("click",".wpfront-button",function(){b(0,null,!0)});if(a.display_open_button)c.on("click","#wpfront-notification-bar-open-button",function(){b(n)});a.keep_closed&&Cookies.get(p)?(e("Keep closed enabled and keep closed cookie exists. Hiding notification bar."),b(0)):(l=!0,a.display_scroll?
|
1 |
+
(function(){window.wpfront_notification_bar=function(a,q){function b(g,b,f){b=b||d.noop;f&&(r=!0);if(0==g){if(l)return;l=!0}else{if(!l)return;l=!1}0==g&&a.keep_closed&&f&&(0<a.keep_closed_for?Cookies.set(p,1,{path:"/",expires:a.keep_closed_for}):Cookies.set(p,1,{path:"/"}));var h=b;b=function(){h();0<g&&(0==a.height&&k.height("auto"),a.display_open_button&&(e("Setting reopen button state to hidden."),m.addClass("hidden")),l=!1);0==g&&a.display_open_button&&(e("Setting reopen button state to visible."),
|
2 |
+
m.removeClass("hidden"))};0<g?e("Setting notification bar state to visible."):e("Setting notification bar state to hidden.");0<a.animate_delay?(k.stop().animate({height:g+"px"},1E3*a.animate_delay,"swing",b),a.fixed_position&&c.stop().animate({height:g+"px"},1E3*a.animate_delay)):(k.height(g),a.fixed_position&&c.height(g),b())}var e=function(b){a.log&&console.log("[WPFront Notification Bar] "+b)};if("function"!==typeof jQuery||a.keep_closed&&"function"!==typeof Cookies)e("Waiting for "+("function"!==
|
3 |
typeof jQuery?"jQuery.":"Cookies.")),setTimeout(function(){wpfront_notification_bar(a,q)},100);else if(2==a.position&&!0!==q)jQuery(function(){wpfront_notification_bar(a,!0)});else{var d=jQuery,p=a.keep_closed_cookie,c=d("#wpfront-notification-bar-spacer").removeClass("hidden"),k=d("#wpfront-notification-bar"),m=d("#wpfront-notification-bar-open-button");if(1==a.position){e("Setting notification bar at top.");var f=0;a.fixed_position&&a.is_admin_bar_showing&&(f=d("html").css("margin-top"),"0px"==
|
4 |
f&&(f=d("html").css("padding-top")),f=parseInt(f));a.fixed_position&&(f+=a.position_offset);k.css("top",f+"px");m.css("top",f+"px");c.css("top",a.position_offset+"px");var h=d("body").prepend(c);d(function(){h.children().first().is(c)||h.prepend(c)})}else e("Setting notification bar at bottom."),h=d("body"),h.children().last().is(c)||h.append(c),d(function(){h.children().last().is(c)||h.append(c)});var n=k.height();0<a.height&&(n=a.height,k.find("table, tbody, tr").css("height","100%"));k.height(0).css({position:a.fixed_position?
|
5 |
"fixed":"relative",visibility:"visible"});m.css({position:a.fixed_position?"fixed":"absolute"});var l=!1,r=!1;if(a.close_button)c.on("click",".wpfront-close",function(){b(0,null,!0)});if(a.button_action_close_bar)c.on("click",".wpfront-button",function(){b(0,null,!0)});if(a.display_open_button)c.on("click","#wpfront-notification-bar-open-button",function(){b(n)});a.keep_closed&&Cookies.get(p)?(e("Keep closed enabled and keep closed cookie exists. Hiding notification bar."),b(0)):(l=!0,a.display_scroll?
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: syammohanm
|
|
3 |
Donate link: http://wpfront.com/donate/
|
4 |
Tags: notification bar, wordpress notification bar, top bar, bottom bar, notification, bar, quick bar, fixed bar, sticky bar, message bar, message, floating bar, notice, sticky header, special offer, discount offer, offer, important, attention bar, highlight bar, popup bar, hellobar, heads up, heads up bar, headsup, headsupbar, popup, Toolbar
|
5 |
Requires at least: 5.0
|
6 |
-
Tested up to: 5.8
|
7 |
Requires PHP: 7.0
|
8 |
-
Stable tag: 2.
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
@@ -68,6 +68,10 @@ The new version(1.3) allows you to filter the bar based on user roles. In this c
|
|
68 |
|
69 |
== Changelog ==
|
70 |
|
|
|
|
|
|
|
|
|
71 |
= 2.2.0 =
|
72 |
* You can now change the capability checked by Notification Bar.
|
73 |
* Use **WPFRONT_NOTIFICATION_BAR_EDIT_CAPABILITY** constant to set your custom capability or use **wpfront_notification_bar_edit_capability** filter.
|
@@ -172,6 +176,9 @@ The new version(1.3) allows you to filter the bar based on user roles. In this c
|
|
172 |
|
173 |
== Upgrade Notice ==
|
174 |
|
|
|
|
|
|
|
175 |
= 2.2.0 =
|
176 |
* New filters.
|
177 |
|
3 |
Donate link: http://wpfront.com/donate/
|
4 |
Tags: notification bar, wordpress notification bar, top bar, bottom bar, notification, bar, quick bar, fixed bar, sticky bar, message bar, message, floating bar, notice, sticky header, special offer, discount offer, offer, important, attention bar, highlight bar, popup bar, hellobar, heads up, heads up bar, headsup, headsupbar, popup, Toolbar
|
5 |
Requires at least: 5.0
|
6 |
+
Tested up to: 5.8.1
|
7 |
Requires PHP: 7.0
|
8 |
+
Stable tag: 2.3.0
|
9 |
License: GPLv3
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
68 |
|
69 |
== Changelog ==
|
70 |
|
71 |
+
= 2.3.0 =
|
72 |
+
* Custom capability bug fix.
|
73 |
+
* Keep closed bug fix.
|
74 |
+
|
75 |
= 2.2.0 =
|
76 |
* You can now change the capability checked by Notification Bar.
|
77 |
* Use **WPFRONT_NOTIFICATION_BAR_EDIT_CAPABILITY** constant to set your custom capability or use **wpfront_notification_bar_edit_capability** filter.
|
176 |
|
177 |
== Upgrade Notice ==
|
178 |
|
179 |
+
= 2.3.0 =
|
180 |
+
* Bug fixes.
|
181 |
+
|
182 |
= 2.2.0 =
|
183 |
* New filters.
|
184 |
|
wpfront-notification-bar.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WPFront Notification Bar
|
4 |
* Plugin URI: http://wpfront.com/notification-bar-plugin/
|
5 |
* Description: Easily lets you create a bar on top or bottom to display a notification.
|
6 |
-
* Version: 2.
|
7 |
* Requires at least: 5.0
|
8 |
* Requires PHP: 7.0
|
9 |
* Author: Syam Mohan
|
3 |
* Plugin Name: WPFront Notification Bar
|
4 |
* Plugin URI: http://wpfront.com/notification-bar-plugin/
|
5 |
* Description: Easily lets you create a bar on top or bottom to display a notification.
|
6 |
+
* Version: 2.3.0.102911
|
7 |
* Requires at least: 5.0
|
8 |
* Requires PHP: 7.0
|
9 |
* Author: Syam Mohan
|