Skip to content

Commit c321318

Browse files
authored
Merge pull request #147 from brainstormforce/astra-notice-update
EPS-1150: Update Astra notices to latest
2 parents efa2311 + 5bb1b0d commit c321318

File tree

6 files changed

+95
-13
lines changed

6 files changed

+95
-13
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
**Donate link:** https://www.paypal.me/BrainstormForce
55
**Requires at least:** 3.6
66
**Tested up to:** 6.7
7-
**Stable tag:** 1.2.2
7+
**Stable tag:** 1.2.3
88
**License:** GPLv2 or later
99
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -97,6 +97,9 @@ href=”https://www.brainstormforce.com/go/brainstorm-force-twitter-page/?utm_so
9797

9898
## Changelog ##
9999

100+
### 1.2.3 ###
101+
- This update addressed a security bug. Please make sure you are using the latest version on your website.
102+
100103
### 1.2.2 ###
101104
- Improvement: WordPress 5.9 compatibility.
102105

bb-header-footer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Author URI: https://www.brainstormforce.com/
88
* Text Domain: bb-header-footer
99
* Domain Path: /languages
10-
* Version: 1.2.2
10+
* Version: 1.2.3
1111
*
1212
* @package BB_Header_Footer
1313
*/
@@ -17,7 +17,7 @@
1717
*/
1818
require_once 'class-bb-header-footer.php';
1919

20-
define( 'BBHF_VER', '1.2.2' );
20+
define( 'BBHF_VER', '1.2.3' );
2121
define( 'BBHF_DIR', plugin_dir_path( __FILE__ ) );
2222
define( 'BBHF_URL', plugins_url( '/', __FILE__ ) );
2323
define( 'BBHF_PATH', plugin_basename( __FILE__ ) );

