Simple Banner - Version 2.1.0

Version Description

  • Removed jQuery dependency from project.
Download this release

Release Info

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

Code changes from version 2.0.7 to 2.1.0

Files changed (3) hide show
  1. readme.txt +8 -2
  2. simple-banner.js +20 -10
  3. simple-banner.php +21 -21
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: rpetersen29
3
  Donate link: https://www.paypal.me/rpetersenDev
4
  Tags: banner, banners, simple, announcement, announcements, cta, notification, bar, bars, free, hello bar, hellobar, pro
5
  Requires at least: 3.0.1
6
- Tested up to: 5.0.2
7
- Stable tag: 2.0.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -45,6 +45,9 @@ Yes.
45
 
46
  == Changelog ==
47
 
 
 
 
48
  = 2.0.7 =
49
  * Fixed settings page bugs, tested to Wordpress v5.0.2.
50
 
@@ -107,6 +110,9 @@ Yes.
107
 
108
  == Upgrade Notice ==
109
 
 
 
 
110
  = 2.0.7 =
111
  Bug fixes for settings page.
112
 
3
  Donate link: https://www.paypal.me/rpetersenDev
4
  Tags: banner, banners, simple, announcement, announcements, cta, notification, bar, bars, free, hello bar, hellobar, pro
5
  Requires at least: 3.0.1
6
+ Tested up to: 5.1.0
7
+ Stable tag: 2.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
45
 
46
  == Changelog ==
47
 
48
+ = 2.1.0 =
49
+ * Removed jQuery dependency from project.
50
+
51
  = 2.0.7 =
52
  * Fixed settings page bugs, tested to Wordpress v5.0.2.
53
 
110
 
111
  == Upgrade Notice ==
112
 
113
+ = 2.1.0 =
114
+ Removed jQuery dependency from project.
115
+
116
  = 2.0.7 =
117
  Bug fixes for settings page.
118
 
simple-banner.js CHANGED
@@ -1,14 +1,24 @@
1
- jQuery(document).ready(function($){
2
- $('<div id="simple-banner" class="simple-banner"></div>')
3
- .prependTo('body');
 
 
4
 
5
- var bodyPaddingLeft = $('body').css('padding-left')
6
- var bodyPaddingRight = $('body').css('padding-right')
 
 
 
7
 
8
- if (bodyPaddingLeft != "0px"){
9
- $('head').append('<style type="text/css" media="screen">.simple-banner{margin-left:-'+bodyPaddingLeft+';padding-left:'+bodyPaddingLeft+';}</style>');
10
- }
11
- if (bodyPaddingRight != "0px"){
12
- $('head').append('<style type="text/css" media="screen">.simple-banner{margin-right:-'+bodyPaddingRight+';padding-right:'+bodyPaddingRight+';}</style>');
 
 
 
 
 
13
  }
14
  });
1
+ document.addEventListener('DOMContentLoaded', function () {
2
+ var banner = document.createElement('div');
3
+ banner.id = 'simple-banner';
4
+ banner.className = 'simple-banner';
5
+ document.getElementsByTagName('body')[0].prepend(banner);
6
 
7
+ var bodyPaddingLeft = document.getElementsByTagName('body')[0].style.paddingLeft;
8
+ var bodyPaddingRight = document.getElementsByTagName('body')[0].style.paddingRight;
9
+ var noPaddingArray = ['0px', ''];
10
+ var isBodyPaddingLeft = !noPaddingArray.includes(bodyPaddingLeft);
11
+ var isBodyPaddingRight = !noPaddingArray.includes(bodyPaddingRight);
12
 
13
+ if (isBodyPaddingLeft || isBodyPaddingRight) {
14
+ var head = document.getElementsByTagName('head')[0];
15
+ var leftAdjust = isBodyPaddingLeft ? 'margin-left:-' + bodyPaddingLeft + ';padding-left:' + bodyPaddingLeft + ';' : '';
16
+ var rightAdjust = isBodyPaddingLeft ? 'margin-right:-' + bodyPaddingRight + ';padding-right:' + bodyPaddingRight + ';' : '';
17
+ var css = '.simple-banner{' + leftAdjust + rightAdjust + '}';
18
+ var style = document.createElement('style');
19
+ style.type = 'text/css';
20
+ style.media = 'screen';
21
+ style.innerText = css;
22
+ document.getElementsByTagName('head')[0].prepend(style);
23
  }
24
  });
simple-banner.php CHANGED
@@ -3,13 +3,13 @@
3
  * Plugin Name: Simple Banner
4
  * Plugin URI: https://github.com/rpetersen29/simple-banner
5
  * Description: Display a simple banner at the top of your website.
6
- * Version: 2.0.7
7
  * Author: Ryan Petersen
