PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.10
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/codeinwp/themeisle-sdk/src/Modules/Notification.php +69 -10 3.1.33.11.10 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
@@ -255,8 +255,9 @@
255 255 public static function get_notification_html( $notification_details ) {
256 256 $default = [
257 257 'id' => '',
258 258 'heading' => '',
259 + 'img_src' => '',
259 260 'message' => '',
260 261 'ctas' => [
261 262 'confirm' => [
262 263 'link' => '#',
@@ -266,18 +267,28 @@
266 267 'link' => '#',
267 268 'text' => '',
268 269 ],
269 270 ],
271 + 'type' => 'success',
270 272 ];
271 273 $notification_details = wp_parse_args( $notification_details, $default );
274 + global $pagenow;
275 + $type = in_array( $notification_details['type'], [ 'success', 'info', 'warning', 'error' ], true ) ? $notification_details['type'] : 'success';
276 + $notification_details['ctas']['cancel']['link'] = wp_nonce_url( add_query_arg( [ 'nid' => $notification_details['id'] ], admin_url( $pagenow ) ), $notification_details['id'], 'tsdk_dismiss_nonce' );
277 + $notification_html = '<div class="notice notice-' . $type . ' is-dismissible themeisle-sdk-notice" data-notification-id="' . esc_attr( $notification_details['id'] ) . '" id="' . esc_attr( $notification_details['id'] ) . '-notification"> <div class="themeisle-sdk-notification-box">';
272 278
273 - $notification_html = '<div class="notice notice-success is-dismissible themeisle-sdk-notice" data-notification-id="' . esc_attr( $notification_details['id'] ) . '" id="' . esc_attr( $notification_details['id'] ) . '-notification"> <div class="themeisle-sdk-notification-box">';
274 -
275 279 if ( ! empty( $notification_details['heading'] ) ) {
276 280 $notification_html .= sprintf( '<h4>%s</h4>', wp_kses_post( $notification_details['heading'] ) );
277 281 }
282 + if ( ! empty( $notification_details['img_src'] ) ) {
283 + $notification_html .= '<div class="wrap-flex">';
284 + $notification_html .= sprintf( '<img src="%s" alt="%s" />', esc_attr( $notification_details['img_src'] ), esc_attr( $notification_details['heading'] ) );
285 + }
278 286 if ( ! empty( $notification_details['message'] ) ) {
279 287 $notification_html .= wp_kses_post( $notification_details['message'] );
288 + if ( ! empty( $notification_details['img_src'] ) ) {
289 + $notification_html .= '</div>';
290 + }
280 291 }
281 292 $notification_html .= '<div class="actions">';
282 293
283 294 if ( ! empty( $notification_details['ctas']['confirm']['text'] ) ) {
@@ -315,8 +326,20 @@
315 326 .themeisle-sdk-notification-box {
316 327 padding: 3px;
317 328 }
318 329
330 + .themeisle-sdk-notification-box .wrap-flex {
331 + display: flex;
332 + align-items: center;
333 + justify-content: start;
334 + gap: 12px;
335 + }
336 +
337 + .themeisle-sdk-notification-box .wrap-flex img {
338 + width: 42px;
339 + object-fit: cover;
340 + }
341 +
319 342 .themeisle-sdk-notification-box .actions {
320 343 margin-top: 6px;
321 344 margin-bottom: 4px;
322 345 }
@@ -339,14 +362,16 @@
339 362 }
340 363 $.post(
341 364 ajaxurl,
342 365 {
343 - 'nonce': '<?php echo wp_create_nonce( (string) __CLASS__ ); ?>',
366 + 'nonce': '<?php echo esc_attr( wp_create_nonce( (string) __CLASS__ ) ); ?>',
344 367 'action': 'themeisle_sdk_dismiss_notice',
345 368 'id': notification_id,
346 - 'confirm': confirm
347 - }
348 - );
369 + 'confirm': confirm,
370 + },
371 + ).fail(function() {
372 + location.href = encodeURI(link.attr('href'));
373 + });
349 374 if (confirm === 'yes') {
350 375 $(this).trigger('themeisle-sdk:confirmed');
351 376 } else {
352 377 $(this).trigger('themeisle-sdk:canceled');
@@ -351,9 +376,9 @@
351 376 } else {
352 377 $(this).trigger('themeisle-sdk:canceled');
353 378 }
354 379 container.hide();
355 - if (link.attr('href') === '#') {
380 + if (confirm === 'no' || link.attr('href') === '#') {
356 381 return false;
357 382 }
358 383 });
359 384 });
@@ -364,9 +389,9 @@
364 389
365 390 /**
366 391 * Dismiss the notification.
367 392 */
368 - static function dismiss() {
393 + public static function dismiss() {
369 394 check_ajax_referer( (string) __CLASS__, 'nonce' );
370 395
371 396 $id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : '';
372 397 $confirm = isset( $_POST['confirm'] ) ? sanitize_text_field( $_POST['confirm'] ) : 'no';
@@ -373,13 +398,43 @@
373 398
374 399 if ( empty( $id ) ) {
375 400 wp_send_json( [] );
376 401 }
402 + self::setup_notifications();
403 + $ids = wp_list_pluck( self::$notifications, 'id' );
404 + if ( ! in_array( $id, $ids, true ) ) {
405 + wp_send_json( [] );
406 + }
377 407 self::set_last_active_notification_timestamp();
378 408 update_option( $id, $confirm );
379 409 do_action( $id . '_process_confirm', $confirm );
380 410 wp_send_json( [] );
381 411 }
412 + /**
413 + * Dismiss the notification.
414 + */
415 + public static function dismiss_get() {
416 + $is_nonce_dismiss = sanitize_text_field( isset( $_GET['tsdk_dismiss_nonce'] ) ? $_GET['tsdk_dismiss_nonce'] : '' );
417 + if ( strlen( $is_nonce_dismiss ) < 5 ) {
418 + return;
419 + }
420 + $id = sanitize_text_field( isset( $_GET['nid'] ) ? $_GET['nid'] : '' );
421 + if ( empty( $id ) ) {
422 + return;
423 + }
424 + $nonce = wp_verify_nonce( sanitize_text_field( $_GET['tsdk_dismiss_nonce'] ), $id );
425 + if ( $nonce !== 1 ) {
426 + return;
427 + }
428 + $ids = wp_list_pluck( self::$notifications, 'id' );
429 + if ( ! in_array( $id, $ids, true ) ) {
430 + return;
431 + }
432 + $confirm = 'no';
433 + self::set_last_active_notification_timestamp();
434 + update_option( $id, $confirm );
435 + do_action( $id . '_process_confirm', $confirm );
436 + }
382 437
383 438 /**
384 439 * Check if we should load the notification module.
385 440 *
@@ -429,8 +484,11 @@
429 484 *
430 485 * @return Notification Module instance.
431 486 */
432 487 public function load( $product ) {
488 + if ( apply_filters( 'themeisle_sdk_hide_notifications', false ) ) {
489 + return;
490 + }
433 491 $this->product = $product;
434 492
435 493 $notifications = apply_filters( 'themeisle_sdk_registered_notifications', [] );
436 494 $notifications = array_filter(
@@ -448,8 +506,9 @@
448 506 );
449 507 self::$notifications = $notifications;
450 508 add_action( 'admin_notices', array( __CLASS__, 'show_notification' ) );
451 509 add_action( 'wp_ajax_themeisle_sdk_dismiss_notice', array( __CLASS__, 'dismiss' ) );
510 + add_action( 'admin_head', array( __CLASS__, 'dismiss_get' ) );
452 511 add_action( 'admin_head', array( __CLASS__, 'setup_notifications' ) );
453 512
454 513 return $this;
455 514 }