WPFront Notification Bar - Version 1.9.0

Version Description

  • Reopen button image is now configurable.
  • Add dynamic CSS through URL.
  • Compatibility fixes.
  • Bug fixes.
  • PHP 8.0 fixes.
  • SiteGround conflict fix.
Download this release

Release Info

Developer syammohanm
Plugin Icon 128x128 WPFront Notification Bar
Version 1.9.0
Comparing to
See all releases

Code changes from version 1.8.1 to 1.9.0

classes/class-wpfront-notification-bar-options.php CHANGED
@@ -71,10 +71,12 @@ if (!class_exists('WPFront_Notification_Bar_Options')) {
71
  $this->addOption('include_pages', 'string', '', array($this, 'validate_include_exclude_pages'));
72
  $this->addOption('exclude_pages', 'string', '', array($this, 'validate_include_exclude_pages'));
73
  $this->addOption('display_open_button', 'bit', false)->label(__('Display Reopen Button', 'wpfront-notification-bar'));
 
74
  $this->addOption('open_button_color', 'string', '#00b7ea')->label(__('Reopen Button Color', 'wpfront-notification-bar'));
75
  $this->addOption('keep_closed', 'bit', false)->label(__('Keep Closed', 'wpfront-notification-bar'));
76
  $this->addOption('keep_closed_for', 'int', 0, array($this, 'validate_zero_positive'))->label(__('Keep Closed For', 'wpfront-notification-bar'));
77
  $this->addOption('position_offset', 'int', 0)->label(__('Position Offset', 'wpfront-notification-bar'));
 
78
  $this->addOption('custom_css', 'string', '')->label(__('Custom CSS', 'wpfront-notification-bar'));
79
  $this->addOption('close_button_color', 'string', '#555555', array($this, 'validate_color'))->label(__('Close Button Color', 'wpfront-notification-bar'));
80
  $this->addOption('close_button_color_hover', 'string', '#aaaaaa', array($this, 'validate_color'));
@@ -94,6 +96,8 @@ if (!class_exists('WPFront_Notification_Bar_Options')) {
94
  $this->addOption('small_device_width', 'int', 640, array($this, 'validate_zero_positive'))->label(__('Small Device Max Width', 'wpfront-notification-bar'));
95
  $this->addOption('hide_small_window', 'bit', false)->label(__('Hide on Small Window', 'wpfront-notification-bar'));
96
  $this->addOption('small_window_width', 'int', 640, array($this, 'validate_zero_positive'))->label(__('Small Window Max Width', 'wpfront-notification-bar'));
 
 
97
  }
98
 
99
  //validation function
@@ -161,33 +165,33 @@ if (!class_exists('WPFront_Notification_Bar_Options')) {
161
 
162
  return $timestamp;
163
  }
164
-
165
  protected function validate_landingpage_cookie_name($arg) {
166
  if (trim($arg) == '') {
167
  return 'wpfront-notification-bar-landingpage';
168
  }
169
-
170
  return $arg;
171
  }
172
-
173
  protected function validate_keep_closed_cookie_name($arg) {
174
  if (trim($arg) == '') {
175
  return 'wpfront-notification-bar-keep-closed';
176
  }
177
-
178
  return $arg;
179
  }
180
-
181
  protected function validate_include_exclude_pages($pages) {
182
- if(strpos($pages, '.') === false) {
183
  return $pages;
184
  }
185
 
186
  $pages = explode(',', $pages);
187
 
188
- for($i = 0; $i < count($pages); $i++) {
189
  $e = explode('.', $pages[$i]);
190
- if(count($e) > 1) {
191
  $pages[$i] = $e[1];
192
  } else {
193
  $pages[$i] = $e[0];
@@ -196,7 +200,12 @@ if (!class_exists('WPFront_Notification_Bar_Options')) {
196
 
197
  return implode(',', $pages);
198
  }
199
-
 
 
 
 
200
  }
201
 
202
- }
 
71
  $this->addOption('include_pages', 'string', '', array($this, 'validate_include_exclude_pages'));
72
  $this->addOption('exclude_pages', 'string', '', array($this, 'validate_include_exclude_pages'));
73
  $this->addOption('display_open_button', 'bit', false)->label(__('Display Reopen Button', 'wpfront-notification-bar'));
74
+ $this->addOption('reopen_button_image_url', 'string', '', array($this, 'validate_reopen_button_image_url'))->label(__('Reopen Button Image URL', 'wpfront-notification-bar'));
75
  $this->addOption('open_button_color', 'string', '#00b7ea')->label(__('Reopen Button Color', 'wpfront-notification-bar'));
76
  $this->addOption('keep_closed', 'bit', false)->label(__('Keep Closed', 'wpfront-notification-bar'));
77
  $this->addOption('keep_closed_for', 'int', 0, array($this, 'validate_zero_positive'))->label(__('Keep Closed For', 'wpfront-notification-bar'));
78
  $this->addOption('position_offset', 'int', 0)->label(__('Position Offset', 'wpfront-notification-bar'));
79
+ $this->addOption('dynamic_css_use_url', 'bit', false)->label(__('Use Dynamic CSS URL', 'wpfront-notification-bar'));
80
  $this->addOption('custom_css', 'string', '')->label(__('Custom CSS', 'wpfront-notification-bar'));
81
  $this->addOption('close_button_color', 'string', '#555555', array($this, 'validate_color'))->label(__('Close Button Color', 'wpfront-notification-bar'));
82
  $this->addOption('close_button_color_hover', 'string', '#aaaaaa', array($this, 'validate_color'));
96
  $this->addOption('small_device_width', 'int', 640, array($this, 'validate_zero_positive'))->label(__('Small Device Max Width', 'wpfront-notification-bar'));
97
  $this->addOption('hide_small_window', 'bit', false)->label(__('Hide on Small Window', 'wpfront-notification-bar'));
98
  $this->addOption('small_window_width', 'int', 640, array($this, 'validate_zero_positive'))->label(__('Small Window Max Width', 'wpfront-notification-bar'));
99
+ $this->addOption('attach_on_shutdown', 'bit', false)->label(__('Attach on Shutdown', 'wpfront-notification-bar'));
100
+ $this->addOption('last_saved', 'string', '0');
101
  }
102
 
103
  //validation function
165
 
166
  return $timestamp;
167
  }
168
+
169
  protected function validate_landingpage_cookie_name($arg) {
170
  if (trim($arg) == '') {
171
  return 'wpfront-notification-bar-landingpage';
172
  }
173
+
174
  return $arg;
175
  }
176
+
177
  protected function validate_keep_closed_cookie_name($arg) {
178
  if (trim($arg) == '') {
179
  return 'wpfront-notification-bar-keep-closed';
180
  }
181
+
182
  return $arg;
183
  }
184
+
185
  protected function validate_include_exclude_pages($pages) {
186
+ if (strpos($pages, '.') === false) {
187
  return $pages;
188
  }
189
 
190
  $pages = explode(',', $pages);
191
 
192
+ for ($i = 0; $i < count($pages); $i++) {
193
  $e = explode('.', $pages[$i]);
194
+ if (count($e) > 1) {
195
  $pages[$i] = $e[1];
196
  } else {
197
  $pages[$i] = $e[0];
200
 
201
  return implode(',', $pages);
202
  }
203
+
204
+ protected function validate_reopen_button_image_url($arg) {
205
+ return trim($arg);
206
+ }
207
+
208
  }
209
 
210
+ }
211
+
classes/class-wpfront-notification-bar.php CHANGED
@@ -22,6 +22,7 @@
22
  */
23
 
24
  require_once("class-wpfront-notification-bar-options.php");
 
25
 