8
  * Author URI: http://rpetersen29.github.io/
9
  * License: GPL2
10
  *
11
  * @package Simple Banner
12
- * @version 2.0.7
13
  * @author Ryan Petersen <rpetersen.dev@gmail.com>
14
  */
15
 
@@ -19,7 +19,7 @@ function simple_banner() {
19
  wp_register_style('simple-banner-style', plugin_dir_url( __FILE__ ) .'simple-banner.css');
20
  wp_enqueue_style('simple-banner-style');
21
  // Enqueue the script
22
- wp_register_script('simple-banner-script', plugin_dir_url( __FILE__ ) . 'simple-banner.js', array( 'jquery' ));
23
  wp_enqueue_script('simple-banner-script');
24
 
25
  if (get_option('pro_version_enabled')) {
@@ -30,7 +30,7 @@ function simple_banner() {
30
 
31
  //add custom CSS colors
32
  add_action( 'wp_head', 'simple_banner_custom_color');
33
- function simple_banner_custom_color()
34
  {
35
  if (get_option('simple_banner_color') != ""){
36
  echo '<style type="text/css" media="screen">.simple-banner{background:' . get_option('simple_banner_color') . "};</style>";
@@ -63,7 +63,7 @@ function simple_banner_custom_text()
63
  {
64
  if (get_option('simple_banner_text') != ""){
65
  if (!get_option('pro_version_enabled') || (get_option('pro_version_enabled') && !in_array(get_the_ID(), explode(",", get_option('disabled_pages_array'))))){
66
- echo '<script type="text/javascript">jQuery(document).ready(function() {
67
  var bannerSpan = document.getElementById("simple-banner");
68
  bannerSpan.innerHTML = "<div class=' . "simple-banner-text" . '><span>' . addslashes( get_option('simple_banner_text') ) . '</span></div>"
69
  });
@@ -93,7 +93,7 @@ function simple_banner_settings() {
93
 
94
  function simple_banner_settings_page() {
95
  ?>
96
- <?php
97
  if (esc_attr( get_option('pro_version_activation_code') ) == "SBPROv1-14315") {
98
  update_option('pro_version_enabled', true);
99
  } else {
@@ -106,10 +106,10 @@ function simple_banner_settings_page() {
106
  <h2>Simple Banner Settings</h2>
107
  <a class="button button-primary button-hero" style="font-weight: 700;" href="https://www.paypal.me/rpetersenDev" target="_blank">DONATE</a>
108
  </div>
109
-
110
-
111
  <p>Use Hex color values for the color fields.</p>
112
- <p>Links in the banner text must be typed in with HTML <code>&lt;a&gt;</code> tags.
113
  <br />e.g. <code>This is a &lt;a href=&#34;http:&#47;&#47;www.wordpress.com&#34;&gt;Link to Wordpress&lt;&#47;a&gt;</code>.</p>
114
 
115
  <!-- Preview Banner -->
@@ -130,9 +130,9 @@ function simple_banner_settings_page() {
130
  <tr valign="top">
131
  <th scope="row">Simple Banner Background Color<br><span style="font-weight:400;">(Leaving this blank sets the color to the default value #024985)</span></th>
132
  <td style="vertical-align:top;">
133
- <input type="text" id="simple_banner_color" name="simple_banner_color" placeholder="Hex value"
134
  value="<?php echo esc_attr( get_option('simple_banner_color') ); ?>" />
135
- <input style="height: 30px;width: 100px;" type="color" id="simple_banner_color_show"
136
  value="<?php echo ((get_option('simple_banner_color') == '') ? '#024985' : esc_attr( get_option('simple_banner_color') )); ?>">
137
  </td>
138
  </tr>
@@ -140,9 +140,9 @@ function simple_banner_settings_page() {
140
  <tr valign="top">
141
  <th scope="row">Simple Banner Text Color<br><span style="font-weight:400;">(Leaving this blank sets the color to the default value white)</span></th>
142
  <td style="vertical-align:top;">
143
- <input type="text" id="simple_banner_text_color" name="simple_banner_text_color" placeholder="Hex value"
144
  value="<?php echo esc_attr( get_option('simple_banner_text_color') ); ?>" />
145
- <input style="height: 30px;width: 100px;" type="color" id="simple_banner_text_color_show"
146
  value="<?php echo ((get_option('simple_banner_text_color') == '') ? '#ffffff' : esc_attr( get_option('simple_banner_text_color') )); ?>">
147
  </td>
148
  </tr>
@@ -150,9 +150,9 @@ function simple_banner_settings_page() {
150
  <tr valign="top">
151
  <th scope="row">Simple Banner Link Color<br><span style="font-weight:400;">(Leaving this blank sets the color to the default value #f16521)</span></th>
152
  <td style="vertical-align:top;">
153
- <input type="text" id="simple_banner_link_color" name="simple_banner_link_color" placeholder="Hex value"
154
  value="<?php echo esc_attr( get_option('simple_banner_link_color') ); ?>" />
155
- <input style="height: 30px;width: 100px;" type="color" id="simple_banner_link_color_show"
156
  value="<?php echo ((get_option('simple_banner_link_color') == '') ? '#f16521' : esc_attr( get_option('simple_banner_link_color') )); ?>">
157
  </td>
158
  </tr>
@@ -183,8 +183,8 @@ function simple_banner_settings_page() {
183
 
184
  <!-- Pro Features -->
185
  <div style="padding: 0 10px;border: 1px solid #24282e;border-radius: 10px;background-color: #fafafa;">
186
- <h2>Pro Features
187
- <?php
188
  if (!get_option('pro_version_enabled')) {
189
  echo '<a class="button-primary" href="https://plasso.com/s/vZGWHecoeB-simple-banner" target="_blank">Purchase Pro Version</a>';
190
  }
@@ -209,7 +209,7 @@ function simple_banner_settings_page() {
209
  </th>
210
  <td>
211
  <div id="simple_banner_pro_disabled_pages">
212
- <?php
213
  $pages = get_pages();
214
  $disabled = !get_option('pro_version_enabled');
215
  $disabled_pages_array = get_option('disabled_pages_array');
@@ -231,7 +231,7 @@ function simple_banner_settings_page() {
231
  }
232
  ?>
233
  </div>
234
- <?php
235
  if (get_option('pro_version_enabled')) {
236
  echo '<input type="text" hidden id="disabled_pages_array" name="disabled_pages_array" value="'. get_option('disabled_pages_array') . '" />';
237
  }
@@ -245,7 +245,7 @@ function simple_banner_settings_page() {
245
  <br><span style="font-weight:400;">CSS will be applied to the entire website</span>
246
  </th>
247
  <td>
248
- <?php
249
  if (get_option('pro_version_enabled')) {
250
  echo '<textarea id="site_custom_css" style="height: 150px;width: 75%;" name="site_custom_css">'. get_option('site_custom_css') . '</textarea>';
251
  } else {
@@ -261,7 +261,7 @@ function simple_banner_settings_page() {
261
  <br><span style="font-weight:400;">JavaScript will be applied to the entire website</span>
262
  </th>
263
  <td>
264
- <?php
265
  if (get_option('pro_version_enabled')) {
266
  echo '<textarea id="site_custom_js" style="height: 150px;width: 75%;" name="site_custom_js">'. get_option('site_custom_js') . '</textarea>';
267
  } else {
3
  * Plugin Name: Simple Banner
4
  * Plugin URI: https://github.com/rpetersen29/simple-banner
5
  * Description: Display a simple banner at the top of your website.
6
+ * Version: 2.1.0
7
  * Author: Ryan Petersen
8
  * Author URI: http://rpetersen29.github.io/
9
  * License: GPL2
10
  *
11
  * @package Simple Banner
12
+ * @version 2.1.0
13
  * @author Ryan Petersen <rpetersen.dev@gmail.com>
14
  */
15
 
19
  wp_register_style('simple-banner-style', plugin_dir_url( __FILE__ ) .'simple-banner.css');
20
  wp_enqueue_style('simple-banner-style');
21
  // Enqueue the script
22
+ wp_register_script('simple-banner-script', plugin_dir_url( __FILE__ ) . 'simple-banner.js', array());
23
  wp_enqueue_script('simple-banner-script');
24
 
25
  if (get_option('pro_version_enabled')) {
30
 
31
  //add custom CSS colors
32
  add_action( 'wp_head', 'simple_banner_custom_color');
33
+ function simple_banner_custom_color()
34
  {
35
  if (get_option('simple_banner_color') != ""){
36
  echo '<style type="text/css" media="screen">.simple-banner{background:' . get_option('simple_banner_color') . "};</style>";
63
  {
64
  if (get_option('simple_banner_text') != ""){
65
  if (!get_option('pro_version_enabled') || (get_option('pro_version_enabled') && !in_array(get_the_ID(), explode(",", get_option('disabled_pages_array'))))){
66
+ echo '<script type="text/javascript">document.addEventListener("DOMContentLoaded", function() {
67
  var bannerSpan = document.getElementById("simple-banner");
68
  bannerSpan.innerHTML = "<div class=' . "simple-banner-text" . '><span>' . addslashes( get_option('simple_banner_text') ) . '</span></div>"
69
  });
93
 
94
  function simple_banner_settings_page() {
95
  ?>
96
+ <?php
97
  if (esc_attr( get_option('pro_version_activation_code') ) == "SBPROv1-14315") {
98
  update_option('pro_version_enabled', true);
99
  } else {
106
  <h2>Simple Banner Settings</h2>
107
  <a class="button button-primary button-hero" style="font-weight: 700;" href="https://www.paypal.me/rpetersenDev" target="_blank">DONATE</a>
108
  </div>
109
+
110
+
111
  <p>Use Hex color values for the color fields.</p>
112
+ <p>Links in the banner text must be typed in with HTML <code>&lt;a&gt;</code> tags.
113
  <br />e.g. <code>This is a &lt;a href=&#34;http:&#47;&#47;www.wordpress.com&#34;&gt;Link to Wordpress&lt;&#47;a&gt;</code>.</p>
114
 
115
  <!-- Preview Banner -->
130
  <tr valign="top">
131
  <th scope="row">Simple Banner Background Color<br><span style="font-weight:400;">(Leaving this blank sets the color to the default value #024985)</span></th>
132
  <td style="vertical-align:top;">
133
+ <input type="text" id="simple_banner_color" name="simple_banner_color" placeholder="Hex value"
134
  value="<?php echo esc_attr( get_option('simple_banner_color') ); ?>" />
135
+ <input style="height: 30px;width: 100px;" type="color" id="simple_banner_color_show"
136
  value="<?php echo ((get_option('simple_banner_color') == '') ? '#024985' : esc_attr( get_option('simple_banner_color') )); ?>">
137
  </td>
138
  </tr>
140
  <tr valign="top">
141
  <th scope="row">Simple Banner Text Color<br><span style="font-weight:400;">(Leaving this blank sets the color to the default value white)</span></th>
142
  <td style="vertical-align:top;">
143
+ <input type="text" id="simple_banner_text_color" name="simple_banner_text_color" placeholder="Hex value"
144
  value="<?php echo esc_attr( get_option('simple_banner_text_color') ); ?>" />
145
+ <input style="height: 30px;width: 100px;" type="color" id="simple_banner_text_color_show"
146
  value="<?php echo ((get_option('simple_banner_text_color') == '') ? '#ffffff' : esc_attr( get_option('simple_banner_text_color') )); ?>">
147
  </td>
148
  </tr>
150
  <tr valign="top">
151
  <th scope="row">Simple Banner Link Color<br><span style="font-weight:400;">(Leaving this blank sets the color to the default value #f16521)</span></th>
152
  <td style="vertical-align:top;">
153
+ <input type="text" id="simple_banner_link_color" name="simple_banner_link_color" placeholder="Hex value"
154
  value="<?php echo esc_attr( get_option('simple_banner_link_color') ); ?>" />
155
+ <input style="height: 30px;width: 100px;" type="color" id="simple_banner_link_color_show"
156
  value="<?php echo ((get_option('simple_banner_link_color') == '') ? '#f16521' : esc_attr( get_option('simple_banner_link_color') )); ?>">
157
  </td>
158
  </tr>
183
 
184
  <!-- Pro Features -->
185
  <div style="padding: 0 10px;border: 1px solid #24282e;border-radius: 10px;background-color: #fafafa;">
186
+ <h2>Pro Features
187
+ <?php
188
  if (!get_option('pro_version_enabled')) {
189
  echo '<a class="button-primary" href="https://plasso.com/s/vZGWHecoeB-simple-banner" target="_blank">Purchase Pro Version</a>';
190
  }
209
  </th>
210
  <td>
211
  <div id="simple_banner_pro_disabled_pages">
212
+ <?php
213
  $pages = get_pages();
214
  $disabled = !get_option('pro_version_enabled');
215
  $disabled_pages_array = get_option('disabled_pages_array');
231
  }
232
  ?>
233
  </div>
234
+ <?php
235
  if (get_option('pro_version_enabled')) {
236
  echo '<input type="text" hidden id="disabled_pages_array" name="disabled_pages_array" value="'. get_option('disabled_pages_array') . '" />';
237
  }
245
  <br><span style="font-weight:400;">CSS will be applied to the entire website</span>
246
  </th>
247
  <td>
248
+ <?php
249
  if (get_option('pro_version_enabled')) {
250
  echo '<textarea id="site_custom_css" style="height: 150px;width: 75%;" name="site_custom_css">'. get_option('site_custom_css') . '</textarea>';
251
  } else {
261
  <br><span style="font-weight:400;">JavaScript will be applied to the entire website</span>
262
  </th>
263
  <td>
264
+ <?php
265
  if (get_option('pro_version_enabled')) {
266
  echo '<textarea id="site_custom_js" style="height: 150px;width: 75%;" name="site_custom_js">'. get_option('site_custom_js') . '</textarea>';
267
  } else {