Version Description
- Bug fixes for disabled pages checkboxes, added experimental feature to disable banner on posts.
Download this release
Release Info
Developer | rpetersen29 |
Plugin | Simple Banner |
Version | 2.10.0 |
Comparing to | |
See all releases |
Code changes from version 2.9.4 to 2.10.0
- readme.txt +9 -3
- simple-banner.php +56 -11
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== Simple Banner ===
|
2 |
Contributors: rpetersen29
|
3 |
Donate link: https://www.paypal.me/rpetersenDev
|
4 |
-
Tags: banner,
|
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 |
|
@@ -118,6 +118,9 @@ Set your banner position to <code>relative</code> and try this in 'Website Custo
|
|
118 |
|
119 |
== Changelog ==
|
120 |
|
|
|
|
|
|
|
121 |
= 2.9.4 =
|
122 |
* Bug fixes for disabled pages array.
|
123 |
|
@@ -262,6 +265,9 @@ Set your banner position to <code>relative</code> and try this in 'Website Custo
|
|
262 |
|
263 |
== Upgrade Notice ==
|
264 |
|
|
|
|
|
|
|
265 |
= 2.9.4 =
|
266 |
* Bug fixes for disabled pages array.
|
267 |
|
1 |
=== Simple Banner ===
|
2 |
Contributors: rpetersen29
|
3 |
Donate link: https://www.paypal.me/rpetersenDev
|
4 |
+
Tags: banner, simple, top, bar, announcement, top bar, topbar, bulletin, notification, notice, cta, free
|
5 |
Requires at least: 3.0.1
|
6 |
+
Tested up to: 5.7
|
7 |
+
Stable tag: 2.10.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
118 |
|
119 |
== Changelog ==
|
120 |
|
121 |
+
= 2.10.0 =
|
122 |
+
* Bug fixes for disabled pages checkboxes, added experimental feature to disable banner on posts.
|
123 |
+
|
124 |
= 2.9.4 =
|
125 |
* Bug fixes for disabled pages array.
|
126 |
|
265 |
|
266 |
== Upgrade Notice ==
|
267 |
|
268 |
+
= 2.10.0 =
|
269 |
+
* Bug fixes for disabled pages checkboxes, added experimental feature to disable banner on posts.
|
270 |
+
|
271 |
= 2.9.4 =
|
272 |
* Bug fixes for disabled pages array.
|
273 |
|
simple-banner.php
CHANGED
@@ -3,30 +3,49 @@
|
|
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() {
|
19 |
add_action('admin_menu', 'simple_banner_menu');
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
add_action( 'wp_enqueue_scripts', 'simple_banner' );
|
23 |
function simple_banner() {
|
24 |
// Enqueue the style
|
25 |
wp_register_style('simple-banner-style', plugin_dir_url( __FILE__ ) .'simple-banner.css', '', VERSION);
|
26 |
wp_enqueue_style('simple-banner-style');
|
27 |
// Set Script parameters
|
28 |
-
$
|
29 |
-
$disabled_on_current_page = !empty($disabled_pages_array) && in_array(get_the_ID(), $disabled_pages_array);
|
30 |
$script_params = array(
|
31 |
// script specific parameters
|
32 |
'version' => VERSION,
|
@@ -40,7 +59,10 @@ function simple_banner() {
|
|
40 |
// debug specific parameters
|
41 |
'debug_mode' => get_option('debug_mode'),
|
42 |
'id' => get_the_ID(),
|
43 |
-
'disabled_pages_array' =>
|
|
|
|
|
|
|
44 |
'simple_banner_font_size' => get_option('simple_banner_font_size'),
|
45 |
'simple_banner_color' => get_option('simple_banner_color'),
|
46 |
'simple_banner_text_color' => get_option('simple_banner_text_color'),
|
@@ -73,9 +95,8 @@ if ( function_exists( 'wp_body_open' ) && get_option('wp_body_open_enabled') ) {
|
|
73 |
}
|
74 |
function simple_banner_body_open() {
|
75 |
// if not disabled use wp_body_open
|
76 |
-
$
|
77 |
$close_button_enabled = get_option('close_button_enabled');
|
78 |
-
$disabled_on_current_page = !empty($disabled_pages_array) && in_array(get_the_ID(), $disabled_pages_array);
|
79 |
$closed_cookie = $close_button_enabled && isset($_COOKIE['simplebannerclosed']);
|
80 |
$closed_button = get_option('close_button_enabled') ? '<button id="simple-banner-close-button" class="simple-banner-button">✕</button>' : '';
|
81 |
|
@@ -94,8 +115,7 @@ function simple_banner_custom_color()
|
|
94 |
{
|
95 |
$closed_cookie = get_option('close_button_enabled') && isset($_COOKIE["simplebannerclosed"]);
|
96 |
|
97 |
-
$
|
98 |
-
$disabled_on_current_page = !empty($disabled_pages_array) && in_array(get_the_ID(), $disabled_pages_array);
|
99 |
$banner_is_disabled = $disabled_on_current_page || get_option('hide_simple_banner') == "yes";
|
100 |
|
101 |
if ($banner_is_disabled || $closed_cookie){
|
@@ -228,6 +248,7 @@ function simple_banner_settings() {
|
|
228 |
register_setting( 'simple-banner-settings-group', 'header_padding' );
|
229 |
register_setting( 'simple-banner-settings-group', 'pro_version_activation_code' );
|
230 |
register_setting( 'simple-banner-settings-group', 'pro_version_enabled' );
|
|
|
231 |
register_setting( 'simple-banner-settings-group', 'disabled_pages_array' );
|
232 |
register_setting( 'simple-banner-settings-group', 'permissions_array' );
|
233 |
register_setting( 'simple-banner-settings-group', 'site_custom_css' );
|
@@ -595,6 +616,27 @@ function simple_banner_settings_page() {
|
|
595 |
echo '<input type="text" hidden id="permissions_array" name="permissions_array" value="'. get_option('permissions_array') . '" />';
|
596 |
}
|
597 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
598 |
<!-- Disabled Pages -->
|
599 |
<tr valign="top">
|
600 |
<th scope="row">
|
@@ -604,7 +646,6 @@ function simple_banner_settings_page() {
|
|
604 |
<td>
|
605 |
<div id="simple_banner_pro_disabled_pages">
|
606 |
<?php
|
607 |
-
$pages = get_pages();
|
608 |
$disabled = !get_option('pro_version_enabled');
|
609 |
$disabled_pages_array = array_filter(explode(',', get_option('disabled_pages_array')));
|
610 |
$frontpage_id = get_option( 'page_on_front' ); // page_on_front returns 0 if value hasn't been set
|
@@ -618,6 +659,10 @@ function simple_banner_settings_page() {
|
|
618 |
$parent_checkbox .= get_option( 'blogname' ) . ' | ' . get_site_url() . ' ';
|
619 |
$parent_checkbox .= '</input><br>';
|
620 |
echo $parent_checkbox;
|
|
|
|
|
|
|
|
|
621 |
foreach ( $pages as $page ) {
|
622 |
$checkbox = '<input type="checkbox"';
|
623 |
$checkbox .= $disabled ? 'disabled ' : '';
|
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.10.0
|
7 |
* Author: Ryan Petersen
|
8 |
* Author URI: http://rpetersen29.github.io/
|
9 |
* License: GPL2
|
10 |
*
|
11 |
* @package Simple Banner
|
12 |
+
* @version 2.10.0
|
13 |
* @author Ryan Petersen <rpetersen.dev@gmail.com>
|
14 |
*/
|
15 |
+
define ('VERSION', '2.10.0');
|
16 |
|
17 |
register_activation_hook( __FILE__, 'simple_banner_activate' );
|
18 |
function simple_banner_activate() {
|
19 |
add_action('admin_menu', 'simple_banner_menu');
|
20 |
}
|
21 |
|
22 |
+
// Disabled Pages/Posts functionns
|
23 |
+
function get_disabled_pages_array() {
|
24 |
+
return array_filter(explode(',', get_option('disabled_pages_array')));
|
25 |
+
}
|
26 |
+
function get_post_object() {
|
27 |
+
return get_posts(array('include' => array(get_the_ID())));
|
28 |
+
}
|
29 |
+
function get_is_current_page_a_post() {
|
30 |
+
return !empty(get_post_object());
|
31 |
+
}
|
32 |
+
function get_disabled_on_posts() {
|
33 |
+
return get_option('disabled_on_posts');
|
34 |
+
}
|
35 |
+
function get_disabled_on_current_page() {
|
36 |
+
$disabled_on_current_page = (!empty(get_disabled_pages_array()) && in_array(get_the_ID(), get_disabled_pages_array()))
|
37 |
+
|| (get_disabled_on_posts() && get_is_current_page_a_post());
|
38 |
+
return $disabled_on_current_page;
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
add_action( 'wp_enqueue_scripts', 'simple_banner' );
|
43 |
function simple_banner() {
|
44 |
// Enqueue the style
|
45 |
wp_register_style('simple-banner-style', plugin_dir_url( __FILE__ ) .'simple-banner.css', '', VERSION);
|
46 |
wp_enqueue_style('simple-banner-style');
|
47 |
// Set Script parameters
|
48 |
+
$disabled_on_current_page = get_disabled_on_current_page();
|
|
|
49 |
$script_params = array(
|
50 |
// script specific parameters
|
51 |
'version' => VERSION,
|
59 |
// debug specific parameters
|
60 |
'debug_mode' => get_option('debug_mode'),
|
61 |
'id' => get_the_ID(),
|
62 |
+
'disabled_pages_array' => get_disabled_pages_array(),
|
63 |
+
'post_object' => get_post_object(),
|
64 |
+
'is_current_page_a_post' => get_is_current_page_a_post(),
|
65 |
+
'disabled_on_posts' => get_disabled_on_posts(),
|
66 |
'simple_banner_font_size' => get_option('simple_banner_font_size'),
|
67 |
'simple_banner_color' => get_option('simple_banner_color'),
|
68 |
'simple_banner_text_color' => get_option('simple_banner_text_color'),
|
95 |
}
|
96 |
function simple_banner_body_open() {
|
97 |
// if not disabled use wp_body_open
|
98 |
+
$disabled_on_current_page = get_disabled_on_current_page();
|
99 |
$close_button_enabled = get_option('close_button_enabled');
|
|
|
100 |
$closed_cookie = $close_button_enabled && isset($_COOKIE['simplebannerclosed']);
|
101 |
$closed_button = get_option('close_button_enabled') ? '<button id="simple-banner-close-button" class="simple-banner-button">✕</button>' : '';
|
102 |
|
115 |
{
|
116 |
$closed_cookie = get_option('close_button_enabled') && isset($_COOKIE["simplebannerclosed"]);
|
117 |
|
118 |
+
$disabled_on_current_page = get_disabled_on_current_page();
|
|
|
119 |
$banner_is_disabled = $disabled_on_current_page || get_option('hide_simple_banner') == "yes";
|
120 |
|
121 |
if ($banner_is_disabled || $closed_cookie){
|
248 |
register_setting( 'simple-banner-settings-group', 'header_padding' );
|
249 |
register_setting( 'simple-banner-settings-group', 'pro_version_activation_code' );
|
250 |
register_setting( 'simple-banner-settings-group', 'pro_version_enabled' );
|
251 |
+
register_setting( 'simple-banner-settings-group', 'disabled_on_posts' );
|
252 |
register_setting( 'simple-banner-settings-group', 'disabled_pages_array' );
|
253 |
register_setting( 'simple-banner-settings-group', 'permissions_array' );
|
254 |
register_setting( 'simple-banner-settings-group', 'site_custom_css' );
|
616 |
echo '<input type="text" hidden id="permissions_array" name="permissions_array" value="'. get_option('permissions_array') . '" />';
|
617 |
}
|
618 |
?>
|
619 |
+
<!-- Disabled on Psts -->
|
620 |
+
<tr valign="top">
|
621 |
+
<th scope="row">
|
622 |
+
Disabled on Posts
|
623 |
+
<br>
|
624 |
+
<span style="font-weight:400;">
|
625 |
+
<span style="color:red;">*EXPERIMENTAL FEATURE*</span><br>
|
626 |
+
Disable Simple Banner on all posts.
|
627 |
+
</span>
|
628 |
+
</th>
|
629 |
+
<td style="padding-top:0;">
|
630 |
+
<?php
|
631 |
+
if (get_option('pro_version_enabled')) {
|
632 |
+
$checked = get_option('disabled_on_posts') ? 'checked ' : '';
|
633 |
+
echo '<input type="checkbox" id="disabled_on_posts" '. $checked . ' name="disabled_on_posts" />';
|
634 |
+
} else {
|
635 |
+
echo '<input type="checkbox" disabled />';
|
636 |
+
}
|
637 |
+
?>
|
638 |
+
</td>
|
639 |
+
</tr>
|
640 |
<!-- Disabled Pages -->
|
641 |
<tr valign="top">
|
642 |
<th scope="row">
|
646 |
<td>
|
647 |
<div id="simple_banner_pro_disabled_pages">
|
648 |
<?php
|
|
|
649 |
$disabled = !get_option('pro_version_enabled');
|
650 |
$disabled_pages_array = array_filter(explode(',', get_option('disabled_pages_array')));
|
651 |
$frontpage_id = get_option( 'page_on_front' ); // page_on_front returns 0 if value hasn't been set
|
659 |
$parent_checkbox .= get_option( 'blogname' ) . ' | ' . get_site_url() . ' ';
|
660 |
$parent_checkbox .= '</input><br>';
|
661 |
echo $parent_checkbox;
|
662 |
+
|
663 |
+
$pages = get_pages(array(
|
664 |
+
'exclude' => array($frontpage_id) // exclude frontpage_id
|
665 |
+
));
|
666 |
foreach ( $pages as $page ) {
|
667 |
$checkbox = '<input type="checkbox"';
|
668 |
$checkbox .= $disabled ? 'disabled ' : '';
|