Simple Banner - Version 2.5.0

Version Description

  • Added Font Size option, changed layout for better preview banner visibility.
Download this release

Release Info

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

Code changes from version 2.4.7 to 2.5.0

Files changed (3) hide show
  1. readme.txt +8 -2
  2. simple-banner.css +0 -1
  3. simple-banner.php +101 -61
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.4.1
7
- Stable tag: 2.4.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -96,6 +96,9 @@ This feature is being actively developed, in the meantime you can use this custo
96
 
97
  == Changelog ==
98
 
 
 
 
99
  = 2.4.7 =
100
  * Fix bug to permissions removal.
101
 
@@ -209,6 +212,9 @@ This feature is being actively developed, in the meantime you can use this custo
209
 
210
  == Upgrade Notice ==
211
 
 
 
 
212
  = 2.4.7 =
213
  * Fix bug to permissions removal.
214
 
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.4.3
7
+ Stable tag: 2.5.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
96
 
97
  == Changelog ==
98
 
99
+ = 2.5.0 =
100
+ * Added Font Size option, changed layout for better preview banner visibility.
101
+
102
  = 2.4.7 =
103
  * Fix bug to permissions removal.
104
 
212
 
213
  == Upgrade Notice ==
214
 
215
+ = 2.5.0 =
216
+ * Added Font Size option, changed layout for better preview banner visibility.
217
+
218
  = 2.4.7 =
219
  * Fix bug to permissions removal.
220
 
simple-banner.css CHANGED
@@ -7,7 +7,6 @@
7
  }
8
 
9
  .simple-banner .simple-banner-text {
10
- font-size: 1.1em;
11
  font-weight: 700;
12
  padding: 10px;
13
  }
7
  }
8
 
9
  .simple-banner .simple-banner-text {
 
10
  font-weight: 700;
11
  padding: 10px;
12
  }
simple-banner.php CHANGED
@@ -3,16 +3,16 @@
3
  * Plugin Name: Simple Banner
4
  * Plugin URI: https://github.com/rpetersen29/simple-banner
5
  * Description: Display a simple banner at the top of your website.
6
- * Version: 2.4.7
7
  * Author: Ryan Petersen
8
  * Author URI: http://rpetersen29.github.io/
9
  * License: GPL2
10
  *
11
  * @package Simple Banner
12
- * @version 2.4.7
13
  * @author Ryan Petersen <rpetersen.dev@gmail.com>
14
  */
15
- define ('VERSION', '2.4.7');
16
 
17
  register_activation_hook( __FILE__, 'simple_banner_activate' );
