Version Description
- Bug security bug in admin panel.
Download this release
Release Info
Developer | rpetersen29 |
Plugin | Simple Banner |
Version | 2.10.8 |
Comparing to | |
See all releases |
Code changes from version 2.10.7 to 2.10.8
- readme.txt +7 -1
- simple-banner.php +284 -160
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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.9.0
|
7 |
-
Stable tag: 2.10.
|
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.10.7 =
|
122 |
* Bug fix for XSS.
|
123 |
|
@@ -286,6 +289,9 @@ Set your banner position to <code>relative</code> and try this in 'Website Custo
|
|
286 |
|
287 |
== Upgrade Notice ==
|
288 |
|
|
|
|
|
|
|
289 |
= 2.10.7 =
|
290 |
* Bug fix for XSS.
|
291 |
|
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.9.0
|
7 |
+
Stable tag: 2.10.8
|
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.8 =
|
122 |
+
* Bug security bug in admin panel.
|
123 |
+
|
124 |
= 2.10.7 =
|
125 |
* Bug fix for XSS.
|
126 |
|
289 |
|
290 |
== Upgrade Notice ==
|
291 |
|
292 |
+
= 2.10.8 =
|
293 |
+
* Bug security bug in admin panel.
|
294 |
+
|
295 |
= 2.10.7 =
|
296 |
* Bug fix for XSS.
|
297 |
|
simple-banner.php
CHANGED
@@ -3,34 +3,25 @@
|
|
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.
|
7 |
* Author: Ryan Petersen
|
8 |
* Author URI: http://rpetersen29.github.io/
|
9 |
* License: GPL2
|
10 |
*
|
11 |
* @package Simple Banner
|
12 |
-
* @version 2.10.
|
13 |
* @author Ryan Petersen <rpetersen.dev@gmail.com>
|
14 |
*/
|
15 |
-
define ('VERSION', '2.10.
|
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 |
-
function get_stripped_option($string) {
|
23 |
-
$allowed_html = wp_kses_allowed_html('post');
|
24 |
-
$string_value = wp_kses(get_option( $string ), $allowed_html, []);
|
25 |
-
$stripped_string_1 = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string_value );
|
26 |
-
$stripped_string_2 = preg_replace( '@href\=[\'\"]javascript@si', 'href="https://', $stripped_string_1 );
|
27 |
-
|
28 |
-
return $stripped_string_2;
|
29 |
-
}
|
30 |
-
|
31 |
// Disabled Pages/Posts functionns
|
32 |
function get_disabled_pages_array() {
|
33 |
-
return array_filter(explode(',',
|
34 |
}
|
35 |
function get_post_object() {
|
36 |
return get_posts(array('include' => array(get_the_ID())));
|
@@ -39,7 +30,7 @@ function get_is_current_page_a_post() {
|
|
39 |
return !empty(get_post_object());
|
40 |
}
|
41 |
function get_disabled_on_posts() {
|
42 |
-
return
|
43 |
}
|
44 |
function get_disabled_on_current_page() {
|
45 |
$disabled_on_current_page = (!empty(get_disabled_pages_array()) && in_array(get_the_ID(), get_disabled_pages_array()))
|
@@ -58,38 +49,38 @@ function simple_banner() {
|
|
58 |
$script_params = array(
|
59 |
// script specific parameters
|
60 |
'version' => VERSION,
|
61 |
-
'hide_simple_banner' =>
|
62 |
-
'simple_banner_position' =>
|
63 |
-
'header_margin' =>
|
64 |
-
'header_padding' =>
|
65 |
-
'simple_banner_text' =>
|
66 |
-
'pro_version_enabled' =>
|
67 |
'disabled_on_current_page' => $disabled_on_current_page,
|
68 |
// debug specific parameters
|
69 |
-
'debug_mode' =>
|
70 |
'id' => get_the_ID(),
|
71 |
'disabled_pages_array' => get_disabled_pages_array(),
|
72 |
// 'post_object' => get_post_object(),
|
73 |
'is_current_page_a_post' => get_is_current_page_a_post(),
|
74 |
'disabled_on_posts' => get_disabled_on_posts(),
|
75 |
-
'simple_banner_font_size' =>
|
76 |
-
'simple_banner_color' =>
|
77 |
-
'simple_banner_text_color' =>
|
78 |
-
'simple_banner_link_color' =>
|
79 |
-
'simple_banner_close_color' =>
|
80 |
-
'simple_banner_text' => $disabled_on_current_page ? '' :
|
81 |
-
'simple_banner_custom_css' =>
|
82 |
-
'simple_banner_scrolling_custom_css' =>
|
83 |
-
'simple_banner_text_custom_css' =>
|
84 |
-
'simple_banner_button_css' =>
|
85 |
-
'site_custom_css' =>
|
86 |
-
'keep_site_custom_css' =>
|
87 |
-
'site_custom_js' =>
|
88 |
-
'keep_site_custom_js' =>
|
89 |
-
'wp_body_open_enabled' =>
|
90 |
'wp_body_open' => function_exists('wp_body_open'),
|
91 |
-
'close_button_enabled' =>
|
92 |
-
'close_button_expiration' =>
|
93 |
'close_button_cookie_set' => isset($_COOKIE['simplebannerclosed']),
|
94 |
);
|
95 |
// Enqueue the script
|
@@ -99,19 +90,19 @@ function simple_banner() {
|
|
99 |
}
|
100 |
|
101 |
// Use `wp_body_open` action
|
102 |
-
if ( function_exists( 'wp_body_open' ) &&
|
103 |
add_action( 'wp_body_open', 'simple_banner_body_open' );
|
104 |
}
|
105 |
function simple_banner_body_open() {
|
106 |
// if not disabled use wp_body_open
|
107 |
$disabled_on_current_page = get_disabled_on_current_page();
|
108 |
-
$close_button_enabled =
|
109 |
$closed_cookie = $close_button_enabled && isset($_COOKIE['simplebannerclosed']);
|
110 |
-
$closed_button =
|
111 |
|
112 |
if (!$disabled_on_current_page && !$closed_cookie) {
|
113 |
echo '<div id="simple-banner" class="simple-banner"><div class="simple-banner-text"><span>'
|
114 |
-
.
|
115 |
. '</span></div>'
|
116 |
. $closed_button
|
117 |
. '</div>';
|
@@ -129,84 +120,84 @@ function prevent_css_removal()
|
|
129 |
add_action( 'wp_head', 'simple_banner_custom_options');
|
130 |
function simple_banner_custom_options()
|
131 |
{
|
132 |
-
$closed_cookie =
|
133 |
|
134 |
$disabled_on_current_page = get_disabled_on_current_page();
|
135 |
-
$banner_is_disabled = $disabled_on_current_page ||
|
136 |
|
137 |
if ($banner_is_disabled || $closed_cookie){
|
138 |
echo '<style type="text/css">.simple-banner{display:none;}</style>';
|
139 |
}
|
140 |
|
141 |
-
if (!$banner_is_disabled && !$closed_cookie &&
|
142 |
-
echo '<style id="simple-banner-header-margin" type="text/css">header{margin-top:' .
|
143 |
}
|
144 |
|
145 |
-
if (!$banner_is_disabled && !$closed_cookie &&
|
146 |
-
echo '<style id="simple-banner-header-padding" type="text/css" >header{padding-top:' .
|
147 |
}
|
148 |
|
149 |
-
if (
|
150 |
-
if (
|
151 |
echo '<style type="text/css">.simple-banner{position:fixed;bottom:0;}</style>';
|
152 |
} else {
|
153 |
-
echo '<style type="text/css">.simple-banner{position:' .
|
154 |
}
|
155 |
}
|
156 |
|
157 |
-
if (
|
158 |
-
echo '<style type="text/css">.simple-banner .simple-banner-text{font-size:' .
|
159 |
}
|
160 |
|
161 |
-
if (
|
162 |
-
echo '<style type="text/css">.simple-banner{background:' .
|
163 |
} else {
|
164 |
echo '<style type="text/css">.simple-banner{background: #024985;}</style>';
|
165 |
}
|
166 |
|
167 |
-
if (
|
168 |
-
echo '<style type="text/css">.simple-banner .simple-banner-text{color:' .
|
169 |
} else {
|
170 |
echo '<style type="text/css">.simple-banner .simple-banner-text{color: #ffffff;}</style>';
|
171 |
}
|
172 |
|
173 |
-
if (
|
174 |
-
echo '<style type="text/css">.simple-banner .simple-banner-text a{color:' .
|
175 |
} else {
|
176 |
echo '<style type="text/css">.simple-banner .simple-banner-text a{color:#f16521;}</style>';
|
177 |
}
|
178 |
|
179 |
-
if (
|
180 |
-
echo '<style type="text/css">.simple-banner .simple-banner-button{color:' .
|
181 |
}
|
182 |
|
183 |
-
if (
|
184 |
-
echo '<style type="text/css">.simple-banner{'.
|
185 |
}
|
186 |
|
187 |
-
if (
|
188 |
-
echo '<style type="text/css">.simple-banner.simple-banner-scrolling{'.
|
189 |
}
|
190 |
|
191 |
-
if (
|
192 |
-
echo '<style type="text/css">.simple-banner .simple-banner-text{'.
|
193 |
}
|
194 |
|
195 |
-
if (
|
196 |
-
echo '<style type="text/css">.simple-banner .simple-banner-button{'.
|
197 |
}
|
198 |
|
199 |
-
$remove_site_custom_css = ($banner_is_disabled || $closed_cookie) &&
|
200 |
-
if (!$remove_site_custom_css &&
|
201 |
-
echo '<style id="simple-banner-site-custom-css" type="text/css">'.
|
202 |
} else {
|
203 |
// put a dummy element to see if css is being bundled
|
204 |
echo '<style id="simple-banner-site-custom-css-dummy" type="text/css"></style>';
|
205 |
}
|
206 |
|
207 |
-
$remove_site_custom_js = ($banner_is_disabled || $closed_cookie) &&
|
208 |
-
if (!$remove_site_custom_js &&
|
209 |
-
echo '<script id="simple-banner-site-custom-js" type="text/javascript">'.
|
210 |
} else {
|
211 |
// put a dummy element to see if scripts are being bundled
|
212 |
echo '<script id="simple-banner-site-custom-js-dummy" type="text/javascript"></script>';
|
@@ -223,7 +214,7 @@ function simple_banner_menu() {
|
|
223 |
$admin->add_cap( $manage_simple_banner );
|
224 |
}
|
225 |
|
226 |
-
$permissions_array =
|
227 |
|
228 |
// Add permissions for other roles
|
229 |
foreach (get_editable_roles() as $role_name => $role_info) {
|
@@ -247,42 +238,166 @@ function simple_banner_menu() {
|
|
247 |
}
|
248 |
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
add_action( 'admin_init', 'simple_banner_settings' );
|
252 |
function simple_banner_settings() {
|
253 |
-
register_setting( 'simple-banner-settings-group', 'hide_simple_banner'
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
register_setting( 'simple-banner-settings-group', '
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
register_setting( 'simple-banner-settings-group', '
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
register_setting( 'simple-banner-settings-group', '
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
register_setting( 'simple-banner-settings-group', '
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
register_setting( 'simple-banner-settings-group', '
|
279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
}
|
281 |
|
282 |
function simple_banner_settings_page() {
|
283 |
?>
|
284 |
<?php
|
285 |
-
if (esc_attr(
|
286 |
update_option('pro_version_enabled', true);
|
287 |
} else {
|
288 |
update_option('pro_version_enabled', false);
|
@@ -331,10 +446,10 @@ function simple_banner_settings_page() {
|
|
331 |
</th>
|
332 |
<td style="vertical-align:top;">
|
333 |
<!-- -->
|
334 |
-
<input type="radio" id="yes" name="hide_simple_banner" value="yes" <?php echo ((
|
335 |
<label for="yes">yes</label>
|
336 |
<!-- -->
|
337 |
-
<input type="radio" id="no" name="hide_simple_banner" value="no" <?php echo ((
|
338 |
<label for="no">no</label>
|
339 |
<!-- -->
|
340 |
</td>
|
@@ -350,7 +465,7 @@ function simple_banner_settings_page() {
|
|
350 |
</th>
|
351 |
<td>
|
352 |
<?php
|
353 |
-
$checked =
|
354 |
echo '<input type="checkbox" id="close_button_enabled" '. $checked . ' name="close_button_enabled" />';
|
355 |
?>
|
356 |
</td>
|
@@ -366,7 +481,7 @@ function simple_banner_settings_page() {
|
|
366 |
</th>
|
367 |
<td>
|
368 |
<input type="number" min="1" max="30" id="close_button_expiration" name="close_button_expiration"
|
369 |
-
value="<?php echo esc_attr(
|
370 |
</td>
|
371 |
</tr>
|
372 |
<!-- Font Size -->
|
@@ -377,7 +492,7 @@ function simple_banner_settings_page() {
|
|
377 |
</th>
|
378 |
<td style="vertical-align:top;">
|
379 |
<input type="text" id="simple_banner_font_size" name="simple_banner_font_size" placeholder="font-size"
|
380 |
-
value="<?php echo esc_attr(
|
381 |
<span>e.g. 16px</span>
|
382 |
</td>
|
383 |
</tr>
|
@@ -389,9 +504,9 @@ function simple_banner_settings_page() {
|
|
389 |
</th>
|
390 |
<td style="vertical-align:top;">
|
391 |
<input type="text" id="simple_banner_color" name="simple_banner_color" placeholder="Hex value"
|
392 |
-
value="<?php echo esc_attr(
|
393 |
<input style="height: 30px;width: 100px;" type="color" id="simple_banner_color_show"
|
394 |
-
value="<?php echo ((
|
395 |
</td>
|
396 |
</tr>
|
397 |
<!-- Text Color -->
|
@@ -402,9 +517,9 @@ function simple_banner_settings_page() {
|
|
402 |
</th>
|
403 |
<td style="vertical-align:top;">
|
404 |
<input type="text" id="simple_banner_text_color" name="simple_banner_text_color" placeholder="Hex value"
|
405 |
-
value="<?php echo esc_attr(
|
406 |
<input style="height: 30px;width: 100px;" type="color" id="simple_banner_text_color_show"
|
407 |
-
value="<?php echo ((
|
408 |
</td>
|
409 |
</tr>
|
410 |
<!-- Link Color-->
|
@@ -415,9 +530,9 @@ function simple_banner_settings_page() {
|
|
415 |
</th>
|
416 |
<td style="vertical-align:top;">
|
417 |
<input type="text" id="simple_banner_link_color" name="simple_banner_link_color" placeholder="Hex value"
|
418 |
-
value="<?php echo esc_attr(
|
419 |
<input style="height: 30px;width: 100px;" type="color" id="simple_banner_link_color_show"
|
420 |
-
value="<?php echo ((
|
421 |
</td>
|
422 |
</tr>
|
423 |
<!-- Close Color-->
|
@@ -428,9 +543,9 @@ function simple_banner_settings_page() {
|
|
428 |
</th>
|
429 |
<td style="vertical-align:top;">
|
430 |
<input type="text" id="simple_banner_close_color" name="simple_banner_close_color" placeholder="Hex value"
|
431 |
-
value="<?php echo esc_attr(
|
432 |
<input style="height: 30px;width: 100px;" type="color" id="simple_banner_close_color_show"
|
433 |
-
value="<?php echo ((
|
434 |
</td>
|
435 |
</tr>
|
436 |
<!-- Text Contents -->
|
@@ -440,7 +555,7 @@ function simple_banner_settings_page() {
|
|
440 |
<br><span style="font-weight:400;">Leaving this blank removes the banner</span>
|
441 |
</th>
|
442 |
<td>
|
443 |
-
<textarea id="simple_banner_text" class="large-text code" style="height: 150px;width: 97%;" name="simple_banner_text"><?php echo
|
444 |
</td>
|
445 |
</tr>
|
446 |
<!-- Custom CSS -->
|
@@ -456,24 +571,24 @@ function simple_banner_settings_page() {
|
|
456 |
<tr valign="top">
|
457 |
<th scope="row" style="font-weight:400;">
|
458 |
<div>.simple-banner {</div>
|
459 |
-
<textarea id="simple_banner_custom_css" class="code" style="height: 150px;width: 90%;" name="simple_banner_custom_css"><?php echo
|
460 |
<div>}</div>
|
461 |
</th>
|
462 |
<td>
|
463 |
<div style="display:flex">
|
464 |
<div style="flex-grow:1;">
|
465 |
<div>.simple-banner-scrolling {</div>
|
466 |
-
<textarea id="simple_banner_scrolling_custom_css" class="code" style="height: 150px;width: 90%;" name="simple_banner_scrolling_custom_css"><?php echo
|
467 |
<div>}</div>
|
468 |
</div>
|
469 |
<div style="flex-grow:1;">
|
470 |
<div>.simple-banner-text {</div>
|
471 |
-
<textarea id="simple_banner_text_custom_css" class="code" style="height: 150px;width: 90%;" name="simple_banner_text_custom_css"><?php echo
|
472 |
<div>}</div>
|
473 |
</div>
|
474 |
<div style="flex-grow:1;">
|
475 |
<div>.simple-banner-button {</div>
|
476 |
-
<textarea id="simple_banner_button_css" class="code" style="height: 150px;width: 90%;" name="simple_banner_button_css"><?php echo
|
477 |
<div>}</div>
|
478 |
</div>
|
479 |
</div>
|
@@ -487,32 +602,32 @@ function simple_banner_settings_page() {
|
|
487 |
</th>
|
488 |
<td style="vertical-align:top;">
|
489 |
<!-- -->
|
490 |
-
<input type="radio" id="footer" name="simple_banner_position" value="footer" <?php echo ((
|
491 |
<label for="footer"><strong>footer:</strong> <span>The banner is fixed on the bottom of the window. Updates the banner position with the following css attributes <code>position: fixed;bottom: 0;</code></span></label><br>
|
492 |
<!-- -->
|
493 |
-
<input type="radio" id="static" name="simple_banner_position" value="static" <?php echo ((
|
494 |
<label for="static"><strong>static:</strong> <span>Default value. Elements render in order, as they appear in the document flow</span></label><br>
|
495 |
<!-- -->
|
496 |
-
<input type="radio" id="absolute" name="simple_banner_position" value="absolute" <?php echo ((
|
497 |
<label for="absolute"><strong>absolute:</strong> <span>The element is positioned relative to its first positioned (not static) ancestor element</span></label><br>
|
498 |
<!-- -->
|
499 |
-
<input type="radio" id="fixed" name="simple_banner_position" value="fixed" <?php echo ((
|
500 |
<label for="fixed"><strong>fixed:</strong> <span>The element is positioned relative to the browser window</span></label><br>
|
501 |
<!-- -->
|
502 |
-
<input type="radio" id="relative" name="simple_banner_position" value="relative" <?php echo ((
|
503 |
<label for="relative"><strong>relative:</strong> <span>The element is positioned relative to its normal position, so <code>left:20px</code> adds 20 pixels to the element's LEFT position</span></label><br>
|
504 |
<!-- -->
|
505 |
-
<input type="radio" id="sticky" name="simple_banner_position" value="sticky" <?php echo ((
|
506 |
<label for="sticky"><strong>sticky:</strong> <span>The element is positioned based on the user's scroll position</span></label><br>
|
507 |
<div style="padding-left: 10px;">
|
508 |
A sticky element toggles between relative and fixed, depending on the scroll position.
|
509 |
It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position:fixed).<br>
|
510 |
<strong>Note:</strong> Not supported in IE/Edge 15 or earlier. Supported in Safari from version 6.1 with a -webkit- prefix.</div>
|
511 |
<!-- -->
|
512 |
-
<input type="radio" id="initial" name="simple_banner_position" value="initial" <?php echo ((
|
513 |
<label for="initial"><strong>initial:</strong> <span>Sets this property to its default value.</span></label><br>
|
514 |
<!-- -->
|
515 |
-
<input type="radio" id="inherit" name="simple_banner_position" value="inherit" <?php echo ((
|
516 |
<label for="inherit"><strong>inherit:</strong> <span>Inherits this property from its parent element.</span></label><br>
|
517 |
</td>
|
518 |
</tr>
|
@@ -525,7 +640,7 @@ function simple_banner_settings_page() {
|
|
525 |
</th>
|
526 |
<td style="vertical-align:top;">
|
527 |
<input type="text" id="header_margin" name="header_margin" placeholder="margin-top"
|
528 |
-
value="<?php echo esc_attr(
|
529 |
<span>e.g. 40px</span>
|
530 |
</td>
|
531 |
</tr>
|
@@ -538,7 +653,7 @@ function simple_banner_settings_page() {
|
|
538 |
</th>
|
539 |
<td style="vertical-align:top;">
|
540 |
<input type="text" id="header_padding" name="header_padding" placeholder="padding-top"
|
541 |
-
value="<?php echo esc_attr(
|
542 |
<span>e.g. 40px</span>
|
543 |
</td>
|
544 |
</tr>
|
@@ -556,7 +671,7 @@ function simple_banner_settings_page() {
|
|
556 |
</th>
|
557 |
<td>
|
558 |
<?php
|
559 |
-
$checked =
|
560 |
echo '<input type="checkbox" id="wp_body_open_enabled" '. $checked . ' name="wp_body_open_enabled" />';
|
561 |
?>
|
562 |
</td>
|
@@ -581,7 +696,7 @@ function simple_banner_settings_page() {
|
|
581 |
|
582 |
<h2>Pro Features
|
583 |
<?php
|
584 |
-
if (!
|
585 |
echo '<a class="button-primary" href="https://simple-banner.square.site/" target="_blank">Purchase Pro Version</a>';
|
586 |
}
|
587 |
?>
|
@@ -589,12 +704,12 @@ function simple_banner_settings_page() {
|
|
589 |
|
590 |
<table class="form-table">
|
591 |
<!-- Activation Code -->
|
592 |
-
<tr valign="top" style="<?php if (
|
593 |
<th scope="row">
|
594 |
Activation Code
|
595 |
</th>
|
596 |
<td>
|
597 |
-
<input type="text" style="border: 2px solid gold;border-radius: 5px;" id="pro_version_activation_code" name="pro_version_activation_code" value="<?php echo
|
598 |
</td>
|
599 |
</tr>
|
600 |
<!-- Permissions -->
|
@@ -608,8 +723,8 @@ function simple_banner_settings_page() {
|
|
608 |
<div id="simple_banner_pro_permissions">
|
609 |
<?php
|
610 |
$roles = get_editable_roles();
|
611 |
-
$disabled = !
|
612 |
-
$permissions_array =
|
613 |
foreach (get_editable_roles() as $role_name => $role_info) {
|
614 |
if ($role_name == 'administrator') {
|
615 |
continue;
|
@@ -630,8 +745,8 @@ function simple_banner_settings_page() {
|
|
630 |
</tr>
|
631 |
<?php endif; ?>
|
632 |
<?php
|
633 |
-
if (
|
634 |
-
echo '<input type="text" hidden id="permissions_array" name="permissions_array" value="'.
|
635 |
}
|
636 |
?>
|
637 |
<!-- Disabled on Psts -->
|
@@ -646,8 +761,8 @@ function simple_banner_settings_page() {
|
|
646 |
</th>
|
647 |
<td style="padding-top:0;">
|
648 |
<?php
|
649 |
-
if (
|
650 |
-
$checked =
|
651 |
echo '<input type="checkbox" id="disabled_on_posts" '. $checked . ' name="disabled_on_posts" />';
|
652 |
} else {
|
653 |
echo '<input type="checkbox" disabled />';
|
@@ -664,9 +779,9 @@ function simple_banner_settings_page() {
|
|
664 |
<td>
|
665 |
<div id="simple_banner_pro_disabled_pages">
|
666 |
<?php
|
667 |
-
$disabled = !
|
668 |
-
$disabled_pages_array = array_filter(explode(',',
|
669 |
-
$frontpage_id =
|
670 |
if ($frontpage_id == 0) {
|
671 |
$frontpage_id = 1;
|
672 |
}
|
@@ -674,7 +789,7 @@ function simple_banner_settings_page() {
|
|
674 |
$parent_checkbox .= $disabled ? 'disabled ' : '';
|
675 |
$parent_checkbox .= (!$disabled && in_array($frontpage_id, $disabled_pages_array)) ? 'checked ' : '';
|
676 |
$parent_checkbox .= 'value="' . $frontpage_id . '">';
|
677 |
-
$parent_checkbox .=
|
678 |
$parent_checkbox .= '</input><br>';
|
679 |
echo $parent_checkbox;
|
680 |
|
@@ -693,8 +808,8 @@ function simple_banner_settings_page() {
|
|
693 |
?>
|
694 |
</div>
|
695 |
<?php
|
696 |
-
if (
|
697 |
-
echo '<input type="text" hidden id="disabled_pages_array" name="disabled_pages_array" value="'.
|
698 |
}
|
699 |
?>
|
700 |
</td>
|
@@ -707,8 +822,8 @@ function simple_banner_settings_page() {
|
|
707 |
</th>
|
708 |
<td>
|
709 |
<?php
|
710 |
-
if (
|
711 |
-
echo '<textarea id="site_custom_css" style="height: 150px;width: 75%;" name="site_custom_css">'.
|
712 |
} else {
|
713 |
echo '<textarea style="height: 150px;width: 75%;" disabled></textarea>';
|
714 |
}
|
@@ -721,8 +836,8 @@ function simple_banner_settings_page() {
|
|
721 |
</th>
|
722 |
<td style="padding-top:0;">
|
723 |
<?php
|
724 |
-
if (
|
725 |
-
$checked =
|
726 |
echo '<input type="checkbox" id="keep_site_custom_css" '. $checked . ' name="keep_site_custom_css" />';
|
727 |
} else {
|
728 |
echo '<input type="checkbox" disabled />';
|
@@ -738,8 +853,8 @@ function simple_banner_settings_page() {
|
|
738 |
</th>
|
739 |
<td>
|
740 |
<?php
|
741 |
-
if (
|
742 |
-
echo '<textarea id="site_custom_js" style="height: 150px;width: 75%;" name="site_custom_js">'.
|
743 |
} else {
|
744 |
echo '<textarea style="height: 150px;width: 75%;" disabled></textarea>';
|
745 |
}
|
@@ -752,8 +867,8 @@ function simple_banner_settings_page() {
|
|
752 |
</th>
|
753 |
<td style="padding-top:0;">
|
754 |
<?php
|
755 |
-
if (
|
756 |
-
$checked =
|
757 |
echo '<input type="checkbox" id="keep_site_custom_js" '. $checked . ' name="keep_site_custom_js" />';
|
758 |
} else {
|
759 |
echo '<input type="checkbox" disabled />';
|
@@ -769,8 +884,8 @@ function simple_banner_settings_page() {
|
|
769 |
</th>
|
770 |
<td>
|
771 |
<?php
|
772 |
-
if (
|
773 |
-
$checked =
|
774 |
echo '<input type="checkbox" id="debug_mode" '. $checked . ' name="debug_mode" />';
|
775 |
} else {
|
776 |
echo '<input type="checkbox" disabled />';
|
@@ -821,11 +936,20 @@ function simple_banner_settings_page() {
|
|
821 |
var style_custom_button_css = document.createElement('style');
|
822 |
|
823 |
// Banner Text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
824 |
document.getElementById('preview_banner_text').innerHTML = document.getElementById('simple_banner_text').value != "" ?
|
825 |
-
'<span>'+document.getElementById('simple_banner_text').value+'</span>' :
|
826 |
'<span>This is what your banner will look like with a <a href="/">link</a>.</span>';
|
827 |
document.getElementById('simple_banner_text').onchange=function(e){
|
828 |
-
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>';
|
829 |
};
|
830 |
|
831 |
// Close Button
|
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.8
|
7 |
* Author: Ryan Petersen
|
8 |
* Author URI: http://rpetersen29.github.io/
|
9 |
* License: GPL2
|
10 |
*
|
11 |
* @package Simple Banner
|
12 |
+
* @version 2.10.8
|
13 |
* @author Ryan Petersen <rpetersen.dev@gmail.com>
|
14 |
*/
|
15 |
+
define ('VERSION', '2.10.8');
|
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())));
|
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()))
|
49 |
$script_params = array(
|
50 |
// script specific parameters
|
51 |
'version' => VERSION,
|
52 |
+
'hide_simple_banner' => get_option('hide_simple_banner'),
|
53 |
+
'simple_banner_position' => get_option('simple_banner_position'),
|
54 |
+
'header_margin' => get_option('header_margin'),
|
55 |
+
'header_padding' => get_option('header_padding'),
|
56 |
+
'simple_banner_text' => get_option('simple_banner_text'),
|
57 |
+
'pro_version_enabled' => get_option('pro_version_enabled'),
|
58 |
'disabled_on_current_page' => $disabled_on_current_page,
|
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'),
|
69 |
+
'simple_banner_link_color' => get_option('simple_banner_link_color'),
|
70 |
+
'simple_banner_close_color' => get_option('simple_banner_close_color'),
|
71 |
+
'simple_banner_text' => $disabled_on_current_page ? '' : get_option('simple_banner_text'),
|
72 |
+
'simple_banner_custom_css' => get_option('simple_banner_custom_css'),
|
73 |
+
'simple_banner_scrolling_custom_css' => get_option('simple_banner_scrolling_custom_css'),
|
74 |
+
'simple_banner_text_custom_css' => get_option('simple_banner_text_custom_css'),
|
75 |
+
'simple_banner_button_css' => get_option('simple_banner_button_css'),
|
76 |
+
'site_custom_css' => get_option('site_custom_css'),
|
77 |
+
'keep_site_custom_css' => get_option('keep_site_custom_css'),
|
78 |
+
'site_custom_js' => get_option('site_custom_js'),
|
79 |
+
'keep_site_custom_js' => get_option('keep_site_custom_js'),
|
80 |
+
'wp_body_open_enabled' => get_option('wp_body_open_enabled'),
|
81 |
'wp_body_open' => function_exists('wp_body_open'),
|
82 |
+
'close_button_enabled' => get_option('close_button_enabled'),
|
83 |
+
'close_button_expiration' => get_option('close_button_expiration'),
|
84 |
'close_button_cookie_set' => isset($_COOKIE['simplebannerclosed']),
|
85 |
);
|
86 |
// Enqueue the script
|
90 |
}
|
91 |
|
92 |
// Use `wp_body_open` action
|
93 |
+
if ( function_exists( 'wp_body_open' ) && get_option('wp_body_open_enabled') ) {
|
94 |
add_action( 'wp_body_open', 'simple_banner_body_open' );
|
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 |
|
103 |
if (!$disabled_on_current_page && !$closed_cookie) {
|
104 |
echo '<div id="simple-banner" class="simple-banner"><div class="simple-banner-text"><span>'
|
105 |
+
. get_option('simple_banner_text')
|
106 |
. '</span></div>'
|
107 |
. $closed_button
|
108 |
. '</div>';
|
120 |
add_action( 'wp_head', 'simple_banner_custom_options');
|
121 |
function simple_banner_custom_options()
|
122 |
{
|
123 |
+
$closed_cookie = get_option('close_button_enabled') && isset($_COOKIE["simplebannerclosed"]);
|
124 |
|
125 |
$disabled_on_current_page = get_disabled_on_current_page();
|
126 |
+
$banner_is_disabled = $disabled_on_current_page || get_option('hide_simple_banner') == "yes";
|
127 |
|
128 |
if ($banner_is_disabled || $closed_cookie){
|
129 |
echo '<style type="text/css">.simple-banner{display:none;}</style>';
|
130 |
}
|
131 |
|
132 |
+
if (!$banner_is_disabled && !$closed_cookie && get_option('header_margin') != ""){
|
133 |
+
echo '<style id="simple-banner-header-margin" type="text/css">header{margin-top:' . get_option('header_margin') . ';}</style>';
|
134 |
}
|
135 |
|
136 |
+
if (!$banner_is_disabled && !$closed_cookie && get_option('header_padding') != ""){
|
137 |
+
echo '<style id="simple-banner-header-padding" type="text/css" >header{padding-top:' . get_option('header_padding') . ';}</style>';
|
138 |
}
|
139 |
|
140 |
+
if (get_option('simple_banner_position') != ""){
|
141 |
+
if (get_option('simple_banner_position') == 'footer'){
|
142 |
echo '<style type="text/css">.simple-banner{position:fixed;bottom:0;}</style>';
|
143 |
} else {
|
144 |
+
echo '<style type="text/css">.simple-banner{position:' . get_option('simple_banner_position') . ';}</style>';
|
145 |
}
|
146 |
}
|
147 |
|
148 |
+
if (get_option('simple_banner_font_size') != ""){
|
149 |
+
echo '<style type="text/css">.simple-banner .simple-banner-text{font-size:' . get_option('simple_banner_font_size') . ';}</style>';
|
150 |
}
|
151 |
|
152 |
+
if (get_option('simple_banner_color') != ""){
|
153 |
+
echo '<style type="text/css">.simple-banner{background:' . get_option('simple_banner_color') . ';}</style>';
|
154 |
} else {
|
155 |
echo '<style type="text/css">.simple-banner{background: #024985;}</style>';
|
156 |
}
|
157 |
|
158 |
+
if (get_option('simple_banner_text_color') != ""){
|
159 |
+
echo '<style type="text/css">.simple-banner .simple-banner-text{color:' . get_option('simple_banner_text_color') . ';}</style>';
|
160 |
} else {
|
161 |
echo '<style type="text/css">.simple-banner .simple-banner-text{color: #ffffff;}</style>';
|
162 |
}
|
163 |
|
164 |
+
if (get_option('simple_banner_link_color') != ""){
|
165 |
+
echo '<style type="text/css">.simple-banner .simple-banner-text a{color:' . get_option('simple_banner_link_color') . ';}</style>';
|
166 |
} else {
|
167 |
echo '<style type="text/css">.simple-banner .simple-banner-text a{color:#f16521;}</style>';
|
168 |
}
|
169 |
|
170 |
+
if (get_option('simple_banner_close_color') != ""){
|
171 |
+
echo '<style type="text/css">.simple-banner .simple-banner-button{color:' . get_option('simple_banner_close_color') . ';}</style>';
|
172 |
}
|
173 |
|
174 |
+
if (get_option('simple_banner_custom_css') != ""){
|
175 |
+
echo '<style type="text/css">.simple-banner{'. get_option('simple_banner_custom_css') . '}</style>';
|
176 |
}
|
177 |
|
178 |
+
if (get_option('simple_banner_scrolling_custom_css') != ""){
|
179 |
+
echo '<style type="text/css">.simple-banner.simple-banner-scrolling{'. get_option('simple_banner_scrolling_custom_css') . '}</style>';
|
180 |
}
|
181 |
|
182 |
+
if (get_option('simple_banner_text_custom_css') != ""){
|
183 |
+
echo '<style type="text/css">.simple-banner .simple-banner-text{'. get_option('simple_banner_text_custom_css') . '}</style>';
|
184 |
}
|
185 |
|
186 |
+
if (get_option('simple_banner_button_css') != ""){
|
187 |
+
echo '<style type="text/css">.simple-banner .simple-banner-button{'. get_option('simple_banner_button_css') . '}</style>';
|
188 |
}
|
189 |
|
190 |
+
$remove_site_custom_css = ($banner_is_disabled || $closed_cookie) && get_option('keep_site_custom_css') == "";
|
191 |
+
if (!$remove_site_custom_css && get_option('site_custom_css') != "" && get_option('pro_version_enabled')) {
|
192 |
+
echo '<style id="simple-banner-site-custom-css" type="text/css">'. get_option('site_custom_css') . '</style>';
|
193 |
} else {
|
194 |
// put a dummy element to see if css is being bundled
|
195 |
echo '<style id="simple-banner-site-custom-css-dummy" type="text/css"></style>';
|
196 |
}
|
197 |
|
198 |
+
$remove_site_custom_js = ($banner_is_disabled || $closed_cookie) && get_option('keep_site_custom_js') == "";
|
199 |
+
if (!$remove_site_custom_js && get_option('site_custom_js') != "" && get_option('pro_version_enabled')) {
|
200 |
+
echo '<script id="simple-banner-site-custom-js" type="text/javascript">'. get_option('site_custom_js') . '</script>';
|
201 |
} else {
|
202 |
// put a dummy element to see if scripts are being bundled
|
203 |
echo '<script id="simple-banner-site-custom-js-dummy" type="text/javascript"></script>';
|
214 |
$admin->add_cap( $manage_simple_banner );
|
215 |
}
|
216 |
|
217 |
+
$permissions_array = get_option('permissions_array');
|
218 |
|
219 |
// Add permissions for other roles
|
220 |
foreach (get_editable_roles() as $role_name => $role_info) {
|
238 |
}
|
239 |
|
240 |
|
241 |
+
// TODO: Add this check after looking into `unfiltered_html` option
|
242 |
+
// function get_sanitized_simple_banner_text($string) {
|
243 |
+
// $string_value = $string;
|
244 |
+
// if ( current_user_can( 'unfiltered_html' ) ) {
|
245 |
+
// returnwp_kses_post( $string );
|
246 |
+
// } else {
|
247 |
+
// return wp_kses_data( $string );
|
248 |
+
// }
|
249 |
+
// }
|
250 |
+
|
251 |
+
//script input sanitization function
|
252 |
+
function theme_slug_sanitize_js_code($input){
|
253 |
+
return base64_encode($input);
|
254 |
+
}
|
255 |
+
|
256 |
+
|
257 |
+
//output escape function
|
258 |
+
function theme_slug_escape_js_output($input){
|
259 |
+
return esc_textarea( base64_decode($input) );
|
260 |
+
}
|
261 |
|
262 |
add_action( 'admin_init', 'simple_banner_settings' );
|
263 |
function simple_banner_settings() {
|
264 |
+
register_setting( 'simple-banner-settings-group', 'hide_simple_banner',
|
265 |
+
array(
|
266 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
267 |
+
)
|
268 |
+
);
|
269 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_font_size',
|
270 |
+
array(
|
271 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
272 |
+
)
|
273 |
+
);
|
274 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_color',
|
275 |
+
array(
|
276 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
277 |
+
)
|
278 |
+
);
|
279 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_text_color',
|
280 |
+
array(
|
281 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
282 |
+
)
|
283 |
+
);
|
284 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_link_color',
|
285 |
+
array(
|
286 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
287 |
+
)
|
288 |
+
);
|
289 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_close_color',
|
290 |
+
array(
|
291 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
292 |
+
)
|
293 |
+
);
|
294 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_text',
|
295 |
+
array(
|
296 |
+
'sanitize_callback' => 'wp_kses_post'
|
297 |
+
)
|
298 |
+
);
|
299 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_custom_css',
|
300 |
+
array(
|
301 |
+
'sanitize_callback' => 'wp_strip_all_tags'
|
302 |
+
)
|
303 |
+
);
|
304 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_scrolling_custom_css',
|
305 |
+
array(
|
306 |
+
'sanitize_callback' => 'wp_strip_all_tags'
|
307 |
+
)
|
308 |
+
);
|
309 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_text_custom_css',
|
310 |
+
array(
|
311 |
+
'sanitize_callback' => 'wp_strip_all_tags'
|
312 |
+
)
|
313 |
+
);
|
314 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_button_css',
|
315 |
+
array(
|
316 |
+
'sanitize_callback' => 'wp_strip_all_tags'
|
317 |
+
)
|
318 |
+
);
|
319 |
+
register_setting( 'simple-banner-settings-group', 'simple_banner_position',
|
320 |
+
array(
|
321 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
322 |
+
)
|
323 |
+
);
|
324 |
+
register_setting( 'simple-banner-settings-group', 'header_margin',
|
325 |
+
array(
|
326 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
327 |
+
)
|
328 |
+
);
|
329 |
+
register_setting( 'simple-banner-settings-group', 'header_padding',
|
330 |
+
array(
|
331 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
332 |
+
)
|
333 |
+
);
|
334 |
+
register_setting( 'simple-banner-settings-group', 'pro_version_activation_code',
|
335 |
+
array(
|
336 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
337 |
+
)
|
338 |
+
);
|
339 |
+
register_setting( 'simple-banner-settings-group', 'pro_version_enabled',
|
340 |
+
array(
|
341 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
342 |
+
)
|
343 |
+
);
|
344 |
+
register_setting( 'simple-banner-settings-group', 'disabled_on_posts',
|
345 |
+
array(
|
346 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
347 |
+
)
|
348 |
+
);
|
349 |
+
register_setting( 'simple-banner-settings-group', 'disabled_pages_array',
|
350 |
+
array(
|
351 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
352 |
+
)
|
353 |
+
);
|
354 |
+
register_setting( 'simple-banner-settings-group', 'permissions_array',
|
355 |
+
array(
|
356 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
357 |
+
)
|
358 |
+
);
|
359 |
+
register_setting( 'simple-banner-settings-group', 'site_custom_css',
|
360 |
+
array(
|
361 |
+
'sanitize_callback' => 'wp_strip_all_tags'
|
362 |
+
)
|
363 |
+
);
|
364 |
+
register_setting( 'simple-banner-settings-group', 'keep_site_custom_css',
|
365 |
+
array(
|
366 |
+
'sanitize_callback' => 'wp_strip_all_tags'
|
367 |
+
)
|
368 |
+
);
|
369 |
+
register_setting( 'simple-banner-settings-group', 'site_custom_js');
|
370 |
+
register_setting( 'simple-banner-settings-group', 'keep_site_custom_js',
|
371 |
+
array(
|
372 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
373 |
+
)
|
374 |
+
);
|
375 |
+
register_setting( 'simple-banner-settings-group', 'debug_mode',
|
376 |
+
array(
|
377 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
378 |
+
)
|
379 |
+
);
|
380 |
+
register_setting( 'simple-banner-settings-group', 'wp_body_open_enabled',
|
381 |
+
array(
|
382 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
383 |
+
)
|
384 |
+
);
|
385 |
+
register_setting( 'simple-banner-settings-group', 'close_button_enabled',
|
386 |
+
array(
|
387 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
388 |
+
)
|
389 |
+
);
|
390 |
+
register_setting( 'simple-banner-settings-group', 'close_button_expiration',
|
391 |
+
array(
|
392 |
+
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
393 |
+
)
|
394 |
+
);
|
395 |
}
|
396 |
|
397 |
function simple_banner_settings_page() {
|
398 |
?>
|
399 |
<?php
|
400 |
+
if (esc_attr( get_option('pro_version_activation_code') ) == "SBPROv1-14315") {
|
401 |
update_option('pro_version_enabled', true);
|
402 |
} else {
|
403 |
update_option('pro_version_enabled', false);
|
446 |
</th>
|
447 |
<td style="vertical-align:top;">
|
448 |
<!-- -->
|
449 |
+
<input type="radio" id="yes" name="hide_simple_banner" value="yes" <?php echo ((get_option('hide_simple_banner') == 'yes') ? 'checked' : '' ); ?>>
|
450 |
<label for="yes">yes</label>
|
451 |
<!-- -->
|
452 |
+
<input type="radio" id="no" name="hide_simple_banner" value="no" <?php echo ((get_option('hide_simple_banner') == 'yes') ? '' : 'checked' ); ?>>
|
453 |
<label for="no">no</label>
|
454 |
<!-- -->
|
455 |
</td>
|
465 |
</th>
|
466 |
<td>
|
467 |
<?php
|
468 |
+
$checked = get_option('close_button_enabled') ? 'checked ' : '';
|
469 |
echo '<input type="checkbox" id="close_button_enabled" '. $checked . ' name="close_button_enabled" />';
|
470 |
?>
|
471 |
</td>
|
481 |
</th>
|
482 |
<td>
|
483 |
<input type="number" min="1" max="30" id="close_button_expiration" name="close_button_expiration"
|
484 |
+
value="<?php echo esc_attr( get_option('close_button_expiration') ); ?>" />
|
485 |
</td>
|
486 |
</tr>
|
487 |
<!-- Font Size -->
|
492 |
</th>
|
493 |
<td style="vertical-align:top;">
|
494 |
<input type="text" id="simple_banner_font_size" name="simple_banner_font_size" placeholder="font-size"
|
495 |
+
value="<?php echo esc_attr( get_option('simple_banner_font_size') ); ?>" />
|
496 |
<span>e.g. 16px</span>
|
497 |
</td>
|
498 |
</tr>
|
504 |
</th>
|
505 |
<td style="vertical-align:top;">
|
506 |
<input type="text" id="simple_banner_color" name="simple_banner_color" placeholder="Hex value"
|
507 |
+
value="<?php echo esc_attr( get_option('simple_banner_color') ); ?>" />
|
508 |
<input style="height: 30px;width: 100px;" type="color" id="simple_banner_color_show"
|
509 |
+
value="<?php echo ((get_option('simple_banner_color') == '') ? '#024985' : esc_attr( get_option('simple_banner_color') )); ?>">
|
510 |
</td>
|
511 |
</tr>
|
512 |
<!-- Text Color -->
|
517 |
</th>
|
518 |
<td style="vertical-align:top;">
|
519 |
<input type="text" id="simple_banner_text_color" name="simple_banner_text_color" placeholder="Hex value"
|
520 |
+
value="<?php echo esc_attr( get_option('simple_banner_text_color') ); ?>" />
|
521 |
<input style="height: 30px;width: 100px;" type="color" id="simple_banner_text_color_show"
|
522 |
+
value="<?php echo ((get_option('simple_banner_text_color') == '') ? '#ffffff' : esc_attr( get_option('simple_banner_text_color') )); ?>">
|
523 |
</td>
|
524 |
</tr>
|
525 |
<!-- Link Color-->
|
530 |
</th>
|
531 |
<td style="vertical-align:top;">
|
532 |
<input type="text" id="simple_banner_link_color" name="simple_banner_link_color" placeholder="Hex value"
|
533 |
+
value="<?php echo esc_attr( get_option('simple_banner_link_color') ); ?>" />
|
534 |
<input style="height: 30px;width: 100px;" type="color" id="simple_banner_link_color_show"
|
535 |
+
value="<?php echo ((get_option('simple_banner_link_color') == '') ? '#f16521' : esc_attr( get_option('simple_banner_link_color') )); ?>">
|
536 |
</td>
|
537 |
</tr>
|
538 |
<!-- Close Color-->
|
543 |
</th>
|
544 |
<td style="vertical-align:top;">
|
545 |
<input type="text" id="simple_banner_close_color" name="simple_banner_close_color" placeholder="Hex value"
|
546 |
+
value="<?php echo esc_attr( get_option('simple_banner_close_color') ); ?>" />
|
547 |
<input style="height: 30px;width: 100px;" type="color" id="simple_banner_close_color_show"
|
548 |
+
value="<?php echo ((get_option('simple_banner_close_color') == '') ? 'black' : esc_attr( get_option('simple_banner_close_color') )); ?>">
|
549 |
</td>
|
550 |
</tr>
|
551 |
<!-- Text Contents -->
|
555 |
<br><span style="font-weight:400;">Leaving this blank removes the banner</span>
|
556 |
</th>
|
557 |
<td>
|
558 |
+
<textarea id="simple_banner_text" class="large-text code" style="height: 150px;width: 97%;" name="simple_banner_text"><?php echo get_option('simple_banner_text'); ?></textarea>
|
559 |
</td>
|
560 |
</tr>
|
561 |
<!-- Custom CSS -->
|
571 |
<tr valign="top">
|
572 |
<th scope="row" style="font-weight:400;">
|
573 |
<div>.simple-banner {</div>
|
574 |
+
<textarea id="simple_banner_custom_css" class="code" style="height: 150px;width: 90%;" name="simple_banner_custom_css"><?php echo get_option('simple_banner_custom_css'); ?></textarea>
|
575 |
<div>}</div>
|
576 |
</th>
|
577 |
<td>
|
578 |
<div style="display:flex">
|
579 |
<div style="flex-grow:1;">
|
580 |
<div>.simple-banner-scrolling {</div>
|
581 |
+
<textarea id="simple_banner_scrolling_custom_css" class="code" style="height: 150px;width: 90%;" name="simple_banner_scrolling_custom_css"><?php echo get_option('simple_banner_scrolling_custom_css'); ?></textarea>
|
582 |
<div>}</div>
|
583 |
</div>
|
584 |
<div style="flex-grow:1;">
|
585 |
<div>.simple-banner-text {</div>
|
586 |
+
<textarea id="simple_banner_text_custom_css" class="code" style="height: 150px;width: 90%;" name="simple_banner_text_custom_css"><?php echo get_option('simple_banner_text_custom_css'); ?></textarea>
|
587 |
<div>}</div>
|
588 |
</div>
|
589 |
<div style="flex-grow:1;">
|
590 |
<div>.simple-banner-button {</div>
|
591 |
+
<textarea id="simple_banner_button_css" class="code" style="height: 150px;width: 90%;" name="simple_banner_button_css"><?php echo get_option('simple_banner_button_css'); ?></textarea>
|
592 |
<div>}</div>
|
593 |
</div>
|
594 |
</div>
|
602 |
</th>
|
603 |
<td style="vertical-align:top;">
|
604 |
<!-- -->
|
605 |
+
<input type="radio" id="footer" name="simple_banner_position" value="footer" <?php echo ((get_option('simple_banner_position') == 'footer') ? 'checked' : '' ); ?>>
|
606 |
<label for="footer"><strong>footer:</strong> <span>The banner is fixed on the bottom of the window. Updates the banner position with the following css attributes <code>position: fixed;bottom: 0;</code></span></label><br>
|
607 |
<!-- -->
|
608 |
+
<input type="radio" id="static" name="simple_banner_position" value="static" <?php echo ((get_option('simple_banner_position') == 'static') ? 'checked' : '' ); ?>>
|
609 |
<label for="static"><strong>static:</strong> <span>Default value. Elements render in order, as they appear in the document flow</span></label><br>
|
610 |
<!-- -->
|
611 |
+
<input type="radio" id="absolute" name="simple_banner_position" value="absolute" <?php echo ((get_option('simple_banner_position') == 'absolute') ? 'checked' : '' ); ?>>
|
612 |
<label for="absolute"><strong>absolute:</strong> <span>The element is positioned relative to its first positioned (not static) ancestor element</span></label><br>
|
613 |
<!-- -->
|
614 |
+
<input type="radio" id="fixed" name="simple_banner_position" value="fixed" <?php echo ((get_option('simple_banner_position') == 'fixed') ? 'checked' : '' ); ?>>
|
615 |
<label for="fixed"><strong>fixed:</strong> <span>The element is positioned relative to the browser window</span></label><br>
|
616 |
<!-- -->
|
617 |
+
<input type="radio" id="relative" name="simple_banner_position" value="relative" <?php echo ((get_option('simple_banner_position') == 'relative') ? 'checked' : '' ); ?>>
|
618 |
<label for="relative"><strong>relative:</strong> <span>The element is positioned relative to its normal position, so <code>left:20px</code> adds 20 pixels to the element's LEFT position</span></label><br>
|
619 |
<!-- -->
|
620 |
+
<input type="radio" id="sticky" name="simple_banner_position" value="sticky" <?php echo ((get_option('simple_banner_position') == 'sticky') ? 'checked' : '' ); ?>>
|
621 |
<label for="sticky"><strong>sticky:</strong> <span>The element is positioned based on the user's scroll position</span></label><br>
|
622 |
<div style="padding-left: 10px;">
|
623 |
A sticky element toggles between relative and fixed, depending on the scroll position.
|
624 |
It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position:fixed).<br>
|
625 |
<strong>Note:</strong> Not supported in IE/Edge 15 or earlier. Supported in Safari from version 6.1 with a -webkit- prefix.</div>
|
626 |
<!-- -->
|
627 |
+
<input type="radio" id="initial" name="simple_banner_position" value="initial" <?php echo ((get_option('simple_banner_position') == 'initial') ? 'checked' : '' ); ?>>
|
628 |
<label for="initial"><strong>initial:</strong> <span>Sets this property to its default value.</span></label><br>
|
629 |
<!-- -->
|
630 |
+
<input type="radio" id="inherit" name="simple_banner_position" value="inherit" <?php echo ((get_option('simple_banner_position') == 'inherit') ? 'checked' : '' ); ?>>
|
631 |
<label for="inherit"><strong>inherit:</strong> <span>Inherits this property from its parent element.</span></label><br>
|
632 |
</td>
|
633 |
</tr>
|
640 |
</th>
|
641 |
<td style="vertical-align:top;">
|
642 |
<input type="text" id="header_margin" name="header_margin" placeholder="margin-top"
|
643 |
+
value="<?php echo esc_attr( get_option('header_margin') ); ?>" />
|
644 |
<span>e.g. 40px</span>
|
645 |
</td>
|
646 |
</tr>
|
653 |
</th>
|
654 |
<td style="vertical-align:top;">
|
655 |
<input type="text" id="header_padding" name="header_padding" placeholder="padding-top"
|
656 |
+
value="<?php echo esc_attr( get_option('header_padding') ); ?>" />
|
657 |
<span>e.g. 40px</span>
|
658 |
</td>
|
659 |
</tr>
|
671 |
</th>
|
672 |
<td>
|
673 |
<?php
|
674 |
+
$checked = get_option('wp_body_open_enabled') ? 'checked ' : '';
|
675 |
echo '<input type="checkbox" id="wp_body_open_enabled" '. $checked . ' name="wp_body_open_enabled" />';
|
676 |
?>
|
677 |
</td>
|
696 |
|
697 |
<h2>Pro Features
|
698 |
<?php
|
699 |
+
if (!get_option('pro_version_enabled')) {
|
700 |
echo '<a class="button-primary" href="https://simple-banner.square.site/" target="_blank">Purchase Pro Version</a>';
|
701 |
}
|
702 |
?>
|
704 |
|
705 |
<table class="form-table">
|
706 |
<!-- Activation Code -->
|
707 |
+
<tr valign="top" style="<?php if (get_option('pro_version_enabled')) { echo 'display: none;'; } ?>">
|
708 |
<th scope="row">
|
709 |
Activation Code
|
710 |
</th>
|
711 |
<td>
|
712 |
+
<input type="text" style="border: 2px solid gold;border-radius: 5px;" id="pro_version_activation_code" name="pro_version_activation_code" value="<?php echo get_option('pro_version_activation_code'); ?>" />
|
713 |
</td>
|
714 |
</tr>
|
715 |
<!-- Permissions -->
|
723 |
<div id="simple_banner_pro_permissions">
|
724 |
<?php
|
725 |
$roles = get_editable_roles();
|
726 |
+
$disabled = !get_option('pro_version_enabled');
|
727 |
+
$permissions_array = get_option('permissions_array');
|
728 |
foreach (get_editable_roles() as $role_name => $role_info) {
|
729 |
if ($role_name == 'administrator') {
|
730 |
continue;
|
745 |
</tr>
|
746 |
<?php endif; ?>
|
747 |
<?php
|
748 |
+
if (get_option('pro_version_enabled')) {
|
749 |
+
echo '<input type="text" hidden id="permissions_array" name="permissions_array" value="'. get_option('permissions_array') . '" />';
|
750 |
}
|
751 |
?>
|
752 |
<!-- Disabled on Psts -->
|
761 |
</th>
|
762 |
<td style="padding-top:0;">
|
763 |
<?php
|
764 |
+
if (get_option('pro_version_enabled')) {
|
765 |
+
$checked = get_option('disabled_on_posts') ? 'checked ' : '';
|
766 |
echo '<input type="checkbox" id="disabled_on_posts" '. $checked . ' name="disabled_on_posts" />';
|
767 |
} else {
|
768 |
echo '<input type="checkbox" disabled />';
|
779 |
<td>
|
780 |
<div id="simple_banner_pro_disabled_pages">
|
781 |
<?php
|
782 |
+
$disabled = !get_option('pro_version_enabled');
|
783 |
+
$disabled_pages_array = array_filter(explode(',', get_option('disabled_pages_array')));
|
784 |
+
$frontpage_id = get_option( 'page_on_front' ); // page_on_front returns 0 if value hasn't been set
|
785 |
if ($frontpage_id == 0) {
|
786 |
$frontpage_id = 1;
|
787 |
}
|
789 |
$parent_checkbox .= $disabled ? 'disabled ' : '';
|
790 |
$parent_checkbox .= (!$disabled && in_array($frontpage_id, $disabled_pages_array)) ? 'checked ' : '';
|
791 |
$parent_checkbox .= 'value="' . $frontpage_id . '">';
|
792 |
+
$parent_checkbox .= get_option( 'blogname' ) . ' | ' . get_site_url() . ' ';
|
793 |
$parent_checkbox .= '</input><br>';
|
794 |
echo $parent_checkbox;
|
795 |
|
808 |
?>
|
809 |
</div>
|
810 |
<?php
|
811 |
+
if (get_option('pro_version_enabled')) {
|
812 |
+
echo '<input type="text" hidden id="disabled_pages_array" name="disabled_pages_array" value="'. get_option('disabled_pages_array') . '" />';
|
813 |
}
|
814 |
?>
|
815 |
</td>
|
822 |
</th>
|
823 |
<td>
|
824 |
<?php
|
825 |
+
if (get_option('pro_version_enabled')) {
|
826 |
+
echo '<textarea id="site_custom_css" style="height: 150px;width: 75%;" name="site_custom_css">'. get_option('site_custom_css') . '</textarea>';
|
827 |
} else {
|
828 |
echo '<textarea style="height: 150px;width: 75%;" disabled></textarea>';
|
829 |
}
|
836 |
</th>
|
837 |
<td style="padding-top:0;">
|
838 |
<?php
|
839 |
+
if (get_option('pro_version_enabled')) {
|
840 |
+
$checked = get_option('keep_site_custom_css') ? 'checked ' : '';
|
841 |
echo '<input type="checkbox" id="keep_site_custom_css" '. $checked . ' name="keep_site_custom_css" />';
|
842 |
} else {
|
843 |
echo '<input type="checkbox" disabled />';
|
853 |
</th>
|
854 |
<td>
|
855 |
<?php
|
856 |
+
if (get_option('pro_version_enabled')) {
|
857 |
+
echo '<textarea id="site_custom_js" style="height: 150px;width: 75%;" name="site_custom_js">'. get_option('site_custom_js') . '</textarea>';
|
858 |
} else {
|
859 |
echo '<textarea style="height: 150px;width: 75%;" disabled></textarea>';
|
860 |
}
|
867 |
</th>
|
868 |
<td style="padding-top:0;">
|
869 |
<?php
|
870 |
+
if (get_option('pro_version_enabled')) {
|
871 |
+
$checked = get_option('keep_site_custom_js') ? 'checked ' : '';
|
872 |
echo '<input type="checkbox" id="keep_site_custom_js" '. $checked . ' name="keep_site_custom_js" />';
|
873 |
} else {
|
874 |
echo '<input type="checkbox" disabled />';
|
884 |
</th>
|
885 |
<td>
|
886 |
<?php
|
887 |
+
if (get_option('pro_version_enabled')) {
|
888 |
+
$checked = get_option('debug_mode') ? 'checked ' : '';
|
889 |
echo '<input type="checkbox" id="debug_mode" '. $checked . ' name="debug_mode" />';
|
890 |
} else {
|
891 |
echo '<input type="checkbox" disabled />';
|
936 |
var style_custom_button_css = document.createElement('style');
|
937 |
|
938 |
// Banner Text
|
939 |
+
var hrefRegex = /href\=[\'\"](.*)[\'\"]/si;
|
940 |
+
var scriptStyleRegex = /<(script|style)[^>]*?>.*?<\/(script|style)>/si;
|
941 |
+
function stripBannerText(string) {
|
942 |
+
let strippedString = string;
|
943 |
+
while (strippedString.match(scriptStyleRegex)) {
|
944 |
+
strippedString = strippedString.replace(scriptStyleRegex, '')
|
945 |
+
};
|
946 |
+
return strippedString.replace(hrefRegex, "href=\"https://$1\"");
|
947 |
+
}
|
948 |
document.getElementById('preview_banner_text').innerHTML = document.getElementById('simple_banner_text').value != "" ?
|
949 |
+
'<span>'+stripBannerText(document.getElementById('simple_banner_text').value)+'</span>' :
|
950 |
'<span>This is what your banner will look like with a <a href="/">link</a>.</span>';
|
951 |
document.getElementById('simple_banner_text').onchange=function(e){
|
952 |
+
document.getElementById('preview_banner_text').innerHTML = e.target.value != "" ? '<span>'+stripBannerText(e.target.value)+'</span>' : '<span>This is what your banner will look like with a <a href="/">link</a>.</span>';
|
953 |
};
|
954 |
|
955 |
// Close Button
|