Version Description
- Add option to use Wordpress action
wp_open_body
for banner insertion.
Download this release
Release Info
Developer | rpetersen29 |
Plugin | Simple Banner |
Version | 2.6.0 |
Comparing to | |
See all releases |
Code changes from version 2.5.0 to 2.6.0
- readme.txt +23 -7
- simple-banner.js +3 -1
- simple-banner.php +37 -5
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.
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -38,12 +38,12 @@ This is how the banner will look in your HTML:
|
|
38 |
|
39 |
`<code>
|
40 |
<div id="simple-banner" class="simple-banner">
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
45 |
</div>
|
46 |
-
</div>
|
47 |
</code>
|
48 |
`
|
49 |
|
@@ -86,6 +86,16 @@ This feature is being actively developed, in the meantime you can use this custo
|
|
86 |
}
|
87 |
}, false);
|
88 |
`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
== Screenshots ==
|
91 |
|
@@ -96,6 +106,9 @@ This feature is being actively developed, in the meantime you can use this custo
|
|
96 |
|
97 |
== Changelog ==
|
98 |
|
|
|
|
|
|
|
99 |
= 2.5.0 =
|
100 |
* Added Font Size option, changed layout for better preview banner visibility.
|
101 |
|
@@ -212,6 +225,9 @@ This feature is being actively developed, in the meantime you can use this custo
|
|
212 |
|
213 |
== Upgrade Notice ==
|
214 |
|
|
|
|
|
|
|
215 |
= 2.5.0 =
|
216 |
* Added Font Size option, changed layout for better preview banner visibility.
|
217 |
|
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.5.1
|
7 |
+
Stable tag: 2.6.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
38 |
|
39 |
`<code>
|
40 |
<div id="simple-banner" class="simple-banner">
|
41 |
+
<div class="simple-banner-text">
|
42 |
+
<span>
|
43 |
+
YOUR SIMPLE BANNER TEXT HERE
|
44 |
+
</span>
|
45 |
+
</div>
|
46 |
</div>
|
|
|
47 |
</code>
|
48 |
`
|
49 |
|
86 |
}
|
87 |
}, false);
|
88 |
`
|
89 |
+
= I have the Divi theme and the banner isn't showing. =
|
90 |
+
|
91 |
+
Set your banner position to <code>relative</code> and try this in 'Website Custom CSS':
|
92 |
+
|
93 |
+
`#main-header:not(.et-fixed-header) {
|
94 |
+
position: relative;
|
95 |
+
}`
|
96 |
+
`#top-header:not(.et-fixed-header) {
|
97 |
+
position: relative;
|
98 |
+
}`
|
99 |
|
100 |
== Screenshots ==
|
101 |
|
106 |
|
107 |
== Changelog ==
|
108 |
|
109 |
+
= 2.6.0 =
|
110 |
+
* Add option to use Wordpress action `wp_open_body` for banner insertion.
|
111 |
+
|
112 |
= 2.5.0 =
|
113 |
* Added Font Size option, changed layout for better preview banner visibility.
|
114 |
|
225 |
|
226 |
== Upgrade Notice ==
|
227 |
|
228 |
+
= 2.6.0 =
|
229 |
+
* Add option to use Wordpress action `wp_open_body` for banner insertion.
|
230 |
+
|
231 |
= 2.5.0 =
|
232 |
* Added Font Size option, changed layout for better preview banner visibility.
|
233 |
|
simple-banner.js
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
jQuery(document).ready(function ($) {
|
2 |
if (scriptParams.simple_banner_text != "") {
|
3 |
if (!scriptParams.pro_version_enabled || (scriptParams.pro_version_enabled && !scriptParams.in_array)) {
|
4 |
-
|
|
|
5 |
.prependTo('body');
|
|
|
6 |
|
7 |
var bodyPaddingLeft = $('body').css('padding-left')
|
8 |
var bodyPaddingRight = $('body').css('padding-right')
|
1 |
jQuery(document).ready(function ($) {
|
2 |
if (scriptParams.simple_banner_text != "") {
|
3 |
if (!scriptParams.pro_version_enabled || (scriptParams.pro_version_enabled && !scriptParams.in_array)) {
|
4 |
+
if (!scriptParams.wp_body_open || !scriptParams.wp_body_open_enabled) {
|
5 |
+
$('<div id="simple-banner" class="simple-banner"><div class="simple-banner-text"><span>' + scriptParams.simple_banner_text + '</span></div></div>')
|
6 |
.prependTo('body');
|
7 |
+
}
|
8 |
|
9 |
var bodyPaddingLeft = $('body').css('padding-left')
|
10 |
var bodyPaddingRight = $('body').css('padding-right')
|
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.
|
7 |
* Author: Ryan Petersen
|
8 |
* Author URI: http://rpetersen29.github.io/
|
9 |
* License: GPL2
|
10 |
*
|
11 |
* @package Simple Banner
|
12 |
-
* @version 2.
|
13 |
* @author Ryan Petersen <rpetersen.dev@gmail.com>
|
14 |
*/
|
15 |
-
define ('VERSION', '2.
|
16 |
|
17 |
register_activation_hook( __FILE__, 'simple_banner_activate' );
|
18 |
function simple_banner_activate() {
|
@@ -47,7 +47,9 @@ function simple_banner() {
|
|
47 |
'site_custom_css' => get_option('site_custom_css'),
|
48 |
'keep_site_custom_css' => get_option('keep_site_custom_css'),
|
49 |
'site_custom_js' => get_option('site_custom_js'),
|
50 |
-
'keep_site_custom_js' => get_option('keep_site_custom_js')
|
|
|
|
|
51 |
);
|
52 |
// Enqueue the script
|
53 |
wp_register_script('simple-banner-script', plugin_dir_url( __FILE__ ) . 'simple-banner.js', array( 'jquery' ), VERSION);
|
@@ -55,7 +57,15 @@ function simple_banner() {
|
|
55 |
wp_enqueue_script('simple-banner-script');
|
56 |
}
|
57 |
|
58 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
add_action( 'wp_head', 'simple_banner_custom_color');
|
60 |
function simple_banner_custom_color()
|
61 |
{
|
@@ -169,6 +179,7 @@ function simple_banner_settings() {
|
|
169 |
register_setting( 'simple-banner-settings-group', 'site_custom_js' );
|
170 |
register_setting( 'simple-banner-settings-group', 'keep_site_custom_js' );
|
171 |
register_setting( 'simple-banner-settings-group', 'debug_mode' );
|
|
|
172 |
}
|
173 |
|
174 |
function simple_banner_settings_page() {
|
@@ -205,6 +216,7 @@ function simple_banner_settings_page() {
|
|
205 |
<form method="post" action="options.php">
|
206 |
<?php settings_fields( 'simple-banner-settings-group' ); ?>
|
207 |
<?php do_settings_sections( 'simple-banner-settings-group' ); ?>
|
|
|
208 |
<table class="form-table">
|
209 |
<!-- Hide -->
|
210 |
<tr valign="top">
|
@@ -356,6 +368,26 @@ function simple_banner_settings_page() {
|
|
356 |
<span>e.g. 40px</span>
|
357 |
</td>
|
358 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
</table>
|
360 |
|
361 |
<div style="padding: 10px;
|
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.6.0
|
7 |
* Author: Ryan Petersen
|
8 |
* Author URI: http://rpetersen29.github.io/
|
9 |
* License: GPL2
|
10 |
*
|
11 |
* @package Simple Banner
|
12 |
+
* @version 2.6.0
|
13 |
* @author Ryan Petersen <rpetersen.dev@gmail.com>
|
14 |
*/
|
15 |
+
define ('VERSION', '2.6.0');
|
16 |
|
17 |
register_activation_hook( __FILE__, 'simple_banner_activate' );
|
18 |
function simple_banner_activate() {
|
47 |
'site_custom_css' => get_option('site_custom_css'),
|
48 |
'keep_site_custom_css' => get_option('keep_site_custom_css'),
|
49 |
'site_custom_js' => get_option('site_custom_js'),
|
50 |
+
'keep_site_custom_js' => get_option('keep_site_custom_js'),
|
51 |
+
'wp_body_open_enabled' => get_option('wp_body_open_enabled'),
|
52 |
+
'wp_body_open' => function_exists( 'wp_body_open' )
|
53 |
);
|
54 |
// Enqueue the script
|
55 |
wp_register_script('simple-banner-script', plugin_dir_url( __FILE__ ) . 'simple-banner.js', array( 'jquery' ), VERSION);
|
57 |
wp_enqueue_script('simple-banner-script');
|
58 |
}
|
59 |
|
60 |
+
// Use `wp_body_open` action
|
61 |
+
if ( function_exists( 'wp_body_open' ) && get_option('wp_body_open_enabled') ) {
|
62 |
+
add_action( 'wp_body_open', 'simple_banner_body_open' );
|
63 |
+
}
|
64 |
+
function simple_banner_body_open() {
|
65 |
+
echo '<div id="simple-banner" class="simple-banner"><div class="simple-banner-text"><span>' . get_option('simple_banner_text') . '</span></div></div>';
|
66 |
+
}
|
67 |
+
|
68 |
+
// Add custom CSS/JS
|
69 |
add_action( 'wp_head', 'simple_banner_custom_color');
|
70 |
function simple_banner_custom_color()
|
71 |
{
|
179 |
register_setting( 'simple-banner-settings-group', 'site_custom_js' );
|
180 |
register_setting( 'simple-banner-settings-group', 'keep_site_custom_js' );
|
181 |
register_setting( 'simple-banner-settings-group', 'debug_mode' );
|
182 |
+
register_setting( 'simple-banner-settings-group', 'wp_body_open_enabled' );
|
183 |
}
|
184 |
|
185 |
function simple_banner_settings_page() {
|
216 |
<form method="post" action="options.php">
|
217 |
<?php settings_fields( 'simple-banner-settings-group' ); ?>
|
218 |
<?php do_settings_sections( 'simple-banner-settings-group' ); ?>
|
219 |
+
|
220 |
<table class="form-table">
|
221 |
<!-- Hide -->
|
222 |
<tr valign="top">
|
368 |
<span>e.g. 40px</span>
|
369 |
</td>
|
370 |
</tr>
|
371 |
+
<!-- wp_body_open -->
|
372 |
+
<?php if ( function_exists( 'wp_body_open' ) ): ?>
|
373 |
+
<tr valign="top">
|
374 |
+
<th scope="row">
|
375 |
+
wp_body_open enabled
|
376 |
+
<br>
|
377 |
+
<span style="font-weight:400;">
|
378 |
+
If enabled, will use the <a href="https://developer.wordpress.org/reference/functions/wp_body_open/">wp_body_open</a> action
|
379 |
+
to insert the banner to your site. This will allow the banner to be translated into other languages if you are using another
|
380 |
+
translation plugin.
|
381 |
+
</span>
|
382 |
+
</th>
|
383 |
+
<td>
|
384 |
+
<?php
|
385 |
+
$checked = get_option('wp_body_open_enabled') ? 'checked ' : '';
|
386 |
+
echo '<input type="checkbox" id="wp_body_open_enabled" '. $checked . ' name="wp_body_open_enabled" />';
|
387 |
+
?>
|
388 |
+
</td>
|
389 |
+
</tr>
|
390 |
+
<?php endif; ?>
|
391 |
</table>
|
392 |
|
393 |
<div style="padding: 10px;
|