26
  if (!class_exists('WPFront_Notification_Bar')) {
27
 
@@ -34,7 +35,7 @@ if (!class_exists('WPFront_Notification_Bar')) {
34
  class WPFront_Notification_Bar {
35
 
36
  //Constants
37
- const VERSION = '1.8.1';
38
  const OPTIONS_GROUP_NAME = 'wpfront-notification-bar-options-group';
39
  const OPTION_NAME = 'wpfront-notification-bar-options';
40
  const PLUGIN_SLUG = 'wpfront-notification-bar';
@@ -50,7 +51,6 @@ if (!class_exists('WPFront_Notification_Bar')) {
50
  private $markupLoaded;
51
  private $scriptLoaded;
52
  private $enabled = null;
53
-
54
  private $logs = array();
55
  private static $instance = null;
56
 
@@ -71,6 +71,7 @@ if (!class_exists('WPFront_Notification_Bar')) {
71
  $this->plugin_file = $plugin_file;
72
 
73
  add_action('plugins_loaded', array($this, 'plugins_loaded'));
 
74
 
75
  if (is_admin()) {
76
  add_action('admin_init', array($this, 'admin_init'));
@@ -121,18 +122,18 @@ if (!class_exists('WPFront_Notification_Bar')) {
121
  }
122
 
123
  public function set_landingpage_cookie() {
124
- if(headers_sent()) {
125
  return;
126
  }
127
-
128
- if($this->doing_ajax()) {
129
  return;
130
  }
131
-
132
- if(defined('WP_CLI') && WP_CLI) {
133
  return;
134
  }
135
-
136
  //for landing page tracking
137
  $cookie_name = $this->options->landingpage_cookie_name();
138
  if (!isset($_COOKIE[$cookie_name]) && !is_admin() && $this->options->display_pages() == 2 && $this->enabled()) {
@@ -165,6 +166,8 @@ if (!class_exists('WPFront_Notification_Bar')) {
165
 
166
  //options page scripts
167
  public function enqueue_options_scripts() {
 
 
168
  $this->enqueue_scripts();
169
 
170
  wp_enqueue_script('jquery');
@@ -197,7 +200,7 @@ if (!class_exists('WPFront_Notification_Bar')) {
197
 
198
  public function plugin_action_links($links, $file) {
199
  if ($file == self::PLUGIN_FILE) {
200
- $settings_link = '<a href="' . menu_page_url(self::PLUGIN_SLUG, false) . '">' . __('Settings', 'wpfront-notification-bar') . '</a>';
201
  array_unshift($links, $settings_link);
202
  }
203
  return $links;
@@ -205,26 +208,36 @@ if (!class_exists('WPFront_Notification_Bar')) {
205
 
206
  //add scripts
207
  public function enqueue_scripts() {
208
- if($this->options->debug_mode()) {
209
  add_action('wp_footer', array($this, 'write_debug_logs'), 99999);
210
- add_action('shutdown', array($this, 'write_debug_logs'), 99999);
 
 
211
  }
212
-
213
  if ($this->enabled() == false) {
214
  return;
215
  }
216
 
217
  wp_enqueue_script('jquery');
218
-
219
- if($this->options->keep_closed()) {
220
  wp_enqueue_script('js-cookie', plugins_url('jquery-plugins/js-cookie.min.js', $this->plugin_file), array(), '2.2.1');
221
  }
222
 
223
  wp_enqueue_script('wpfront-notification-bar', plugins_url("js/wpfront-notification-bar{$this->min_file_suffix}.js", $this->plugin_file), array('jquery'), self::VERSION);
224
 
225
- add_action('wp_footer', array($this, 'write_markup'));
226
- add_action('shutdown', array($this, 'write_markup'));
227
-
 
 
 
 
 
 
 
 
 
228
  $this->scriptLoaded = true;
229
  }
230
 
@@ -235,6 +248,28 @@ if (!class_exists('WPFront_Notification_Bar')) {
235
  }
236
 
237
  wp_enqueue_style('wpfront-notification-bar', plugins_url("css/wpfront-notification-bar{$this->min_file_suffix}.css", $this->plugin_file), array(), self::VERSION);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  }
239
 
240
  //creates options page
@@ -265,7 +300,7 @@ if (!class_exists('WPFront_Notification_Bar')) {
265
 
266
  if ($this->enabled()) {
267
  $this->log('Writing HTML template.');
268
-
269
  include(plugin_dir_path($this->plugin_file) . 'templates/notification-bar-template.php');
270
 
271
  $json = json_encode(array(
@@ -296,27 +331,27 @@ if (!class_exists('WPFront_Notification_Bar')) {
296
 
297
  private function write_load_script($json) {
298
  $this->log('Writing JS load script.');
299
-
300
  $this->write_debug_logs();
301
-
302
- if($this->options->debug_mode()) {
303
- ?>
304
- <script type="text/javascript">
305
- console.log('[WPFront Notification Bar] Starting JS scripts execution.');
306
- </script>
307
- <?php
308
- }
309
  ?>
 
310
  <script type="text/javascript">
311
  function __load_wpfront_notification_bar() {
312
  if (typeof wpfront_notification_bar === "function") {
313
  wpfront_notification_bar(<?php echo $json; ?>);
314
  } else {
315
- <?php
316
- if($this->options->debug_mode()) {
317
- echo 'console.log("[WPFront Notification Bar] Waiting for JS function \"wpfront_notification_bar\".");';
318
- }
319
- ?>
320
  setTimeout(__load_wpfront_notification_bar, 100);
321
  }
322
  }
@@ -324,32 +359,36 @@ if (!class_exists('WPFront_Notification_Bar')) {
324
  </script>
325
  <?php
326
  }
327
-
328
  public function write_debug_logs() {
329
- if(empty($this->logs)) {
330
  return;
331
  }
332
-
333
- if(!$this->options->debug_mode()) {
334
  return;
335
  }
336
-
337
  if ($this->doing_ajax()) {
338
  return;
339
  }
340
-
341
  $now = current_time('mysql');
342
  $now = strtotime($now);
343
  $now_str = date('Y-m-d h:i:s a', $now);
344
-
345
  echo "<!-- [WPFront Notification Bar] Page generated at $now_str. -->";
346
  echo '<script type="text/javascript">';
347
  echo "console.log('[WPFront Notification Bar] Page generated at $now_str.');";
348
  foreach ($this->logs as $message => $args) {
349
- vprintf("console.log('$message');", $args);
 
 
 
 
350
  }
351
  echo '</script>';
352
-
353
  $this->logs = array();
354
  }
355
 
@@ -505,16 +544,16 @@ if (!class_exists('WPFront_Notification_Bar')) {
505
  case 1:
506
  return true;
507
  case 2:
508
- if(isset($_COOKIE[$this->options->landingpage_cookie_name()])) {
509
  $this->log('Filter: Display only on landing page. This is not the landing page, disabling notification.');
510
  return false;
511
  }
512
-
513
  return true;
514
  case 3:
515
  case 4:
516
  global $post;
517
- if(empty($post)) {
518
  $this->log('Filter: Global post object is empty.');
519
  }
520
  $ID = false;
@@ -565,16 +604,16 @@ if (!class_exists('WPFront_Notification_Bar')) {
565
  }
566
 
567
  protected function enabled() {
568
- if($this->enabled !== null) {
569
  return $this->enabled;
570
  }
571
-
572
  if ($this->options->enabled()) {
573
  $this->log('Notification bar is enabled.');
574
  $this->enabled = $this->filter();
575
  return $this->enabled;
576
  }
577
-
578
  if ($this->is_preview_mode()) {
579
  $this->log('Notification bar is running in preview mode.');
580
  $this->enabled = $this->filter();
@@ -597,22 +636,42 @@ if (!class_exists('WPFront_Notification_Bar')) {
597
 
598
  protected function doing_ajax() {
599
  if (defined('DOING_AJAX') && DOING_AJAX) {
600
- return true;
 
 
 
 
 
 
 
 
601
  }
602
 
603
  if (wp_doing_ajax()) {
604
- return true;
605
  }
606
 
607
- if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
608
- return true;
609
  }
610
 
611
- if (!empty($_SERVER['REQUEST_URI']) && strtolower($_SERVER['REQUEST_URI']) == '/wp-admin/async-upload.php') {
612
- return true;
613
  }
614
 
615
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
616
  }
617
 
618
  public function settings_updated($old_value, $value) {
@@ -636,25 +695,41 @@ if (!class_exists('WPFront_Notification_Bar')) {
636
  }
637
 
638
  private function is_preview_mode() {
639
- if($this->options->preview_mode()) {
640
  $this->log('Preview mode is enabled.');
641
-
642
- if(empty($_COOKIE[self::PREVIEW_MODE_NAME])) {
643
  $this->log('Preview mode flag is not set. Disabling preview mode.');
644
  return false;
645
  }
646
-
647
  return true;
648
  }
649
-
650
  $this->log('Preview mode is not enabled.');
651
  return false;
652
  }
653
-
654
  private function log($message, $args = null) {
655
  $this->logs["[WPFront Notification Bar] $message"] = $args;
656
  }
657
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
658
  }
659
 
660
  }
22
  */
23
 
24
  require_once("class-wpfront-notification-bar-options.php");
25
+ require_once(dirname(__DIR__) . "/templates/custom-css-template.php");
26
 
27
  if (!class_exists('WPFront_Notification_Bar')) {
28
 
35
  class WPFront_Notification_Bar {
36
 
37
  //Constants
38
+ const VERSION = '1.9.0.03231';
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';
51
  private $markupLoaded;
52
  private $scriptLoaded;
53
  private $enabled = null;
 
54
  private $logs = array();
55
  private static $instance = null;
56
 
71
  $this->plugin_file = $plugin_file;
72
 
73
  add_action('plugins_loaded', array($this, 'plugins_loaded'));
74
+ add_action('init', array($this, 'custom_css'));
75
 
76
  if (is_admin()) {
77
  add_action('admin_init', array($this, 'admin_init'));
122
  }
123
 
124
  public function set_landingpage_cookie() {
125
+ if (headers_sent()) {
126
  return;
127
  }
128
+
129
+ if ($this->doing_ajax()) {
130
  return;
131
  }
132
+
133
+ if (defined('WP_CLI') && WP_CLI) {
134
  return;
135
  }
136
+
137
  //for landing page tracking
138
  $cookie_name = $this->options->landingpage_cookie_name();
139
  if (!isset($_COOKIE[$cookie_name]) && !is_admin() && $this->options->display_pages() == 2 && $this->enabled()) {
166
 
167
  //options page scripts
168
  public function enqueue_options_scripts() {
169
+ wp_enqueue_media();
170
+
171
  $this->enqueue_scripts();
172
 
173
  wp_enqueue_script('jquery');
200
 
201
  public function plugin_action_links($links, $file) {
202
  if ($file == self::PLUGIN_FILE) {
203
+ $settings_link = '<a id="wpfront-notification-bar-settings-link" href="' . menu_page_url(self::PLUGIN_SLUG, false) . '">' . __('Settings', 'wpfront-notification-bar') . '</a>';
204
  array_unshift($links, $settings_link);
205
  }
206
  return $links;
208
 
209
  //add scripts
210
  public function enqueue_scripts() {
211
+ if ($this->options->debug_mode()) {
212
  add_action('wp_footer', array($this, 'write_debug_logs'), 99999);
213
+ if ($this->options->attach_on_shutdown()) {
214
+ add_action('shutdown', array($this, 'write_debug_logs'), 99999);
215
+ }
216
  }
 
217
  if ($this->enabled() == false) {
218
  return;
219
  }
220
 
221
  wp_enqueue_script('jquery');
222
+
223
+ if ($this->options->keep_closed()) {
224
  wp_enqueue_script('js-cookie', plugins_url('jquery-plugins/js-cookie.min.js', $this->plugin_file), array(), '2.2.1');
225
  }
226
 
227
  wp_enqueue_script('wpfront-notification-bar', plugins_url("js/wpfront-notification-bar{$this->min_file_suffix}.js", $this->plugin_file), array('jquery'), self::VERSION);
228
 
229
+ if ($this->options->position() == 1) {
230
+ add_action('wp_body_open', array($this, 'write_markup'));
231
+ add_action('wp_footer', array($this, 'write_markup'));//Callback hook 'wp_body_open' only works from WordPress 5.2
232
+ add_action('admin_head', array($this, 'write_markup'));
233
+ } else {
234
+ add_action('wp_footer', array($this, 'write_markup'));
235
+ add_action('admin_footer', array($this, 'write_markup'));
236
+ }
237
+ if ($this->options->attach_on_shutdown()) {
238
+ add_action('shutdown', array($this, 'write_markup'));
239
+ }
240
+
241
  $this->scriptLoaded = true;
242
  }
243
 
248
  }
249
 
250
  wp_enqueue_style('wpfront-notification-bar', plugins_url("css/wpfront-notification-bar{$this->min_file_suffix}.css", $this->plugin_file), array(), self::VERSION);
251
+
252
+ if ($this->options->dynamic_css_use_url()) {
253
+ wp_enqueue_style('wpfront-notification-bar-custom', $this->custom_css_url(), array('wpfront-notification-bar'), self::VERSION . '.' . $this->options->last_saved());
254
+ }
255
+ }
256
+
257
+ private function custom_css_url() {
258
+ return plugins_url("css/wpfront-notification-bar-custom-css/", $this->plugin_file);
259
+ }
260
+
261
+ public function custom_css() {
262
+ if (strpos($_SERVER['REQUEST_URI'], '/css/wpfront-notification-bar-custom-css/') === false) {
263
+ return;
264
+ }
265
+
266
+ header('Content-Type: text/css; charset=UTF-8');
267
+ header('Expires: ' . gmdate('D, d M Y H:i:s ', strtotime('+1 year')) . 'GMT');
268
+
269
+ $template = new WPFront_Notification_Bar_Custom_CSS_Template();
270
+ $template->write($this);
271
+
272
+ exit();
273
  }
274
 
275
  //creates options page
300
 
301
  if ($this->enabled()) {
302
  $this->log('Writing HTML template.');
303
+
304
  include(plugin_dir_path($this->plugin_file) . 'templates/notification-bar-template.php');
305
 
306
  $json = json_encode(array(
331
 
332
  private function write_load_script($json) {
333
  $this->log('Writing JS load script.');
334
+
335
  $this->write_debug_logs();
336
+
337
+ if ($this->options->debug_mode()) {
338
+ ?>
339
+ <script type="text/javascript">
340
+ console.log('[WPFront Notification Bar] Starting JS scripts execution.');
341
+ </script>
342
+ <?php }
 
343
  ?>
344
+
345
  <script type="text/javascript">
346
  function __load_wpfront_notification_bar() {
347
  if (typeof wpfront_notification_bar === "function") {
348
  wpfront_notification_bar(<?php echo $json; ?>);
349
  } else {
350
+ <?php
351
+ if ($this->options->debug_mode()) {
352
+ echo 'console.log("[WPFront Notification Bar] Waiting for JS function \"wpfront_notification_bar\".");';
353
+ }
354
+ ?>
355
  setTimeout(__load_wpfront_notification_bar, 100);
356
  }
357
  }
359
  </script>
360
  <?php
361
  }
362
+
363
  public function write_debug_logs() {
364
+ if (empty($this->logs)) {
365
  return;
366
  }
367
+
368
+ if (!$this->options->debug_mode()) {
369
  return;
370
  }
371
+
372
  if ($this->doing_ajax()) {
373
  return;
374
  }
375
+
376
  $now = current_time('mysql');
377
  $now = strtotime($now);
378
  $now_str = date('Y-m-d h:i:s a', $now);
379
+
380
  echo "<!-- [WPFront Notification Bar] Page generated at $now_str. -->";
381
  echo '<script type="text/javascript">';
382
  echo "console.log('[WPFront Notification Bar] Page generated at $now_str.');";
383
  foreach ($this->logs as $message => $args) {
384
+ if(empty($args)) {
385
+ printf("console.log('$message');");
386
+ } else {
387
+ vprintf("console.log('$message');", $args);
388
+ }
389
  }
390
  echo '</script>';
391
+
392
  $this->logs = array();
393
  }
394
 
544
  case 1:
545
  return true;
546
  case 2:
547
+ if (isset($_COOKIE[$this->options->landingpage_cookie_name()])) {
548
  $this->log('Filter: Display only on landing page. This is not the landing page, disabling notification.');
549
  return false;
550
  }
551
+
552
  return true;
553
  case 3:
554
  case 4:
555
  global $post;
556
+ if (empty($post)) {
557
  $this->log('Filter: Global post object is empty.');
558
  }
559
  $ID = false;
604
  }
605
 
606
  protected function enabled() {
607
+ if ($this->enabled !== null) {
608
  return $this->enabled;
609
  }
610
+
611
  if ($this->options->enabled()) {
612
  $this->log('Notification bar is enabled.');
613
  $this->enabled = $this->filter();
614
  return $this->enabled;
615
  }
616
+
617
  if ($this->is_preview_mode()) {
618
  $this->log('Notification bar is running in preview mode.');
619
  $this->enabled = $this->filter();
636
 
637
  protected function doing_ajax() {
638
  if (defined('DOING_AJAX') && DOING_AJAX) {
639
+ return TRUE;
640
+ }
641
+
642
+ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
643
+ return TRUE;
644
+ }
645
+
646
+ if (!empty($_SERVER['REQUEST_URI']) && strtolower($_SERVER['REQUEST_URI']) == '/wp-admin/async-upload.php') {
647
+ return TRUE;
648
  }
649
 
650
  if (wp_doing_ajax()) {
651
+ return TRUE;
652
  }
653
 
654
+ if (wp_is_json_request()) {
655
+ return TRUE;
656
  }
657
 
658
+ if (wp_is_jsonp_request()) {
659
+ return TRUE;
660
  }
661
 
662
+ if (wp_is_xml_request()) {
663
+ return TRUE;
664
+ }
665
+
666
+ if (defined('XMLRPC_REQUEST') && XMLRPC_REQUEST) {
667
+ return TRUE;
668
+ }
669
+
670
+ if (defined('WP_CLI') && WP_CLI) {
671
+ return TRUE;
672
+ }
673
+
674
+ return FALSE;
675
  }
676
 
677
  public function settings_updated($old_value, $value) {
695
  }
696
 
697
  private function is_preview_mode() {
698
+ if ($this->options->preview_mode()) {
699
  $this->log('Preview mode is enabled.');
700
+
701
+ if (empty($_COOKIE[self::PREVIEW_MODE_NAME])) {
702
  $this->log('Preview mode flag is not set. Disabling preview mode.');
703
  return false;
704
  }
705
+
706
  return true;
707
  }
708
+
709
  $this->log('Preview mode is not enabled.');
710
  return false;
711
  }
712
+
713
  private function log($message, $args = null) {
714
  $this->logs["[WPFront Notification Bar] $message"] = $args;
715
  }
716
 
717
+ public function get_plugin_file() {
718
+ return $this->plugin_file;
719
+ }
720
+
721
+ public function get_options() {
722
+ return $this->options;
723
+ }
724
+
725
+ public function display_on_page_load() {
726
+ if (!$this->options->display_scroll() && $this->options->display_after() == 0 && $this->options->animate_delay() == 0) {
727
+ return true;
728
+ }
729
+
730
+ return false;
731
+ }
732
+
733
  }
734
 
735
  }
css/options.css CHANGED
@@ -89,4 +89,18 @@
89
  .colorpicker input
90
  {
91
  min-height: 0px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
89
  .colorpicker input
90
  {
91
  min-height: 0px;
92
+ }
93
+
94
+ #wpfront-notification-bar-options #media-library-button
95
+ {
96
+ min-height: 0px;
97
+ height: 24px;
98
+ margin-bottom: 5px;
99
+ line-height: inherit;
100
+ vertical-align: inherit;
101
+ }
102
+
103
+ #wpfront-notification-bar-options #reopen-button-image-url
104
+ {
105
+ width:600px;
106
  }
css/options.min.css CHANGED
@@ -1 +1 @@
1
- #icon-wpfront-notification-bar{background:url("../images/settings32x32.png") no-repeat scroll 0 0 rgba(0,0,0,0)}#wpfront-notification-bar-options input.seconds,#wpfront-notification-bar-options input.pixels{width:40px}#wpfront-notification-bar-options input.date,#wpfront-notification-bar-options input.time{width:100px}#wpfront-notification-bar-options textArea{width:70%}#wpfront-notification-bar-options input.URL{width:50%}#wpfront-notification-bar-options table.form-table .color-selector-div{display:inline-block;width:120px}#wpfront-notification-bar-options table.form-table .color-selector{vertical-align:middle}#wpfront-notification-bar-options table.form-table .color-value{width:75px;height:24px;min-height:0;vertical-align:middle}#wpfront-notification-bar-options table.form-table div.pages-selection,#wpfront-notification-bar-options table.form-table div.roles-selection{width:70%;height:150px;background-color:#fff;overflow:auto;border:1px solid #dfdfdf;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}#wpfront-notification-bar-options table.form-table div.page-div,#wpfront-notification-bar-options table.form-table div.role-div{float:left;width:250px;padding:2px;white-space:nowrap;overflow:hidden}#wpfront-notification-bar-options input.cookie-name{width:30%}#wpfront-notification-bar-options input.post-id-list{width:70%}.colorpicker input{min-height:0}
1
+ #icon-wpfront-notification-bar{background:url("../images/settings32x32.png") no-repeat scroll 0 0 rgba(0,0,0,0)}#wpfront-notification-bar-options input.seconds,#wpfront-notification-bar-options input.pixels{width:40px}#wpfront-notification-bar-options input.date,#wpfront-notification-bar-options input.time{width:100px}#wpfront-notification-bar-options textArea{width:70%}#wpfront-notification-bar-options input.URL{width:50%}#wpfront-notification-bar-options table.form-table .color-selector-div{display:inline-block;width:120px}#wpfront-notification-bar-options table.form-table .color-selector{vertical-align:middle}#wpfront-notification-bar-options table.form-table .color-value{width:75px;height:24px;min-height:0;vertical-align:middle}#wpfront-notification-bar-options table.form-table div.pages-selection,#wpfront-notification-bar-options table.form-table div.roles-selection{width:70%;height:150px;background-color:#fff;overflow:auto;border:1px solid #dfdfdf;-moz-border-radius:4px;-khtml-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}#wpfront-notification-bar-options table.form-table div.page-div,#wpfront-notification-bar-options table.form-table div.role-div{float:left;width:250px;padding:2px;white-space:nowrap;overflow:hidden}#wpfront-notification-bar-options input.cookie-name{width:30%}#wpfront-notification-bar-options input.post-id-list{width:70%}.colorpicker input{min-height:0}#wpfront-notification-bar-options #media-library-button{min-height:0;height:24px;margin-bottom:5px;line-height:inherit;vertical-align:inherit}#wpfront-notification-bar-options #reopen-button-image-url{width:600px}
css/wpfront-notification-bar.css CHANGED
@@ -31,6 +31,22 @@
31
  width: 100%;
32
  }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  #wpfront-notification-bar div.wpfront-close
35
  {
36
  position: absolute;
@@ -109,11 +125,11 @@
109
  height: 30px;
110
  cursor: pointer;
111
  background-repeat: no-repeat;
112
-
113
  border-radius: 2px;
114
  -webkit-border-radius: 2px;
115
  -moz-border-radius: 2px;
116
-
117
  -webkit-box-sizing: content-box;
118
  -moz-box-sizing: content-box;
119
  box-sizing: content-box;
@@ -127,10 +143,9 @@
127
  #wpfront-notification-bar-open-button.top
128
  {
129
  top: 0px;
130
- background-image: url(../images/arrow_down.png);
131
  background-position: top center;
132
  border-top: 0px;
133
-
134
  -webkit-border-top-right-radius: 0px;
135
  -webkit-border-top-left-radius: 0px;
136
  -moz-border-radius-topright: 0px;
@@ -142,10 +157,9 @@
142
  #wpfront-notification-bar-open-button.bottom
143
  {
144
  bottom: 0px;
145
- background-image: url(../images/arrow_up.png);
146
  background-position: bottom center;
147
  border-bottom: 0px;
148
-
149
  -webkit-border-bottom-right-radius: 0px;
150
  -webkit-border-bottom-left-radius: 0px;
151
  -moz-border-radius-bottomright: 0px;
31
  width: 100%;
32
  }
33
 
34
+ #wpfront-notification-bar.wpfront-fixed.load
35
+ {
36
+ visibility: visible;
37
+ position: relative;
38
+ }
39
+
40
+ #wpfront-notification-bar.top
41
+ {
42
+ top: 0px;
43
+ }
44
+
45
+ #wpfront-notification-bar.bottom
46
+ {
47
+ bottom: 0px;
48
+ }
49
+
50
  #wpfront-notification-bar div.wpfront-close
51
  {
52
  position: absolute;
125
  height: 30px;
126
  cursor: pointer;
127
  background-repeat: no-repeat;
128
+
129
  border-radius: 2px;
130
  -webkit-border-radius: 2px;
131
  -moz-border-radius: 2px;
132
+
133
  -webkit-box-sizing: content-box;
134
  -moz-box-sizing: content-box;
135
  box-sizing: content-box;
143
  #wpfront-notification-bar-open-button.top
144
  {
145
  top: 0px;
 
146
  background-position: top center;
147
  border-top: 0px;
148
+
149
  -webkit-border-top-right-radius: 0px;
150
  -webkit-border-top-left-radius: 0px;
151
  -moz-border-radius-topright: 0px;
157
  #wpfront-notification-bar-open-button.bottom
158
  {
159
  bottom: 0px;
 
160
  background-position: bottom center;
161
  border-bottom: 0px;
162
+
163
  -webkit-border-bottom-right-radius: 0px;
164
  -webkit-border-bottom-left-radius: 0px;
165
  -moz-border-radius-bottomright: 0px;
css/wpfront-notification-bar.min.css CHANGED
@@ -1 +1 @@
1
- #wpfront-notification-bar{visibility:hidden;position:fixed;overflow:hidden;left:0;right:0;color:#fff;background-color:#000}.wpfront-bottom-shadow{-webkit-box-shadow:0 5px 5px 0 rgba(0,0,0,0.75);-moz-box-shadow:0 5px 5px 0 rgba(0,0,0,0.75);box-shadow:0 5px 5px 0 rgba(0,0,0,0.75)}.wpfront-top-shadow{-webkit-box-shadow:0 -5px 5px 0 rgba(0,0,0,0.75);-moz-box-shadow:0 -5px 5px 0 rgba(0,0,0,0.75);box-shadow:0 -5px 5px 0 rgba(0,0,0,0.75)}#wpfront-notification-bar.wpfront-fixed{position:fixed;z-index:9999;width:100%}#wpfront-notification-bar div.wpfront-close{position:absolute;top:3px;right:5px;cursor:pointer;font-family:Arial,sans-serif;font-weight:bold;line-height:0;font-size:10px;padding:5px 2px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}#wpfront-notification-bar table,#wpfront-notification-bar tbody,#wpfront-notification-bar tr{margin:auto;border:0;padding:0;background:inherit}#wpfront-notification-bar td{background:inherit;vertical-align:middle;text-align:center;border:0;margin:0;padding:5px 0;line-height:1em}#wpfront-notification-bar div{text-align:center;display:inline-block;vertical-align:middle}#wpfront-notification-bar a.wpfront-button{display:inline-block;box-shadow:0 1px 2px rgba(0,0,0,0.2);white-space:nowrap;font-size:13px;font-weight:bold;text-align:center;text-decoration:none;text-shadow:0 1px 1px rgba(0,0,0,0.3);cursor:pointer;padding:5px 10px;margin-left:5px;border-radius:2px;-webkit-border-radius:2px;-moz-border-radius:2px}#wpfront-notification-bar-open-button{position:absolute;right:10px;z-index:9999;border:3px solid white;width:23px;height:30px;cursor:pointer;background-repeat:no-repeat;border-radius:2px;-webkit-border-radius:2px;-moz-border-radius:2px;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}#wpfront-notification-bar-open-button.hidden{display:none}#wpfront-notification-bar-open-button.top{top:0;background-image:url(../images/arrow_down.png);background-position:top center;border-top:0;-webkit-border-top-right-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-top-left-radius:0}#wpfront-notification-bar-open-button.bottom{bottom:0;background-image:url(../images/arrow_up.png);background-position:bottom center;border-bottom:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;border-bottom-right-radius:0;border-bottom-left-radius:0}#wpfront-notification-bar-spacer{position:relative}#wpfront-notification-bar-spacer.hidden{display:none}
1
+ #wpfront-notification-bar{visibility:hidden;position:fixed;overflow:hidden;left:0;right:0;color:#fff;background-color:#000}.wpfront-bottom-shadow{-webkit-box-shadow:0 5px 5px 0 rgba(0,0,0,0.75);-moz-box-shadow:0 5px 5px 0 rgba(0,0,0,0.75);box-shadow:0 5px 5px 0 rgba(0,0,0,0.75)}.wpfront-top-shadow{-webkit-box-shadow:0 -5px 5px 0 rgba(0,0,0,0.75);-moz-box-shadow:0 -5px 5px 0 rgba(0,0,0,0.75);box-shadow:0 -5px 5px 0 rgba(0,0,0,0.75)}#wpfront-notification-bar.wpfront-fixed{position:fixed;z-index:9999;width:100%}#wpfront-notification-bar.wpfront-fixed.load{visibility:visible;position:relative}#wpfront-notification-bar.top{top:0}#wpfront-notification-bar.bottom{bottom:0}#wpfront-notification-bar div.wpfront-close{position:absolute;top:3px;right:5px;cursor:pointer;font-family:Arial,sans-serif;font-weight:bold;line-height:0;font-size:10px;padding:5px 2px;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px}#wpfront-notification-bar table,#wpfront-notification-bar tbody,#wpfront-notification-bar tr{margin:auto;border:0;padding:0;background:inherit}#wpfront-notification-bar td{background:inherit;vertical-align:middle;text-align:center;border:0;margin:0;padding:5px 0;line-height:1em}#wpfront-notification-bar div{text-align:center;display:inline-block;vertical-align:middle}#wpfront-notification-bar a.wpfront-button{display:inline-block;box-shadow:0 1px 2px rgba(0,0,0,0.2);white-space:nowrap;font-size:13px;font-weight:bold;text-align:center;text-decoration:none;text-shadow:0 1px 1px rgba(0,0,0,0.3);cursor:pointer;padding:5px 10px;margin-left:5px;border-radius:2px;-webkit-border-radius:2px;-moz-border-radius:2px}#wpfront-notification-bar-open-button{position:absolute;right:10px;z-index:9999;border:3px solid white;width:23px;height:30px;cursor:pointer;background-repeat:no-repeat;border-radius:2px;-webkit-border-radius:2px;-moz-border-radius:2px;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}#wpfront-notification-bar-open-button.hidden{display:none}#wpfront-notification-bar-open-button.top{top:0;background-position:top center;border-top:0;-webkit-border-top-right-radius:0;-webkit-border-top-left-radius:0;-moz-border-radius-topright:0;-moz-border-radius-topleft:0;border-top-right-radius:0;border-top-left-radius:0}#wpfront-notification-bar-open-button.bottom{bottom:0;background-position:bottom center;border-bottom:0;-webkit-border-bottom-right-radius:0;-webkit-border-bottom-left-radius:0;-moz-border-radius-bottomright:0;-moz-border-radius-bottomleft:0;border-bottom-right-radius:0;border-bottom-left-radius:0}#wpfront-notification-bar-spacer{position:relative}#wpfront-notification-bar-spacer.hidden{display:none}
js/options.js CHANGED
@@ -1,63 +1,90 @@
1
- jQuery(document).ready(function () {
2
- var $ = jQuery;
3
-
4
- $('#wpfront-notification-bar-options .pages-selection input[type="checkbox"]').change(function () {
5
- var $this = $(this);
6
- var $input = $this.parent().parent().parent().prev();
7
- var $text = $input.val();
8
-
9
- if ($this.prop('checked')) {
10
- $text += ',' + $this.val();
11
- } else {
12
- $text = (',' + $text + ',').replace(',' + $this.val() + ',', ',');
13
- }
14
-
15
- $text = $text.replace(/(^[,\s]+)|([,\s]+$)/g, '');
16
- $input.val($text);
17
- });
18
-
19
- $('#wpfront-notification-bar-options .roles-selection input[type="checkbox"]').change(function () {
20
- var values = [];
21
- var div = $(this).parent().parent().parent();
22
- div.find('input:checked').each(function (i, e) {
23
- values.push($(e).val());
24
- });
25
- div.children(":first").val(JSON.stringify(values));
26
- });
27
-
28
- $('#wpfront-notification-bar-options input.date').datepicker({
29
- 'dateFormat': 'yy-mm-dd'
30
- });
31
-
32
- $('#wpfront-notification-bar-options input.time').timepicker({
33
- 'timeFormat': 'h:i a'
34
- });
35
-
36
- $('#chk_button_action_url_noopener').change(function() {
37
- $('#txt_button_action_url_noopener').val($(this).prop('checked') ? 1 : 0);
38
- });
39
-
40
- function setColorPicker(div) {
41
- if(div.ColorPicker) {
42
- div.ColorPicker({
43
- color: div.attr('color'),
44
- onShow: function (colpkr) {
45
- $(colpkr).fadeIn(500);
46
- return false;
47
- }, onHide: function (colpkr) {
48
- $(colpkr).fadeOut(500);
49
- return false;
50
- },
51
- onChange: function (hsb, hex, rgb) {
52
- div.css('backgroundColor', '#' + hex);
53
- div.next().val('#' + hex);
54
- }
55
- }).css('backgroundColor', div.attr('color'));
56
- }
57
- }
58
-
59
- $('#wpfront-notification-bar-options').find(".color-selector").each(function (i, e) {
60
- setColorPicker($(e));
61
- });
62
-
63
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function () {
2
+ var $ = jQuery;
3
+ var $divOptions = $('#wpfront-notification-bar-options');
4
+
5
+ $divOptions.on('change', '.pages-selection input[type="checkbox"]', function() {
6
+ var $this = $(this);
7
+ var $input = $this.parent().parent().parent().prev();
8
+ var $text = $input.val();
9
+
10
+ if ($this.prop('checked')) {
11
+ $text += ',' + $this.val();
12
+ } else {
13
+ $text = (',' + $text + ',').replace(',' + $this.val() + ',', ',');
14
+ }
15
+
16
+ $text = $text.replace(/(^[,\s]+)|([,\s]+$)/g, '');
17
+ $input.val($text);
18
+ });
19
+
20
+ $divOptions.on('change', '.roles-selection input[type="checkbox"]', function() {
21
+ var values = [];
22
+ var div = $(this).parent().parent().parent();
23
+ div.find('input:checked').each(function (i, e) {
24
+ values.push($(e).val());
25
+ });
26
+ div.children(":first").val(JSON.stringify(values));
27
+ });
28
+
29
+ $divOptions.find('input.date').datepicker({
30
+ 'dateFormat': 'yy-mm-dd'
31
+ });
32
+
33
+ $divOptions.find('input.time').timepicker({
34
+ 'timeFormat': 'h:i a'
35
+ });
36
+
37
+ $divOptions.on('change', '#chk_button_action_url_noopener', function() {
38
+ $('#txt_button_action_url_noopener').val($(this).prop('checked') ? 1 : 0);
39
+ });
40
+
41
+ function setColorPicker(div) {
42
+ if (div.ColorPicker) {
43
+ div.ColorPicker({
44
+ color: div.attr('color'),
45
+ onShow: function (colpkr) {
46
+ $(colpkr).fadeIn(500);
47
+ return false;
48
+ }, onHide: function (colpkr) {
49
+ $(colpkr).fadeOut(500);
50
+ return false;
51
+ },
52
+ onChange: function (hsb, hex, rgb) {
53
+ div.css('backgroundColor', '#' + hex);
54
+ div.next().val('#' + hex);
55
+ }
56
+ }).css('backgroundColor', div.attr('color'));
57
+ }
58
+ }
59
+
60
+ $divOptions.find(".color-selector").each(function (i, e) {
61
+ setColorPicker($(e));
62
+ });
63
+
64
+ });
65
+
66
+ (function () {
67
+ window.init_wpfront_notifiction_bar_options = function (settings) {
68
+ var $ = jQuery;
69
+ var mediaLibrary = null;
70
+
71
+ $('#wpfront-notification-bar-options').on('click', '#media-library-button', function () {
72
+ if (mediaLibrary === null) {
73
+ mediaLibrary = wp.media.frames.file_frame = wp.media({
74
+ title: settings.choose_image,
75
+ multiple: false,
76
+ button: {
77
+ text: settings.select_image
78
+ }
79
+ }).on('select', function () {
80
+ var obj = mediaLibrary.state().get('selection').first().toJSON();
81
+
82
+ $('#reopen-button-image-url').val(obj.url);
83
+ });
84
+ }
85
+
86
+ mediaLibrary.open();
87
+ return false;
88
+ });
89
+ };
90
+ })();
js/options.min.js CHANGED
@@ -1,3 +1,3 @@
1
- jQuery(document).ready(function(){function e(a){a.ColorPicker&&a.ColorPicker({color:a.attr("color"),onShow:function(a){b(a).fadeIn(500);return!1},onHide:function(a){b(a).fadeOut(500);return!1},onChange:function(b,c,f){a.css("backgroundColor","#"+c);a.next().val("#"+c)}}).css("backgroundColor",a.attr("color"))}var b=jQuery;b('#wpfront-notification-bar-options .pages-selection input[type="checkbox"]').change(function(){var a=b(this),d=a.parent().parent().parent().prev(),c=d.val();c=a.prop("checked")?
2
- c+(","+a.val()):(","+c+",").replace(","+a.val()+",",",");c=c.replace(/(^[,\s]+)|([,\s]+$)/g,"");d.val(c)});b('#wpfront-notification-bar-options .roles-selection input[type="checkbox"]').change(function(){var a=[],d=b(this).parent().parent().parent();d.find("input:checked").each(function(c,d){a.push(b(d).val())});d.children(":first").val(JSON.stringify(a))});b("#wpfront-notification-bar-options input.date").datepicker({dateFormat:"yy-mm-dd"});b("#wpfront-notification-bar-options input.time").timepicker({timeFormat:"h:i a"});
3
- b("#chk_button_action_url_noopener").change(function(){b("#txt_button_action_url_noopener").val(b(this).prop("checked")?1:0)});b("#wpfront-notification-bar-options").find(".color-selector").each(function(a,d){e(b(d))})});
1
+ jQuery(document).ready(function(){function d(b){b.ColorPicker&&b.ColorPicker({color:b.attr("color"),onShow:function(b){c(b).fadeIn(500);return!1},onHide:function(b){c(b).fadeOut(500);return!1},onChange:function(c,a,d){b.css("backgroundColor","#"+a);b.next().val("#"+a)}}).css("backgroundColor",b.attr("color"))}var c=jQuery,a=c("#wpfront-notification-bar-options");a.on("change",'.pages-selection input[type="checkbox"]',function(){var b=c(this),a=b.parent().parent().parent().prev(),e=a.val();e=b.prop("checked")?
2
+ e+(","+b.val()):(","+e+",").replace(","+b.val()+",",",");e=e.replace(/(^[,\s]+)|([,\s]+$)/g,"");a.val(e)});a.on("change",'.roles-selection input[type="checkbox"]',function(){var b=[],a=c(this).parent().parent().parent();a.find("input:checked").each(function(a,d){b.push(c(d).val())});a.children(":first").val(JSON.stringify(b))});a.find("input.date").datepicker({dateFormat:"yy-mm-dd"});a.find("input.time").timepicker({timeFormat:"h:i a"});a.on("change","#chk_button_action_url_noopener",function(){c("#txt_button_action_url_noopener").val(c(this).prop("checked")?
3
+ 1:0)});a.find(".color-selector").each(function(a,f){d(c(f))})});(function(){window.init_wpfront_notifiction_bar_options=function(d){var c=jQuery,a=null;c("#wpfront-notification-bar-options").on("click","#media-library-button",function(){null===a&&(a=wp.media.frames.file_frame=wp.media({title:d.choose_image,multiple:!1,button:{text:d.select_image}}).on("select",function(){var b=a.state().get("selection").first().toJSON();c("#reopen-button-image-url").val(b.url)}));a.open();return!1})}})();
js/wpfront-notification-bar.js CHANGED
@@ -12,22 +12,29 @@
12
 
13
  (function() {
14
  //displays the notification bar
15
- window.wpfront_notification_bar = function(data) {
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);
25
  }, 100);
26
  return;
27
  }
28
-
 
 
 
 
 
 
 
29
  var $ = jQuery;
30
-
31
  var keep_closed_cookie = data.keep_closed_cookie;
32
 
33
  var spacer = $("#wpfront-notification-bar-spacer").removeClass('hidden');
@@ -49,13 +56,25 @@
49
  }
50
  bar.css("top", top + "px");
51
  open_button.css("top", top + "px");
52
- $("body").prepend(spacer);
53
  spacer.css("top", data.position_offset + "px");
 
 
 
 
 
 
54
  }
55
  else {
56
  log('Setting notification bar at bottom.');
57
- $("body").append(spacer);
58
- bar.css("bottom", "0px");
 
 
 
 
 
 
 
59
  }
60
 
61
  var height = bar.height();
@@ -94,12 +113,12 @@
94
  //set height to auto if in case content wraps on resize
95
  if (data.height == 0)
96
  bar.height("auto");
97
-
98
  if(data.display_open_button) {
99
  log('Setting reopen button state to hidden.');
100
  open_button.addClass('hidden');
101
  }
102
-
103
  closed = false;
104
  }
105
  if (height == 0 && data.display_open_button) {
@@ -119,7 +138,7 @@
119
  log('Setting notification bar state to visible.');
120
  else
121
  log('Setting notification bar state to hidden.');
122
-
123
  if (data.animate_delay > 0) {
124
  bar.stop().animate({"height": height + "px"}, data.animate_delay * 1000, "swing", callback);
125
  if (data.fixed_position)
@@ -135,20 +154,20 @@
135
  }
136
 
137
  if (data.close_button) {
138
- bar.find(".wpfront-close").click(function() {
139
  setHeight(0, null, true);
140
  });
141
  }
142
 
143
  //close button action
144
  if (data.button_action_close_bar) {
145
- bar.find(".wpfront-button").click(function() {
146
  setHeight(0, null, true);
147
  });
148
  }
149
 
150
  if (data.display_open_button) {
151
- open_button.click(function() {
152
  setHeight(height);
153
  });
154
  }
@@ -166,8 +185,8 @@
166
  if (data.display_scroll) {
167
  log('Display on scroll enabled. Hiding notification bar.');
168
  setHeight(0);
169
-
170
- $(window).scroll(function() {
171
  if (user_closed)
172
  return;
173
 
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;
34
+ }
35
+
36
  var $ = jQuery;
37
+
38
  var keep_closed_cookie = data.keep_closed_cookie;
39
 
40
  var spacer = $("#wpfront-notification-bar-spacer").removeClass('hidden');
56
  }
57
  bar.css("top", top + "px");
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
+ });
78
  }
79
 
80
  var height = bar.height();
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
  }
121
+
122
  closed = false;
123
  }
124
  if (height == 0 && data.display_open_button) {
138
  log('Setting notification bar state to visible.');
139
  else
140
  log('Setting notification bar state to hidden.');
141
+
142
  if (data.animate_delay > 0) {
143
  bar.stop().animate({"height": height + "px"}, data.animate_delay * 1000, "swing", callback);
144
  if (data.fixed_position)
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
  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
 
js/wpfront-notification-bar.min.js CHANGED
@@ -1,6 +1,6 @@
1
- (function(){window.wpfront_notification_bar=function(a){function b(g,b,d){b=b||e.noop;d&&(p=!0);if(0==g){if(h)return;h=!0}else{if(!h)return;h=!1}var k=b;b=function(){k();0<g&&(0==a.height&&f.height("auto"),a.display_open_button&&(c("Setting reopen button state to hidden."),l.addClass("hidden")),h=!1);0==g&&a.display_open_button&&(c("Setting reopen button state to visible."),l.removeClass("hidden"));0==g&&a.keep_closed&&d&&(0<a.keep_closed_for?Cookies.set(n,1,{path:"/",expires:a.keep_closed_for}):
2
- Cookies.set(n,1,{path:"/"}))};0<g?c("Setting notification bar state to visible."):c("Setting notification bar state to hidden.");0<a.animate_delay?(f.stop().animate({height:g+"px"},1E3*a.animate_delay,"swing",b),a.fixed_position&&m.stop().animate({height:g+"px"},1E3*a.animate_delay)):(f.height(g),a.fixed_position&&m.height(g),b())}var c=function(b){a.log&&console.log("[WPFront Notification Bar] "+b)};if("function"!==typeof jQuery||a.keep_closed&&"function"!==typeof Cookies)c("Waiting for "+("function"!==
3
- typeof jQuery?"jQuery.":"Cookies.")),setTimeout(function(){wpfront_notification_bar(a)},100);else{var e=jQuery,n=a.keep_closed_cookie,m=e("#wpfront-notification-bar-spacer").removeClass("hidden"),f=e("#wpfront-notification-bar"),l=e("#wpfront-notification-bar-open-button");if(1==a.position){c("Setting notification bar at top.");var d=0;a.fixed_position&&a.is_admin_bar_showing&&(d=e("html").css("margin-top"),"0px"==d&&(d=e("html").css("padding-top")),d=parseInt(d));a.fixed_position&&(d+=a.position_offset);
4
- f.css("top",d+"px");l.css("top",d+"px");e("body").prepend(m);m.css("top",a.position_offset+"px")}else c("Setting notification bar at bottom."),e("body").append(m),f.css("bottom","0px");var k=f.height();0<a.height&&(k=a.height,f.find("table, tbody, tr").css("height","100%"));f.height(0).css({position:a.fixed_position?"fixed":"relative",visibility:"visible"});l.css({position:a.fixed_position?"fixed":"absolute"});var h=!1,p=!1;a.close_button&&f.find(".wpfront-close").click(function(){b(0,null,!0)});
5
- a.button_action_close_bar&&f.find(".wpfront-button").click(function(){b(0,null,!0)});a.display_open_button&&l.click(function(){b(k)});a.keep_closed&&Cookies.get(n)?(c("Keep closed enabled and keep closed cookie exists. Hiding notification bar."),b(0)):(h=!0,a.display_scroll?(c("Display on scroll enabled. Hiding notification bar."),b(0),e(window).scroll(function(){p||(e(this).scrollTop()>a.display_scroll_offset?b(k):b(0))})):(c("Setting notification bar open event after "+a.display_after+" second(s)."),
6
- setTimeout(function(){b(k,function(){0<a.auto_close_after&&(c("Setting notification bar auto close event after "+a.auto_close_after+" second(s)."),setTimeout(function(){b(0,null,!0)},1E3*a.auto_close_after))})},1E3*a.display_after)))}}})();
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."),m.removeClass("hidden"));0==g&&a.keep_closed&&f&&(0<a.keep_closed_for?Cookies.set(p,1,{path:"/",expires:a.keep_closed_for}):
2
+ Cookies.set(p,1,{path:"/"}))};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?
6
+ (e("Display on scroll enabled. Hiding notification bar."),b(0),d(window).on("scroll",function(){r||(d(this).scrollTop()>a.display_scroll_offset?b(n):b(0))})):(e("Setting notification bar open event after "+a.display_after+" second(s)."),setTimeout(function(){b(n,function(){0<a.auto_close_after&&(e("Setting notification bar auto close event after "+a.auto_close_after+" second(s)."),setTimeout(function(){b(0,null,!0)},1E3*a.auto_close_after))})},1E3*a.display_after)))}}})();
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
- === WPFront Notification Bar ===
2
  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.7
7
  Requires PHP: 7.0
8
- Stable tag: 1.8.1
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -68,6 +68,14 @@ The new version(1.3) allows you to filter the bar based on user roles. In this c
68
 
69
  == Changelog ==
70
 
 
 
 
 
 
 
 
 
71
  = 1.8.1 =
72
  * Description correction.
73
 
@@ -138,6 +146,10 @@ The new version(1.3) allows you to filter the bar based on user roles. In this c
138
  * Initial release
139
 
140
  == Upgrade Notice ==
 
 
 
 
141
  = 1.8 =
142
  * New features added.
143
 
1
+ === WPFront Notification Bar ===
2
  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.7
7
  Requires PHP: 7.0
8
+ Stable tag: 1.9.0
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
68
 
69
  == Changelog ==
70
 
71
+ = 1.9.0 =
72
+ * Reopen button image is now configurable.
73
+ * Add dynamic CSS through URL.
74
+ * Compatibility fixes.
75
+ * Bug fixes.
76
+ * PHP 8.0 fixes.
77
+ * SiteGround conflict fix.
78
+
79
  = 1.8.1 =
80
  * Description correction.
81
 
146
  * Initial release
147
 
148
  == Upgrade Notice ==
149
+
150
+ = 1.9.0 =
151
+ * Compatibility fixes.
152
+
153
  = 1.8 =
154
  * New features added.
155
 
templates/custom-css-template.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ WPFront Notification Bar Plugin
4
+ Copyright (C) 2013, WPFront.com
5
+ Website: wpfront.com
6
+ Contact: syam@wpfront.com
7
+
8
+ WPFront Notification Bar Plugin is distributed under the GNU General Public License, Version 3,
9
+ June 2007. Copyright (C) 2007 Free Software Foundation, Inc., 51 Franklin
10
+ St, Fifth Floor, Boston, MA 02110, USA
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
16
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
+ */
23
+
24
+ class WPFront_Notification_Bar_Custom_CSS_Template {
25
+
26
+ protected $controller;
27
+ protected $options;
28
+
29
+ public function write($controller) {
30
+ $this->controller = $controller;
31
+ $this->options = $controller->get_options();
32
+
33
+ $this->wpfront_notification_bar_css();
34
+ $this->div_wpfront_message_css();
35
+ $this->a_wpfront_button_css();
36
+ $this->open_button_css();
37
+ $this->div_wpfront_close_css();
38
+ $this->div_wpfront_close_hover_css();
39
+ $this->hide_small_device();
40
+ $this->hide_small_window();
41
+ $this->custom_css();
42
+ }
43
+
44
+ protected function wpfront_notification_bar_css() {
45
+ ?>
46
+
47
+ #wpfront-notification-bar
48
+ {
49
+ background: <?php echo $this->options->bar_from_color(); ?>;
50
+ background: -moz-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%, <?php echo $this->options->bar_to_color(); ?> 100%);
51
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->bar_from_color(); ?>), color-stop(100%,<?php echo $this->options->bar_to_color(); ?>));
52
+ background: -webkit-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
53
+ background: -o-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
54
+ background: -ms-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
55
+ background: linear-gradient(to bottom, <?php echo $this->options->bar_from_color(); ?> 0%, <?php echo $this->options->bar_to_color(); ?> 100%);
56
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->bar_from_color(); ?>', endColorstr='<?php echo $this->options->bar_to_color(); ?>',GradientType=0 );
57
+ }
58
+ <?php
59
+ }
60
+
61
+ protected function div_wpfront_message_css() {
62
+ ?>
63
+ #wpfront-notification-bar div.wpfront-message
64
+ {
65
+ color: <?php echo $this->options->message_color(); ?>;
66
+ }
67
+
68
+ <?php
69
+ }
70
+
71
+ protected function a_wpfront_button_css() {
72
+ ?>
73
+ #wpfront-notification-bar a.wpfront-button
74
+ {
75
+ background: <?php echo $this->options->button_from_color(); ?>;
76
+ background: -moz-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%, <?php echo $this->options->button_to_color(); ?> 100%);
77
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->button_from_color(); ?>), color-stop(100%,<?php echo $this->options->button_to_color(); ?>));
78
+ background: -webkit-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
79
+ background: -o-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
80
+ background: -ms-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
81
+ background: linear-gradient(to bottom, <?php echo $this->options->button_from_color(); ?> 0%, <?php echo $this->options->button_to_color(); ?> 100%);
82
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->button_from_color(); ?>', endColorstr='<?php echo $this->options->button_to_color(); ?>',GradientType=0 );
83
+
84
+ color: <?php echo $this->options->button_text_color(); ?>;
85
+ }
86
+ <?php
87
+ }
88
+
89
+ protected function open_button_css() {
90
+ ?>
91
+ #wpfront-notification-bar-open-button
92
+ {
93
+ background-color: <?php echo $this->options->open_button_color(); ?>;
94
+ <?php
95
+ if (!empty($this->options->reopen_button_image_url())) {
96
+ echo "background-image: url({$this->options->reopen_button_image_url()});";
97
+ }
98
+ ?>
99
+ }
100
+ <?php
101
+ if (empty($this->options->reopen_button_image_url())) {
102
+ $url_top = plugins_url('images/arrow_down.png', $this->controller->get_plugin_file());
103
+ $url_bottom = plugins_url('images/arrow_up.png', $this->controller->get_plugin_file());
104
+ ?>
105
+ #wpfront-notification-bar-open-button.top
106
+ {
107
+ background-image: url(<?php echo $url_top; ?>);
108
+ }
109
+
110
+ #wpfront-notification-bar-open-button.bottom
111
+ {
112
+ background-image: url(<?php echo $url_bottom; ?>);
113
+ }
114
+ <?php
115
+ }
116
+ }
117
+
118
+ protected function div_wpfront_close_css() {
119
+ ?>
120
+ #wpfront-notification-bar div.wpfront-close
121
+ {
122
+ border: 1px solid <?php echo $this->options->close_button_color(); ?>;
123
+ background-color: <?php echo $this->options->close_button_color(); ?>;
124
+ color: <?php echo $this->options->close_button_color_x(); ?>;
125
+ }
126
+ <?php
127
+ }
128
+
129
+ protected function div_wpfront_close_hover_css() {
130
+ ?>
131
+ #wpfront-notification-bar div.wpfront-close:hover
132
+ {
133
+ border: 1px solid <?php echo $this->options->close_button_color_hover(); ?>;
134
+ background-color: <?php echo $this->options->close_button_color_hover(); ?>;
135
+ }
136
+ <?php
137
+ }
138
+
139
+ protected function hide_small_device() {
140
+ if ($this->options->hide_small_device()) {
141
+ echo "@media screen and (max-device-width: {$this->options->small_device_width()}px) { #wpfront-notification-bar-spacer { display:none; } }";
142
+ }
143
+ }
144
+
145
+ protected function hide_small_window() {
146
+ if ($this->options->hide_small_window()) {
147
+ echo "@media screen and (max-width: {$this->options->small_window_width()}px) { #wpfront-notification-bar-spacer { display:none; } }";
148
+ }
149
+ }
150
+
151
+ protected function custom_css() {
152
+ echo $this->options->custom_css();
153
+ }
154
+
155
+ }
templates/notification-bar-template.php CHANGED
@@ -29,87 +29,36 @@
29
  */
30
  ?>
31
 
32
- <style type="text/css">
33
- #wpfront-notification-bar
34
- {
35
- background: <?php echo $this->options->bar_from_color(); ?>;
36
- background: -moz-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%, <?php echo $this->options->bar_to_color(); ?> 100%);
37
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->bar_from_color(); ?>), color-stop(100%,<?php echo $this->options->bar_to_color(); ?>));
38
- background: -webkit-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
39
- background: -o-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
40
- background: -ms-linear-gradient(top, <?php echo $this->options->bar_from_color(); ?> 0%,<?php echo $this->options->bar_to_color(); ?> 100%);
41
- background: linear-gradient(to bottom, <?php echo $this->options->bar_from_color(); ?> 0%, <?php echo $this->options->bar_to_color(); ?> 100%);
42
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->bar_from_color(); ?>', endColorstr='<?php echo $this->options->bar_to_color(); ?>',GradientType=0 );
43
- }
44
-
45
- #wpfront-notification-bar div.wpfront-message
46
- {
47
- color: <?php echo $this->options->message_color(); ?>;
48
- }
49
-
50
- #wpfront-notification-bar a.wpfront-button
51
- {
52
- background: <?php echo $this->options->button_from_color(); ?>;
53
- background: -moz-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%, <?php echo $this->options->button_to_color(); ?> 100%);
54
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,<?php echo $this->options->button_from_color(); ?>), color-stop(100%,<?php echo $this->options->button_to_color(); ?>));
55
- background: -webkit-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
56
- background: -o-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
57
- background: -ms-linear-gradient(top, <?php echo $this->options->button_from_color(); ?> 0%,<?php echo $this->options->button_to_color(); ?> 100%);
58
- background: linear-gradient(to bottom, <?php echo $this->options->button_from_color(); ?> 0%, <?php echo $this->options->button_to_color(); ?> 100%);
59
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='<?php echo $this->options->button_from_color(); ?>', endColorstr='<?php echo $this->options->button_to_color(); ?>',GradientType=0 );
60
-
61
- color: <?php echo $this->options->button_text_color(); ?>;
62
- }
63
-
64
- #wpfront-notification-bar-open-button
65
- {
66
- background-color: <?php echo $this->options->open_button_color(); ?>;
67
- }
68
-
69
- #wpfront-notification-bar div.wpfront-close
70
- {
71
- border: 1px solid <?php echo $this->options->close_button_color(); ?>;
72
- background-color: <?php echo $this->options->close_button_color(); ?>;
73
- color: <?php echo $this->options->close_button_color_x(); ?>;
74
- }
75
-
76
- #wpfront-notification-bar div.wpfront-close:hover
77
- {
78
- border: 1px solid <?php echo $this->options->close_button_color_hover(); ?>;
79
- background-color: <?php echo $this->options->close_button_color_hover(); ?>;
80
- }
81
-
82
- <?php
83
- if($this->options->hide_small_device()) {
84
- echo "@media screen and (max-device-width: {$this->options->small_device_width()}px) { #wpfront-notification-bar-spacer { display:none; } }";
85
- }
86
  ?>
87
-
88
-
89
  <?php
90
- if($this->options->hide_small_window()) {
91
- echo "@media screen and (max-width: {$this->options->small_window_width()}px) { #wpfront-notification-bar-spacer { display:none; } }";
92
- }
93
  ?>
94
-
95
- </style>
 
 
 
96
 
97
  <?php if ($this->options->display_button() && $this->options->button_action() == 2) { ?>
98
  <script type="text/javascript">
99
  function wpfront_notification_bar_button_action_script() {
100
  try {
101
  <?php echo $this->options->button_action_javascript(); ?>
102
- }
103
- catch (err) {
104
  }
105
  }
106
  </script>
107
  <?php } ?>
108
 
109
- <div id="wpfront-notification-bar-spacer" class="hidden">
110
  <div id="wpfront-notification-bar-open-button" aria-label="reopen" class="hidden <?php echo $this->options->position() == 1 ? 'top wpfront-bottom-shadow' : 'bottom wpfront-top-shadow'; ?>"></div>
111
- <div id="wpfront-notification-bar" class="wpfront-fixed <?php if ($this->options->display_shadow()) echo $this->options->position() == 1 ? 'wpfront-bottom-shadow' : 'wpfront-top-shadow'; ?>">
112
- <?php if ($this->options->close_button()) { ?>
 
113
  <div aria-label="close" class="wpfront-close">X</div>
114
  <?php } ?>
115
  <table border="0" cellspacing="0" cellpadding="0" role="presentation">
@@ -119,35 +68,35 @@
119
  <?php echo $this->get_message_text(); ?>
120
  </div>
121
  <div>
122
- <?php
123
- if ($this->options->display_button()) {
124
- $button_text = $this->get_button_text();
125
- ?>
126
- <?php
127
- if ($this->options->button_action() == 1) {
128
- $rel = array();
129
-
130
- if($this->options->button_action_url_nofollow()) {
131
- $rel[] = 'nofollow';
132
- }
133
-
134
- if($this->options->button_action_url_noreferrer()) {
135
- $rel[] = 'noreferrer';
136
- }
137
-
138
- if($this->options->button_action_new_tab() && $this->options->button_action_url_noopener()) {
139
- $rel[] = 'noopener';
140
- }
141
-
142
- $rel = implode(' ', $rel);
143
- ?>
144
- <a class="wpfront-button" href="<?php echo $this->options->button_action_url(); ?>" target="<?php echo $this->options->button_action_new_tab() ? '_blank' : '_self'; ?>" <?php echo empty($rel) ? '' : "rel=\"$rel\""; ?>><?php echo $button_text; ?></a>
145
- <?php
146
- }
147
  ?>
148
- <?php if ($this->options->button_action() == 2) { ?>
149
- <a class="wpfront-button" onclick="javascript:wpfront_notification_bar_button_action_script();"><?php echo $button_text; ?></a>
150
- <?php } ?>
 
 
 
 
151
  <?php } ?>
152
  </div>
153
  </td>
@@ -155,8 +104,6 @@
155
  </table>
156
  </div>
157
  </div>
 
158
 
159
 
160
- <style type="text/css">
161
- <?php echo $this->options->custom_css(); ?>
162
- </style>
29
  */
30
  ?>
31
 
32
+ <?php
33
+ if (!$this->options->dynamic_css_use_url()) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  ?>
35
+ <style type="text/css">
 
36
  <?php
37
+ $template = new WPFront_Notification_Bar_Custom_CSS_Template();
38
+ $template->write($this);
 
39
  ?>
40
+ </style>
41
+ <?php
42
+ }
43
+ ?>
44
+
45
 
46
  <?php if ($this->options->display_button() && $this->options->button_action() == 2) { ?>
47
  <script type="text/javascript">
48
  function wpfront_notification_bar_button_action_script() {
49
  try {
50
  <?php echo $this->options->button_action_javascript(); ?>
51
+ } catch (err) {
 
52
  }
53
  }
54
  </script>
55
  <?php } ?>
56
 
57
+ <div id="wpfront-notification-bar-spacer" class="<?php echo $this->display_on_page_load() ? ' ' : 'hidden'; ?>">
58
  <div id="wpfront-notification-bar-open-button" aria-label="reopen" class="hidden <?php echo $this->options->position() == 1 ? 'top wpfront-bottom-shadow' : 'bottom wpfront-top-shadow'; ?>"></div>
59
+ <div id="wpfront-notification-bar" class="wpfront-fixed <?php echo $this->display_on_page_load() ? ' load' : ''; ?> <?php echo $this->options->position() == 1 ? ' top' : ' bottom'; ?> <?php if ($this->options->display_shadow()) echo $this->options->position() == 1 ? ' wpfront-bottom-shadow' : ' wpfront-top-shadow'; ?>">
60
+
61
+ <?php if ($this->options->close_button()) { ?>
62
  <div aria-label="close" class="wpfront-close">X</div>
63
  <?php } ?>
64
  <table border="0" cellspacing="0" cellpadding="0" role="presentation">
68
  <?php echo $this->get_message_text(); ?>
69
  </div>
70
  <div>
71
+ <?php
72
+ if ($this->options->display_button()) {
73
+ $button_text = $this->get_button_text();
74
+ ?>
75
+ <?php
76
+ if ($this->options->button_action() == 1) {
77
+ $rel = array();
78
+
79
+ if ($this->options->button_action_url_nofollow()) {
80
+ $rel[] = 'nofollow';
81
+ }
82
+
83
+ if ($this->options->button_action_url_noreferrer()) {
84
+ $rel[] = 'noreferrer';
85
+ }
86
+
87
+ if ($this->options->button_action_new_tab() && $this->options->button_action_url_noopener()) {
88
+ $rel[] = 'noopener';
89
+ }
90
+
91
+ $rel = implode(' ', $rel);
 
 
 
 
92
  ?>
93
+ <a class="wpfront-button" href="<?php echo $this->options->button_action_url(); ?>" target="<?php echo $this->options->button_action_new_tab() ? '_blank' : '_self'; ?>" <?php echo empty($rel) ? '' : "rel=\"$rel\""; ?>><?php echo $button_text; ?></a>
94
+ <?php
95
+ }
96
+ ?>
97
+ <?php if ($this->options->button_action() == 2) { ?>
98
+ <a class="wpfront-button" onclick="javascript:wpfront_notification_bar_button_action_script();"><?php echo $button_text; ?></a>
99
+ <?php } ?>
100
  <?php } ?>
101
  </div>
102
  </td>
104
  </table>
105
  </div>
106
  </div>
107
+ </div>
108
 
109
 
 
 
 
templates/options-template.php CHANGED
@@ -63,18 +63,17 @@
63
  </th>
64
  <td>
65
  <input type="checkbox" name="<?php echo $this->options->preview_mode_name(); ?>" <?php echo $this->options->preview_mode() ? 'checked' : ''; ?> />
66
- <?php
67
- if($this->options->preview_mode()) {
68
  $url = add_query_arg('wpfront-notification-bar-preview-mode', '1', home_url());
69
  ?>
70
  <span class="description"><a target="_blank" rel="noopener" href="<?php echo $url; ?>"><?php echo $url; ?></a></span>
71
- <?php
72
- }
73
- else {
74
  ?>
75
  <span class="description"><?php echo __('[You can test the notification bar without enabling it.]', 'wpfront-notification-bar'); ?></span>
76
- <?php
77
- }
78
  ?>
79
  </td>
80
  </tr>
@@ -189,6 +188,17 @@
189
  <input type="checkbox" name="<?php echo $this->options->display_open_button_name(); ?>" <?php echo $this->options->display_open_button() ? 'checked' : ''; ?> />&#160;<span class="description">[<?php echo __('A reopen button will be displayed after the bar is closed.', 'wpfront-notification-bar'); ?>]</span>
190
  </td>
191
  </tr>
 
 
 
 
 
 
 
 
 
 
 
192
  <tr>
193
  <th scope="row">
194
  <?php echo $this->options->keep_closed_label(); ?>
@@ -250,6 +260,15 @@
250
  <span class="description"><?php echo __('[Notification bar will be hidden on browser window with lesser or equal width.]', 'wpfront-notification-bar'); ?></span>
251
  </td>
252
  </tr>
 
 
 
 
 
 
 
 
 
253
  </table>
254
 
255
  <h3><?php echo __('Content', 'wpfront-notification-bar'); ?></h3>
@@ -577,6 +596,15 @@
577
 
578
  <h3><?php echo __('CSS', 'wpfront-notification-bar'); ?></h3>
579
  <table class="form-table">
 
 
 
 
 
 
 
 
 
580
  <tr>
581
  <th scope="row">
582
  <?php echo $this->options->custom_css_label(); ?>
@@ -586,7 +614,16 @@
586
  </td>
587
  </tr>
588
  </table>
 
589
  <?php submit_button(); ?>
590
  </form>
591
  </div>
592
- </div>
 
 
 
 
 
 
 
 
63
  </th>
64
  <td>
65
  <input type="checkbox" name="<?php echo $this->options->preview_mode_name(); ?>" <?php echo $this->options->preview_mode() ? 'checked' : ''; ?> />
66
+ <?php
67
+ if ($this->options->preview_mode()) {
68
  $url = add_query_arg('wpfront-notification-bar-preview-mode', '1', home_url());
69
  ?>
70
  <span class="description"><a target="_blank" rel="noopener" href="<?php echo $url; ?>"><?php echo $url; ?></a></span>
71
+ <?php
72
+ } else {
 
73
  ?>
74
  <span class="description"><?php echo __('[You can test the notification bar without enabling it.]', 'wpfront-notification-bar'); ?></span>
75
+ <?php
76
+ }
77
  ?>
78
  </td>
79
  </tr>
188
  <input type="checkbox" name="<?php echo $this->options->display_open_button_name(); ?>" <?php echo $this->options->display_open_button() ? 'checked' : ''; ?> />&#160;<span class="description">[<?php echo __('A reopen button will be displayed after the bar is closed.', 'wpfront-notification-bar'); ?>]</span>
189
  </td>
190
  </tr>
191
+ <tr>
192
+ <th scope="row">
193
+ <?php echo $this->options->reopen_button_image_url_label(); ?>
194
+ </th>
195
+ <td>
196
+ <input id="reopen-button-image-url" class="url" name="<?php echo $this->options->reopen_button_image_url_name(); ?>" value="<?php echo $this->options->reopen_button_image_url(); ?>"/>
197
+ <input type="button" id="media-library-button" class="button" value="<?php echo __('Media Library', 'wpfront-notification-bar'); ?>" />
198
+ <br />
199
+ <span class="description"><?php echo esc_html(__('[Set empty value to use default images.]')); ?></span>
200
+ </td>
201
+ </tr>
202
  <tr>
203
  <th scope="row">
204
  <?php echo $this->options->keep_closed_label(); ?>
260
  <span class="description"><?php echo __('[Notification bar will be hidden on browser window with lesser or equal width.]', 'wpfront-notification-bar'); ?></span>
261
  </td>
262
  </tr>
263
+ <tr>
264
+ <th scope="row">
265
+ <?php echo $this->options->attach_on_shutdown_label(); ?>
266
+ </th>
267
+ <td>
268
+ <input type="checkbox" name="<?php echo $this->options->attach_on_shutdown_name(); ?>" <?php echo $this->options->attach_on_shutdown() ? 'checked' : ''; ?> />
269
+ <span class="description"><?php echo __('[Enable as a last resort if the notification bar is not working. This could create compatibility issues.]', 'wpfront-notification-bar'); ?></span>
270
+ </td>
271
+ </tr>
272
  </table>
273
 
274
  <h3><?php echo __('Content', 'wpfront-notification-bar'); ?></h3>
596
 
597
  <h3><?php echo __('CSS', 'wpfront-notification-bar'); ?></h3>
598
  <table class="form-table">
599
+ <tr>
600
+ <th scope="row">
601
+ <?php echo $this->options->dynamic_css_use_url_label(); ?>
602
+ </th>
603
+ <td>
604
+ <input type="checkbox" name="<?php echo $this->options->dynamic_css_use_url_name(); ?>" <?php echo $this->options->dynamic_css_use_url() ? 'checked' : ''; ?> />
605
+ <span class="description"><?php echo __('[Custom and dynamic CSS will be added through a URL instead of writing to the document. Enabling this setting is recommened if there are no conflicts, so that caching can be leveraged.]', 'wpfront-notification-bar'); ?></span>
606
+ </td>
607
+ </tr>
608
  <tr>
609
  <th scope="row">
610
  <?php echo $this->options->custom_css_label(); ?>
614
  </td>
615
  </tr>
616
  </table>
617
+ <input type="hidden" name="<?php echo $this->options->last_saved_name(); ?>" value="<?php echo time(); ?>" />
618
  <?php submit_button(); ?>
619
  </form>
620
  </div>
621
+ </div>
622
+ <script type="text/javascript">
623
+ (function () {
624
+ init_wpfront_notifiction_bar_options({
625
+ choose_image: '<?php echo __('Choose Image', 'wpfront-notification-bar'); ?>',
626
+ select_image: '<?php echo __('Select Image', 'wpfront-notification-bar'); ?>'
627
+ });
628
+ })();
629
+ </script>
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: 1.8.1
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: 1.9.0.03231
7
  * Requires at least: 5.0
8
  * Requires PHP: 7.0
9
  * Author: Syam Mohan