Simple Banner - Version 2.4.0

Version Description

  • Added some new fields (hiding, position, and header top margin/padding) to help with banner customization.
Download this release

Release Info

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

Code changes from version 2.3.0 to 2.4.0

Files changed (2) hide show
  1. readme.txt +10 -3
  2. simple-banner.php +93 -9
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.0
7
- Stable tag: 2.3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -47,7 +47,7 @@ This is how the banner will look in your HTML:
47
  </code>
48
  `
49
 
50
- = The banner or changes to the banner aren't showing up, what's wrong? =
51
 
52
  Your browser frequently caches scripts associated with a website in order to improve speed and performance. There are also some
53
  wordpress plugins that cache scripts to improve performance. If you aren't seeing your banner or the changes you made to the banner,
@@ -55,7 +55,8 @@ first clear your browser cache and if that doesn't work, look for any plugin tha
55
 
56
  = Why is my banner covering my header or behind my header? =
57
 
58
- Your theme probably uses absolute positioning for its header in this case. That is fine, but it also means you need a custom solution for your banner.
 
59
  You can either try to find another plugin that suits your needs or you can purchase the pro version and open a support ticket to fix your situation.
60
 
61
  = Is there a Pro version? =
@@ -96,6 +97,9 @@ In the meantime you can use the following custom JavaScript to disable on your h
96
 
97
  == Changelog ==
98
 
 
 
 
99
  = 2.3.0 =
100
  * Added permissions adding and updated documentation.
101
 
@@ -185,6 +189,9 @@ In the meantime you can use the following custom JavaScript to disable on your h
185
 
186
  == Upgrade Notice ==
187
 
 
 
 
188
  = 2.3.0 =
189
  * Added permissions adding and updated documentation.
190
 
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.0
7
+ Stable tag: 2.4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
47
  </code>
48
  `
49
 
50
+ = The banner or changes to the banner aren't showing up, or are only showing up when I'm logged in, what's wrong? =
51
 
52
  Your browser frequently caches scripts associated with a website in order to improve speed and performance. There are also some
53
  wordpress plugins that cache scripts to improve performance. If you aren't seeing your banner or the changes you made to the banner,
55
 
56
  = Why is my banner covering my header or behind my header? =
57
 
58
+ Your theme probably uses absolute positioning for its header in this case. Try changing the positioning of your banner and see if that helps.
59
+ This changes the <code>position</code> CSS attribute of the banner. More information can be found <a target="_blank" href="https://www.w3schools.com/cssref/pr_class_position.asp">here</a>. If none of this works, you may need a custom solution for your banner.
60
  You can either try to find another plugin that suits your needs or you can purchase the pro version and open a support ticket to fix your situation.
61
 
62
  = Is there a Pro version? =
97
 
98
  == Changelog ==
99
 
100
+ = 2.4.0 =
101
+ * Added some new fields (hiding, position, and header top margin/padding) to help with banner customization.
102
+
103
  = 2.3.0 =
104
  * Added permissions adding and updated documentation.
105
 
189
 
190
  == Upgrade Notice ==
191
 
192
+ = 2.4.0 =
193
+ * Added some new fields (hiding, position, and header top margin/padding) to help with banner customization.
194
+
195
  = 2.3.0 =
196
  * Added permissions adding and updated documentation.
197
 
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.3.0
7
  * Author: Ryan Petersen
8
  * Author URI: http://rpetersen29.github.io/
9
  * License: GPL2
10
  *
11
  * @package Simple Banner
12
- * @version 2.3.0
13
  * @author Ryan Petersen <rpetersen.dev@gmail.com>
14
  */
15
- define ('VERSION', '2.3.0');
16
 
17
  add_action( 'wp_enqueue_scripts', 'simple_banner' );
