← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Notification.php
+11
-4
3.1.3
→
3.5.0
View file →
| @@ -83,9 +83,9 @@ | ||
| 83 | 83 | } |
| 84 | 84 | $notification_html = self::get_notification_html( $notification_details ); |
| 85 | 85 | do_action( $notification_details['id'] . '_before_render' ); |
| 86 | 86 | |
| 87 | - echo $notification_html; | |
| 87 | + echo $notification_html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, already escaped internally. | |
| 88 | 88 | |
| 89 | 89 | do_action( $notification_details['id'] . '_after_render' ); |
| 90 | 90 | self::render_snippets(); |
| 91 | 91 | } |
| @@ -225,9 +225,9 @@ | ||
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * Get last notification details. |
| 228 | 228 | * |
| 229 | - * @return array Last notification details. | |
| 229 | + * @return int Last notification details. | |
| 230 | 230 | */ |
| 231 | 231 | private static function get_last_active_notification_timestamp() { |
| 232 | 232 | $notification = self::get_notifications_metadata(); |
| 233 | 233 | |
| @@ -339,9 +339,9 @@ | ||
| 339 | 339 | } |
| 340 | 340 | $.post( |
| 341 | 341 | ajaxurl, |
| 342 | 342 | { |
| 343 | - 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>', | |
| 343 | + 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>', | |
| 344 | 344 | 'action': 'themeisle_sdk_dismiss_notice', |
| 345 | 345 | 'id': notification_id, |
| 346 | 346 | 'confirm': confirm |
| 347 | 347 | } |
| @@ -364,9 +364,9 @@ | ||
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | 366 | * Dismiss the notification. |
| 367 | 367 | */ |
| 368 | - static function dismiss() { | |
| 368 | + public static function dismiss() { | |
| 369 | 369 | check_ajax_referer( (string) __CLASS__, 'nonce' ); |
| 370 | 370 | |
| 371 | 371 | $id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : ''; |
| 372 | 372 | $confirm = isset( $_POST['confirm'] ) ? sanitize_text_field( $_POST['confirm'] ) : 'no'; |
| @@ -373,8 +373,12 @@ | ||
| 373 | 373 | |
| 374 | 374 | if ( empty( $id ) ) { |
| 375 | 375 | wp_send_json( [] ); |
| 376 | 376 | } |
| 377 | + $ids = wp_list_pluck( self::$notifications, 'id' ); | |
| 378 | + if ( ! in_array( $id, $ids, true ) ) { | |
| 379 | + wp_send_json( [] ); | |
| 380 | + } | |
| 377 | 381 | self::set_last_active_notification_timestamp(); |
| 378 | 382 | update_option( $id, $confirm ); |
| 379 | 383 | do_action( $id . '_process_confirm', $confirm ); |
| 380 | 384 | wp_send_json( [] ); |
| @@ -429,8 +433,11 @@ | ||
| 429 | 433 | * |
| 430 | 434 | * @return Notification Module instance. |
| 431 | 435 | */ |
| 432 | 436 | public function load( $product ) { |
| 437 | + if ( apply_filters( 'themeisle_sdk_hide_notifications', false ) ) { | |
| 438 | + return; | |
| 439 | + } | |
| 433 | 440 | $this->product = $product; |
| 434 | 441 | |
| 435 | 442 | $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] ); |
| 436 | 443 | $notifications = array_filter( |