lib/astra-notices/class-astra-notices.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Astra_Notices {
2828
* @var array Notices.
2929
* @since 1.0.0
3030
*/
31-
private static $version = '1.1.8';
31+
private static $version = '1.1.12';
3232

3333
/**
3434
* Notices
@@ -96,6 +96,12 @@ public function add_data_attributes( $allowedposttags, $context ) {
9696
*/
9797
public static function add_notice( $args = array() ) {
9898
self::$notices[] = $args;
99+
$notice_id = $args['id']; // Notice ID.
100+
$notices = get_option( 'allowed_astra_notices', array() );
101+
if(array_search($notice_id, $notices) === false) {
102+
$notices[] = $notice_id; // Add notice id to the array.
103+
update_option( 'allowed_astra_notices', $notices ); // Update the option.
104+
}
99105
}
100106

101107
/**
@@ -115,13 +121,33 @@ public function dismiss_notice() {
115121
return;
116122
}
117123

124+
$allowed_notices = get_option( 'allowed_astra_notices', array() ); // Get allowed notices.
125+
126+
// Define restricted user meta keys
127+
$wp_default_meta_keys = array(
128+
'wp_capabilities',
129+
'wp_user_level',
130+
'wp_user-settings',
131+
'account_status',
132+
'session_tokens',
133+
);
134+
135+
// Verify that the notice being dismissed is in the list of allowed notices.
136+
if(array_search($notice_id, $allowed_notices) === false) {
137+
return;
138+
}
139+
118140
if ( false === wp_verify_nonce( $nonce, 'astra-notices' ) ) {
119141
wp_send_json_error( esc_html_e( 'WordPress Nonce not validated.' ) );
120142
}
121143

122144
// Valid inputs?
123145
if ( ! empty( $notice_id ) ) {
124146

147+
if ( in_array( $notice_id, $wp_default_meta_keys, true ) ) {
148+
wp_send_json_error( esc_html_e( 'Invalid notice ID.' ) );
149+
}
150+
125151
if ( ! empty( $repeat_notice_after ) ) {
126152
set_transient( $notice_id, true, $repeat_notice_after );
127153
} else {
@@ -141,6 +167,7 @@ public function dismiss_notice() {
141167
* @return void
142168
*/
143169
public function enqueue_scripts() {
170+
wp_register_style( 'astra-notices', self::get_url() . 'notices.css', array(), self::$version );
144171
wp_register_script( 'astra-notices', self::get_url() . 'notices.js', array( 'jquery' ), self::$version, true );
145172
wp_localize_script(
146173
'astra-notices',
@@ -269,14 +296,15 @@ public function show_notices() {
269296
*/
270297
public static function markup( $notice = array() ) {
271298
wp_enqueue_script( 'astra-notices' );
299+
wp_enqueue_style( 'astra-notices' );
272300

273301
do_action( 'astra_notice_before_markup' );
274302

275303
do_action( "astra_notice_before_markup_{$notice['id']}" );
276304

277305
?>
278-
<div id="<?php echo esc_attr( $notice['id'] ); ?>" class="<?php echo esc_attr( $notice['classes'] ); ?>" data-repeat-notice-after="<?php echo esc_attr( $notice['repeat-notice-after'] ); ?>">
279-
<div class="notice-container">
306+
<div id="<?php echo esc_attr( $notice['id'] ); ?>" class="<?php echo 'astra-notice-wrapper ' . esc_attr( $notice['classes'] ); ?>" data-repeat-notice-after="<?php echo esc_attr( $notice['repeat-notice-after'] ); ?>">
307+
<div class="astra-notice-container">
280308
<?php do_action( "astra_notice_inside_markup_{$notice['id']}" ); ?>
281309
<?php echo wp_kses_post( $notice['message'] ); ?>
282310
</div>

lib/astra-notices/composer.json

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,32 @@
22
"name": "brainstormforce/astra-notices",
33
"type": "wordpress-plugin",
44
"description": "Easily create admin notices",
5-
"version": "1.1.8",
6-
"license": "GPL v3",
5+
"license": "GPL-3.0-or-later",
76
"authors": [
87
{
98
"name": "Brainstorm Force",
109
"email": "hello@bsf.io"
1110
}
1211
],
1312
"require": {
14-
"composer/installers": "^1.11"
13+
"composer/installers": "^2.0"
1514
},
1615
"require-dev": {
1716
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
18-
"phpcompatibility/phpcompatibility-wp": "^2.1",
19-
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5",
17+
"phpcompatibility/phpcompatibility-wp": "*",
18+
"phpunit/phpunit": "^9.0",
2019
"wp-cli/dist-archive-command": "^2.0",
21-
"wp-coding-standards/wpcs": "^2.3"
20+
"wp-coding-standards/wpcs": "^2.3",
21+
"wp-phpunit/wp-phpunit": "^6.0",
22+
"roots/wordpress": "^6.0",
23+
"yoast/phpunit-polyfills": "^1.0"
24+
},
25+
"config": {
26+
"allow-plugins": {
27+
"composer/installers": true,
28+
"dealerdirect/phpcodesniffer-composer-installer": true,
29+
"roots/wordpress-core-installer": true
30+
}
2231
},
2332
"minimum-stability": "stable",
2433
"scripts": {

lib/astra-notices/notices.css

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.astra-review-notice-container {
2+
display: flex;
3+
align-items: center;
4+
padding-top: 10px;
5+
}
6+
7+
.astra-review-notice-container .dashicons {
8+
font-size: 1.4em;
9+
padding-left: 10px;
10+
}
11+
12+
.astra-review-notice-container a {
13+
padding-left: 5px;
14+
text-decoration: none;
15+
}
16+
17+
.astra-review-notice-container .dashicons:first-child {
18+
padding-left: 0;
19+
}
20+
21+
.astra-notice-container .notice-image img {
22+
max-width: 90px;
23+
}
24+
25+
.astra-notice-container .notice-content .notice-heading {
26+
padding-bottom: 5px;
27+
}
28+
29+
.astra-notice-container .notice-content {
30+
margin-left: 15px;
31+
}
32+
33+
.astra-notice-container {
34+
padding-top: 10px;
35+
padding-bottom: 10px;
36+
display: flex;
37+
justify-content: left;
38+
align-items: center;
39+
}

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: header footer for beaver builder, beaver builder addon, beaver builder, pa
44
Donate link: https://www.paypal.me/BrainstormForce
55
Requires at least: 3.6
66
Tested up to: 6.7
7-
Stable tag: 1.2.2
7+
Stable tag: 1.2.3
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -97,6 +97,9 @@ href=”https://www.brainstormforce.com/go/brainstorm-force-twitter-page/?utm_so
9797

9898
== Changelog ==
9999

100+
= 1.2.3 =
101+
- This update addressed a security bug. Please make sure you are using the latest version on your website.
102+
100103
= 1.2.2 =
101104
- Improvement: WordPress 5.9 compatibility.
102105

0 commit comments

Comments
 (0)