18
  function simple_banner() {
@@ -22,6 +22,10 @@ function simple_banner() {
22
  // Set Script parameters
23
  $script_params = array(
24
  // script specific parameters
 
 
 
 
25
  'simple_banner_text' => get_option('simple_banner_text'),
26
  'pro_version_enabled' => get_option('pro_version_enabled'),
27
  'in_array' => in_array(get_the_ID(), explode(",", get_option('disabled_pages_array'))),
@@ -47,34 +51,50 @@ function simple_banner() {
47
  add_action( 'wp_head', 'simple_banner_custom_color');
48
  function simple_banner_custom_color()
49
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  if (get_option('simple_banner_color') != ""){
51
- echo '<style type="text/css" media="screen">.simple-banner{background:' . get_option('simple_banner_color') . '}</style>';
52
  } else {
53
  echo '<style type="text/css" media="screen">.simple-banner{background: #024985;}</style>';
54
  }
55
 
56
  if (get_option('simple_banner_text_color') != ""){
57
- echo '<style type="text/css" media="screen">.simple-banner .simple-banner-text{color:' . get_option('simple_banner_text_color') . '}</style>';
58
  } else {
59
  echo '<style type="text/css" media="screen">.simple-banner .simple-banner-text{color: #ffffff;}</style>';
60
  }
61
 
62
  if (get_option('simple_banner_link_color') != ""){
63
- echo '<style type="text/css" media="screen">.simple-banner .simple-banner-text a{color:' . get_option('simple_banner_link_color') . "}</style>";
64
  } else {
65
  echo '<style type="text/css" media="screen">.simple-banner .simple-banner-text a{color:#f16521;}</style>';
66
  }
67
 
68
  if (get_option('simple_banner_custom_css') != ""){
69
- echo '<style type="text/css" media="screen">.simple-banner{'. get_option('simple_banner_custom_css') . "}</style>";
70
  }
71
 
72
  if (get_option('site_custom_css') != "" && get_option('pro_version_enabled')) {
73
- echo '<style type="text/css" media="screen">'. get_option('site_custom_css') . "</style>";
74
  }
75
 
76
  if (get_option('site_custom_js') != "" && get_option('pro_version_enabled')) {
77
- echo '<script type="text/javascript">'. get_option('site_custom_js') . "</script>";
78
  }
79
  }
80
 
@@ -105,6 +125,10 @@ function simple_banner_menu() {
105
 
106
  add_action( 'admin_init', 'simple_banner_settings' );
107
  function simple_banner_settings() {
 
 
 
 
108
  register_setting( 'simple-banner-settings-group', 'simple_banner_color' );
109
  register_setting( 'simple-banner-settings-group', 'simple_banner_text_color' );
110
  register_setting( 'simple-banner-settings-group', 'simple_banner_link_color' );
@@ -154,6 +178,66 @@ function simple_banner_settings_page() {
154
  <?php settings_fields( 'simple-banner-settings-group' ); ?>
155
  <?php do_settings_sections( 'simple-banner-settings-group' ); ?>
156
  <table class="form-table">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  <!-- Background Color -->
158
  <tr valign="top">
159
  <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>
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.0
7
  * Author: Ryan Petersen
8
  * Author URI: http://rpetersen29.github.io/
9
  * License: GPL2
10
  *
11
  * @package Simple Banner
12
+ * @version 2.4.0
13
  * @author Ryan Petersen <rpetersen.dev@gmail.com>
14
  */
15
+ define ('VERSION', '2.4.0');
16
 
17
  add_action( 'wp_enqueue_scripts', 'simple_banner' );
18
  function simple_banner() {
22
  // Set Script parameters
23
  $script_params = array(
24
  // script specific parameters
25
+ 'hide_simple_banner' => get_option('hide_simple_banner'),
26
+ 'simple_banner_position' => get_option('simple_banner_position'),
27
+ 'header_margin' => get_option('header_margin'),
28
+ 'header_padding' => get_option('header_padding'),
29
  'simple_banner_text' => get_option('simple_banner_text'),
30
  'pro_version_enabled' => get_option('pro_version_enabled'),
31
  'in_array' => in_array(get_the_ID(), explode(",", get_option('disabled_pages_array'))),
51
  add_action( 'wp_head', 'simple_banner_custom_color');
52
  function simple_banner_custom_color()
53
  {
54
+ if (get_option('hide_simple_banner') == "yes"){
55
+ echo '<style type="text/css" media="screen">.simple-banner{display:none;}</style>';
56
+ }
57
+
58
+ if (get_option('header_margin') != ""){
59
+ echo '<style type="text/css" media="screen">header{margin-top:' . get_option('header_margin') . ';}</style>';
60
+ }
61
+
62
+ if (get_option('header_padding') != ""){
63
+ echo '<style type="text/css" media="screen">header{padding-top:' . get_option('header_padding') . ';}</style>';
64
+ }
65
+
66
+ if (get_option('simple_banner_position') != ""){
67
+ echo '<style type="text/css" media="screen">.simple-banner{position:' . get_option('simple_banner_position') . ';}</style>';
68
+ }
69
+
70
  if (get_option('simple_banner_color') != ""){
71
+ echo '<style type="text/css" media="screen">.simple-banner{background:' . get_option('simple_banner_color') . ';}</style>';
72
  } else {
73
  echo '<style type="text/css" media="screen">.simple-banner{background: #024985;}</style>';
74
  }
75
 
76
  if (get_option('simple_banner_text_color') != ""){
77
+ echo '<style type="text/css" media="screen">.simple-banner .simple-banner-text{color:' . get_option('simple_banner_text_color') . ';}</style>';
78
  } else {
79
  echo '<style type="text/css" media="screen">.simple-banner .simple-banner-text{color: #ffffff;}</style>';
80
  }
81
 
82
  if (get_option('simple_banner_link_color') != ""){
83
+ echo '<style type="text/css" media="screen">.simple-banner .simple-banner-text a{color:' . get_option('simple_banner_link_color') . ';}</style>';
84
  } else {
85
  echo '<style type="text/css" media="screen">.simple-banner .simple-banner-text a{color:#f16521;}</style>';
86
  }
87
 
88
  if (get_option('simple_banner_custom_css') != ""){
89
+ echo '<style type="text/css" media="screen">.simple-banner{'. get_option('simple_banner_custom_css') . '}</style>';
90
  }
91
 
92
  if (get_option('site_custom_css') != "" && get_option('pro_version_enabled')) {
93
+ echo '<style type="text/css" media="screen">'. get_option('site_custom_css') . '</style>';
94
  }
95
 
96
  if (get_option('site_custom_js') != "" && get_option('pro_version_enabled')) {
97
+ echo '<script type="text/javascript">'. get_option('site_custom_js') . '</script>';
98
  }
99
  }
100
 
125
 
126
  add_action( 'admin_init', 'simple_banner_settings' );
127
  function simple_banner_settings() {
128
+ register_setting( 'simple-banner-settings-group', 'hide_simple_banner' );
129
+ register_setting( 'simple-banner-settings-group', 'simple_banner_position' );
130
+ register_setting( 'simple-banner-settings-group', 'header_margin' );
131
+ register_setting( 'simple-banner-settings-group', 'header_padding' );
132
  register_setting( 'simple-banner-settings-group', 'simple_banner_color' );
133
  register_setting( 'simple-banner-settings-group', 'simple_banner_text_color' );
134
  register_setting( 'simple-banner-settings-group', 'simple_banner_link_color' );
178
  <?php settings_fields( 'simple-banner-settings-group' ); ?>
179
  <?php do_settings_sections( 'simple-banner-settings-group' ); ?>
180
  <table class="form-table">
181
+ <!-- Hide -->
182
+ <tr valign="top">
183
+ <th scope="row">Hide Simple Banner<br><span style="font-weight:400;">(This can hide the simple banner, essentially applies <code>display: none;</code> to the banner.)</span></th>
184
+ <td style="vertical-align:top;">
185
+ <!-- -->
186
+ <input type="radio" id="yes" name="hide_simple_banner" value="yes" <?php echo ((get_option('hide_simple_banner') == 'yes') ? checked : '' ); ?>>
187
+ <label for="yes">yes</label>
188
+ <!-- -->
189
+ <input type="radio" id="no" name="hide_simple_banner" value="no" <?php echo ((get_option('hide_simple_banner') == 'yes') ? '' : checked ); ?>>
190
+ <label for="no">no</label>
191
+ <!-- -->
192
+ </td>
193
+ </tr>
194
+ <!-- Position -->
195
+ <tr valign="top">
196
+ <th scope="row">Simple Banner Position<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></th>
197
+ <td style="vertical-align:top;">
198
+ <!-- -->
199
+ <input type="radio" id="static" name="simple_banner_position" value="static" <?php echo ((get_option('simple_banner_position') == 'static') ? checked : '' ); ?>>
200
+ <label for="static"><strong>static:</strong> <span>Default value. Elements render in order, as they appear in the document flow</span></label><br>
201
+ <!-- -->
202
+ <input type="radio" id="absolute" name="simple_banner_position" value="absolute" <?php echo ((get_option('simple_banner_position') == 'absolute') ? checked : '' ); ?>>
203
+ <label for="absolute"><strong>absolute:</strong> <span>The element is positioned relative to its first positioned (not static) ancestor element</span></label><br>
204
+ <!-- -->
205
+ <input type="radio" id="fixed" name="simple_banner_position" value="fixed" <?php echo ((get_option('simple_banner_position') == 'fixed') ? checked : '' ); ?>>
206
+ <label for="fixed"><strong>fixed:</strong> <span>The element is positioned relative to the browser window</span></label><br>
207
+ <!-- -->
208
+ <input type="radio" id="relative" name="simple_banner_position" value="relative" <?php echo ((get_option('simple_banner_position') == 'relative') ? checked : '' ); ?>>
209
+ <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>
210
+ <!-- -->
211
+ <input type="radio" id="sticky" name="simple_banner_position" value="sticky" <?php echo ((get_option('simple_banner_position') == 'sticky') ? checked : '' ); ?>>
212
+ <label for="sticky"><strong>sticky:</strong> <span>The element is positioned based on the user's scroll position</span></label><br>
213
+ <div style="padding-left: 10px;">
214
+ A sticky element toggles between relative and fixed, depending on the scroll position.
215
+ It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position:fixed).<br>
216
+ <strong>Note:</strong> Not supported in IE/Edge 15 or earlier. Supported in Safari from version 6.1 with a -webkit- prefix.</div>
217
+ <!-- -->
218
+ <input type="radio" id="initial" name="simple_banner_position" value="initial" <?php echo ((get_option('simple_banner_position') == 'initial') ? checked : '' ); ?>>
219
+ <label for="initial"><strong>initial:</strong> <span>Sets this property to its default value.</span></label><br>
220
+ <!-- -->
221
+ <input type="radio" id="inherit" name="simple_banner_position" value="inherit" <?php echo ((get_option('simple_banner_position') == 'inherit') ? checked : '' ); ?>>
222
+ <label for="inherit"><strong>inherit:</strong> <span>Inherits this property from its parent element.</span></label><br>
223
+ </td>
224
+ </tr>
225
+ <!-- Header Margin -->
226
+ <tr valign="top">
227
+ <th scope="row">Header Top Margin<br><span style="font-weight:400;">(Apply margin to the top of your theme header, e.g. 40px)</span></th>
228
+ <td style="vertical-align:top;">
229
+ <input type="text" id="header_margin" name="header_margin" placeholder="margin-top"
230
+ value="<?php echo esc_attr( get_option('header_margin') ); ?>" />
231
+ </td>
232
+ </tr>
233
+ <!-- Header Padding -->
234
+ <tr valign="top">
235
+ <th scope="row">Header Top Padding<br><span style="font-weight:400;">(Apply padding to the top of your theme header, e.g. 40px)</span></th>
236
+ <td style="vertical-align:top;">
237
+ <input type="text" id="header_padding" name="header_padding" placeholder="padding-top"
238
+ value="<?php echo esc_attr( get_option('header_padding') ); ?>" />
239
+ </td>
240
+ </tr>
241
  <!-- Background Color -->
242
  <tr valign="top">
243
  <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>