@@ -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>
0 commit comments