18
  function simple_banner_activate() {
@@ -38,6 +38,7 @@ function simple_banner() {
38
  'debug_mode' => get_option('debug_mode'),
39
  'id' => get_the_ID(),
40
  'disabled_pages_array' => explode(",", get_option('disabled_pages_array')),
 
41
  'simple_banner_color' => get_option('simple_banner_color'),
42
  'simple_banner_text_color' => get_option('simple_banner_text_color'),
43
  'simple_banner_link_color' => get_option('simple_banner_link_color'),
@@ -77,6 +78,10 @@ function simple_banner_custom_color()
77
  echo '<style type="text/css" media="screen">.simple-banner{position:' . get_option('simple_banner_position') . ';}</style>';
78
  }
79
 
 
 
 
 
80
  if (get_option('simple_banner_color') != ""){
81
  echo '<style type="text/css" media="screen">.simple-banner{background:' . get_option('simple_banner_color') . ';}</style>';
82
  } else {
@@ -146,14 +151,15 @@ function simple_banner_menu() {
146
  add_action( 'admin_init', 'simple_banner_settings' );
147
  function simple_banner_settings() {
148
  register_setting( 'simple-banner-settings-group', 'hide_simple_banner' );
149
- register_setting( 'simple-banner-settings-group', 'simple_banner_position' );
150
- register_setting( 'simple-banner-settings-group', 'header_margin' );
151
- register_setting( 'simple-banner-settings-group', 'header_padding' );
152
  register_setting( 'simple-banner-settings-group', 'simple_banner_color' );
153
  register_setting( 'simple-banner-settings-group', 'simple_banner_text_color' );
154
  register_setting( 'simple-banner-settings-group', 'simple_banner_link_color' );
155
  register_setting( 'simple-banner-settings-group', 'simple_banner_text' );
156
  register_setting( 'simple-banner-settings-group', 'simple_banner_custom_css' );
 
 
 
157
  register_setting( 'simple-banner-settings-group', 'pro_version_activation_code' );
158
  register_setting( 'simple-banner-settings-group', 'pro_version_enabled' );
159
  register_setting( 'simple-banner-settings-group', 'disabled_pages_array' );
@@ -188,7 +194,7 @@ function simple_banner_settings_page() {
188
 
189
  <!-- Preview Banner -->
190
  <div id="preview_banner" class="simple-banner" style="width: 100%;text-align: center;">
191
- <div id="preview_banner_text" class="simple-banner-text" style="font-size: 1.1em;font-weight: 700;padding: 10px;">
192
  <span>This is what your banner will look like with a <a href="/">link</a>.</span>
193
  </div>
194
  </div>
@@ -216,64 +222,16 @@ function simple_banner_settings_page() {
216
  <!-- -->
217
  </td>
218
  </tr>
219
- <!-- Position -->
220
  <tr valign="top">
221
  <th scope="row">
222
- Simple Banner Position
223
- <br><span style="font-weight:400;">Change the <code>position</code> value of your banner. More information <a target="_blank" href="https://www.w3schools.com/cssref/pr_class_position.asp">here</a></span>
224
  </th>
225
  <td style="vertical-align:top;">
226
- <!-- -->
227
- <input type="radio" id="static" name="simple_banner_position" value="static" <?php echo ((get_option('simple_banner_position') == 'static') ? 'checked' : '' ); ?>>
228
- <label for="static"><strong>static:</strong> <span>Default value. Elements render in order, as they appear in the document flow</span></label><br>
229
- <!-- -->
230
- <input type="radio" id="absolute" name="simple_banner_position" value="absolute" <?php echo ((get_option('simple_banner_position') == 'absolute') ? 'checked' : '' ); ?>>
231
- <label for="absolute"><strong>absolute:</strong> <span>The element is positioned relative to its first positioned (not static) ancestor element</span></label><br>
232
- <!-- -->
233
- <input type="radio" id="fixed" name="simple_banner_position" value="fixed" <?php echo ((get_option('simple_banner_position') == 'fixed') ? 'checked' : '' ); ?>>
234
- <label for="fixed"><strong>fixed:</strong> <span>The element is positioned relative to the browser window</span></label><br>
235
- <!-- -->
236
- <input type="radio" id="relative" name="simple_banner_position" value="relative" <?php echo ((get_option('simple_banner_position') == 'relative') ? 'checked' : '' ); ?>>
237
- <label for="relative"><strong>relative:</strong> <span>The element is positioned relative to its normal position, so "left:20px" adds 20 pixels to the element's LEFT position</span></label><br>
238
- <!-- -->
239
- <input type="radio" id="sticky" name="simple_banner_position" value="sticky" <?php echo ((get_option('simple_banner_position') == 'sticky') ? 'checked' : '' ); ?>>
240
- <label for="sticky"><strong>sticky:</strong> <span>The element is positioned based on the user's scroll position</span></label><br>
241
- <div style="padding-left: 10px;">
242
- A sticky element toggles between relative and fixed, depending on the scroll position.
243
- It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position:fixed).<br>
244
- <strong>Note:</strong> Not supported in IE/Edge 15 or earlier. Supported in Safari from version 6.1 with a -webkit- prefix.</div>
245
- <!-- -->
246
- <input type="radio" id="initial" name="simple_banner_position" value="initial" <?php echo ((get_option('simple_banner_position') == 'initial') ? 'checked' : '' ); ?>>
247
- <label for="initial"><strong>initial:</strong> <span>Sets this property to its default value.</span></label><br>
248
- <!-- -->
249
- <input type="radio" id="inherit" name="simple_banner_position" value="inherit" <?php echo ((get_option('simple_banner_position') == 'inherit') ? 'checked' : '' ); ?>>
250
- <label for="inherit"><strong>inherit:</strong> <span>Inherits this property from its parent element.</span></label><br>
251
- </td>
252
- </tr>
253
- <!-- Header Margin -->
254
- <tr valign="top">
255
- <th scope="row">
256
- Header Top Margin
257
- <br><span style="font-weight:400;">Apply margin to the top of your theme header</span>
258
- <br><span style="font-weight:400;color:red;">Will be disabled if banner is hidden or disabled</span>
259
- </th>
260
- <td style="vertical-align:top;">
261
- <input type="text" id="header_margin" name="header_margin" placeholder="margin-top"
262
- value="<?php echo esc_attr( get_option('header_margin') ); ?>" />
263
- <span>e.g. 40px</span>
264
- </td>
265
- </tr>
266
- <!-- Header Padding -->
267
- <tr valign="top">
268
- <th scope="row">
269
- Header Top Padding
270
- <br><span style="font-weight:400;">Apply padding to the top of your theme header</span>
271
- <br><span style="font-weight:400;color:red;">Will be disabled if banner is hidden or disabled</span>
272
- </th>
273
- <td style="vertical-align:top;">
274
- <input type="text" id="header_padding" name="header_padding" placeholder="padding-top"
275
- value="<?php echo esc_attr( get_option('header_padding') ); ?>" />
276
- <span>e.g. 40px</span>
277
  </td>
278
  </tr>
279
  <!-- Background Color -->
@@ -338,6 +296,66 @@ function simple_banner_settings_page() {
338
  <div>}</div>
339
  </td>
340
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  </table>
342
 
343
  <div style="padding: 10px;
@@ -540,6 +558,7 @@ function simple_banner_settings_page() {
540
 
541
  <!-- Script to apply styles to Preview Banner -->
542
  <script type="text/javascript">
 
543
  var style_background_color = document.createElement('style');
544
  var style_link_color = document.createElement('style');
545
  var style_text_color = document.createElement('style');
@@ -551,6 +570,27 @@ function simple_banner_settings_page() {
551
  document.getElementById('preview_banner_text').innerHTML = e.target.value != "" ? '<span>'+e.target.value+'</span>' : '<span>This is what your banner will look like with a <a href="/">link</a>.</span>';
552
  };
553
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
554
  // Background Color
555
  style_background_color.type = 'text/css';
556
  style_background_color.id = 'preview_banner_background_color'
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.5.0
7
  * Author: Ryan Petersen
8
  * Author URI: http://rpetersen29.github.io/
9
  * License: GPL2
10
  *
11
  * @package Simple Banner
12
+ * @version 2.5.0
13
  * @author Ryan Petersen <rpetersen.dev@gmail.com>
14
  */
15
+ define ('VERSION', '2.5.0');
16
 
17
  register_activation_hook( __FILE__, 'simple_banner_activate' );
18
  function simple_banner_activate() {
38
  'debug_mode' => get_option('debug_mode'),
39
  'id' => get_the_ID(),
40
  'disabled_pages_array' => explode(",", get_option('disabled_pages_array')),
41
+ 'simple_banner_font_size' => get_option('simple_banner_font_size'),
42
  'simple_banner_color' => get_option('simple_banner_color'),
43
  'simple_banner_text_color' => get_option('simple_banner_text_color'),
44
  'simple_banner_link_color' => get_option('simple_banner_link_color'),
78
  echo '<style type="text/css" media="screen">.simple-banner{position:' . get_option('simple_banner_position') . ';}</style>';
79
  }
80
 
81
+ if (get_option('simple_banner_font_size') != ""){
82
+ echo '<style type="text/css" media="screen">.simple-banner .simple-banner-text{font-size:' . get_option('simple_banner_font_size') . ';}</style>';
83
+ }
84
+
85
  if (get_option('simple_banner_color') != ""){
86
  echo '<style type="text/css" media="screen">.simple-banner{background:' . get_option('simple_banner_color') . ';}</style>';
87
  } else {
151
  add_action( 'admin_init', 'simple_banner_settings' );
152
  function simple_banner_settings() {
153
  register_setting( 'simple-banner-settings-group', 'hide_simple_banner' );
154
+ register_setting( 'simple-banner-settings-group', 'simple_banner_font_size' );
 
 
155
  register_setting( 'simple-banner-settings-group', 'simple_banner_color' );
156
  register_setting( 'simple-banner-settings-group', 'simple_banner_text_color' );
157
  register_setting( 'simple-banner-settings-group', 'simple_banner_link_color' );
158
  register_setting( 'simple-banner-settings-group', 'simple_banner_text' );
159
  register_setting( 'simple-banner-settings-group', 'simple_banner_custom_css' );
160
+ register_setting( 'simple-banner-settings-group', 'simple_banner_position' );
161
+ register_setting( 'simple-banner-settings-group', 'header_margin' );
162
+ register_setting( 'simple-banner-settings-group', 'header_padding' );
163
  register_setting( 'simple-banner-settings-group', 'pro_version_activation_code' );
164
  register_setting( 'simple-banner-settings-group', 'pro_version_enabled' );
165
  register_setting( 'simple-banner-settings-group', 'disabled_pages_array' );
194
 
195
  <!-- Preview Banner -->
196
  <div id="preview_banner" class="simple-banner" style="width: 100%;text-align: center;">
197
+ <div id="preview_banner_text" class="simple-banner-text" style="font-weight: 700;padding: 10px;">
198
  <span>This is what your banner will look like with a <a href="/">link</a>.</span>
199
  </div>
200
  </div>
222
  <!-- -->
223
  </td>
224
  </tr>
225
+ <!-- Font Size -->
226
  <tr valign="top">
227
  <th scope="row">
228
+ Simple Banner Font Size
229
+ <br><span style="font-weight:400;">Leaving this blank sets the default to your theme CSS value</span>
230
  </th>
231
  <td style="vertical-align:top;">
232
+ <input type="text" id="simple_banner_font_size" name="simple_banner_font_size" placeholder="font-size"
233
+ value="<?php echo esc_attr( get_option('simple_banner_font_size') ); ?>" />
234
+ <span>e.g. 16px</span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  </td>
236
  </tr>
237
  <!-- Background Color -->
296
  <div>}</div>
297
  </td>
298
  </tr>
299
+ <!-- Position -->
300
+ <tr valign="top">
301
+ <th scope="row">
302
+ Simple Banner Position
303
+ <br><span style="font-weight:400;">Change the <code>position</code> value of your banner. More information <a target="_blank" href="https://www.w3schools.com/cssref/pr_class_position.asp">here</a></span>
304
+ </th>
305
+ <td style="vertical-align:top;">
306
+ <!-- -->
307
+ <input type="radio" id="static" name="simple_banner_position" value="static" <?php echo ((get_option('simple_banner_position') == 'static') ? 'checked' : '' ); ?>>
308
+ <label for="static"><strong>static:</strong> <span>Default value. Elements render in order, as they appear in the document flow</span></label><br>
309
+ <!-- -->
310
+ <input type="radio" id="absolute" name="simple_banner_position" value="absolute" <?php echo ((get_option('simple_banner_position') == 'absolute') ? 'checked' : '' ); ?>>
311
+ <label for="absolute"><strong>absolute:</strong> <span>The element is positioned relative to its first positioned (not static) ancestor element</span></label><br>
312
+ <!-- -->
313
+ <input type="radio" id="fixed" name="simple_banner_position" value="fixed" <?php echo ((get_option('simple_banner_position') == 'fixed') ? 'checked' : '' ); ?>>
314
+ <label for="fixed"><strong>fixed:</strong> <span>The element is positioned relative to the browser window</span></label><br>
315
+ <!-- -->
316
+ <input type="radio" id="relative" name="simple_banner_position" value="relative" <?php echo ((get_option('simple_banner_position') == 'relative') ? 'checked' : '' ); ?>>
317
+ <label for="relative"><strong>relative:</strong> <span>The element is positioned relative to its normal position, so "left:20px" adds 20 pixels to the element's LEFT position</span></label><br>
318
+ <!-- -->
319
+ <input type="radio" id="sticky" name="simple_banner_position" value="sticky" <?php echo ((get_option('simple_banner_position') == 'sticky') ? 'checked' : '' ); ?>>
320
+ <label for="sticky"><strong>sticky:</strong> <span>The element is positioned based on the user's scroll position</span></label><br>
321
+ <div style="padding-left: 10px;">
322
+ A sticky element toggles between relative and fixed, depending on the scroll position.
323
+ It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position:fixed).<br>
324
+ <strong>Note:</strong> Not supported in IE/Edge 15 or earlier. Supported in Safari from version 6.1 with a -webkit- prefix.</div>
325
+ <!-- -->
326
+ <input type="radio" id="initial" name="simple_banner_position" value="initial" <?php echo ((get_option('simple_banner_position') == 'initial') ? 'checked' : '' ); ?>>
327
+ <label for="initial"><strong>initial:</strong> <span>Sets this property to its default value.</span></label><br>
328
+ <!-- -->
329
+ <input type="radio" id="inherit" name="simple_banner_position" value="inherit" <?php echo ((get_option('simple_banner_position') == 'inherit') ? 'checked' : '' ); ?>>
330
+ <label for="inherit"><strong>inherit:</strong> <span>Inherits this property from its parent element.</span></label><br>
331
+ </td>
332
+ </tr>
333
+ <!-- Header Margin -->
334
+ <tr valign="top">
335
+ <th scope="row">
336
+ Header Top Margin
337
+ <br><span style="font-weight:400;">Apply margin to the top of your theme header</span>
338
+ <br><span style="font-weight:400;color:red;">Will be disabled if banner is hidden or disabled</span>
339
+ </th>
340
+ <td style="vertical-align:top;">
341
+ <input type="text" id="header_margin" name="header_margin" placeholder="margin-top"
342
+ value="<?php echo esc_attr( get_option('header_margin') ); ?>" />
343
+ <span>e.g. 40px</span>
344
+ </td>
345
+ </tr>
346
+ <!-- Header Padding -->
347
+ <tr valign="top">
348
+ <th scope="row">
349
+ Header Top Padding
350
+ <br><span style="font-weight:400;">Apply padding to the top of your theme header</span>
351
+ <br><span style="font-weight:400;color:red;">Will be disabled if banner is hidden or disabled</span>
352
+ </th>
353
+ <td style="vertical-align:top;">
354
+ <input type="text" id="header_padding" name="header_padding" placeholder="padding-top"
355
+ value="<?php echo esc_attr( get_option('header_padding') ); ?>" />
356
+ <span>e.g. 40px</span>
357
+ </td>
358
+ </tr>
359
  </table>
360
 
361
  <div style="padding: 10px;
558
 
559
  <!-- Script to apply styles to Preview Banner -->
560
  <script type="text/javascript">
561
+ var style_font_size = document.createElement('style');
562
  var style_background_color = document.createElement('style');
563
  var style_link_color = document.createElement('style');
564
  var style_text_color = document.createElement('style');
570
  document.getElementById('preview_banner_text').innerHTML = e.target.value != "" ? '<span>'+e.target.value+'</span>' : '<span>This is what your banner will look like with a <a href="/">link</a>.</span>';
571
  };
572
 
573
+ // Font Size
574
+ style_font_size.type = 'text/css';
575
+ style_font_size.id = 'preview_banner_font_size'
576
+ style_font_size.appendChild(document.createTextNode('.simple-banner .simple-banner-text{font-size:' + (document.getElementById('simple_banner_font_size').value || '1em') + '}'));
577
+ document.getElementsByTagName('head')[0].appendChild(style_font_size);
578
+
579
+ document.getElementById('simple_banner_font_size').onchange=function(e){
580
+ var child = document.getElementById('preview_banner_font_size');
581
+ if (child){child.innerText = "";child.id='';}
582
+
583
+ var style_dynamic = document.createElement('style');
584
+ style_dynamic.type = 'text/css';
585
+ style_dynamic.id = 'preview_banner_font_size';
586
+ style_dynamic.appendChild(
587
+ document.createTextNode(
588
+ '.simple-banner .simple-banner-text{font-size:' + (document.getElementById('simple_banner_font_size').value || '1em') + '}'
589
+ )
590
+ );
591
+ document.getElementsByTagName('head')[0].appendChild(style_dynamic);
592
+ };
593
+
594
  // Background Color
595
  style_background_color.type = 'text/css';
596
  style_background_color.id = 'preview_banner_background_color'