| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound -- Third-party vendor library, namespace cannot be changed | |
| 3 | 2 | namespace Oxaim\Libs; |
| 4 | 3 | |
| 5 | 4 | defined( 'ABSPATH' ) || exit; |
| 6 | 5 | |
| @@ -286,13 +285,11 @@ | ||
| 286 | 285 | }else{ |
| 287 | 286 | $expired = ''; |
| 288 | 287 | } |
| 289 | 288 | |
| 290 | - // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Vendor library global variable | |
| 291 | 289 | global $oxaim_lib_notice_list; |
| 292 | 290 | |
| 293 | 291 | if(!isset($oxaim_lib_notice_list[$this->notice_id])){ |
| 294 | - // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Vendor library global variable usage | |
| 295 | 292 | $oxaim_lib_notice_list[$this->notice_id] = __FILE__; |
| 296 | 293 | |
| 297 | 294 | // is transient expired? |
| 298 | 295 | if ( false === $expired || empty( $expired ) ) { |
| @@ -368,15 +365,13 @@ | ||
| 368 | 365 | add_action( 'admin_head', [ __CLASS__, 'enqueue_scripts' ] ); |
| 369 | 366 | } |
| 370 | 367 | |
| 371 | 368 | public static function dismiss_ajax_call() { |
| 372 | - check_ajax_referer( 'wpmet_notice_dismiss', 'nonce' ); | |
| 369 | + $post_arr = filter_input_array( INPUT_POST, FILTER_SANITIZE_STRING ); | |
| 370 | + $notice_id = ( isset( $post_arr['notice_id'] ) ) ? $post_arr['notice_id'] : ''; | |
| 371 | + $dismissible = ( isset( $post_arr['dismissible'] ) ) ? $post_arr['dismissible'] : ''; | |
| 372 | + $expired_time = ( isset( $post_arr['expired_time'] ) ) ? $post_arr['expired_time'] : ''; | |
| 373 | 373 | |
| 374 | - $post_arr = wp_unslash( $_POST ); | |
| 375 | - $notice_id = ( isset( $post_arr['notice_id'] ) ) ? sanitize_key( $post_arr['notice_id'] ) : ''; | |
| 376 | - $dismissible = ( isset( $post_arr['dismissible'] ) ) ? sanitize_text_field( $post_arr['dismissible'] ) : ''; | |
| 377 | - $expired_time = ( isset( $post_arr['expired_time'] ) ) ? absint( $post_arr['expired_time'] ) : 0; | |
| 378 | - | |
| 379 | 374 | if ( ! empty( $notice_id ) ) { |
| 380 | 375 | if ( 'user' === $dismissible ) { |
| 381 | 376 | update_user_meta( get_current_user_id(), $notice_id, true ); |
| 382 | 377 | } else { |
| @@ -389,9 +384,8 @@ | ||
| 389 | 384 | wp_send_json_error(); |
| 390 | 385 | } |
| 391 | 386 | |
| 392 | 387 | public static function enqueue_scripts() { |
| 393 | - $nonce = wp_create_nonce( 'wpmet_notice_dismiss' ); | |
| 394 | 388 | echo " |
| 395 | 389 | <script> |
| 396 | 390 | jQuery(document).ready(function ($) { |
| 397 | 391 | $( '.wpmet-notice.is-dismissible' ).on( 'click', '.notice-dismiss', function() { |
| @@ -411,9 +405,8 @@ | ||
| 411 | 405 | action : 'wpmet-notices', |
| 412 | 406 | notice_id : notice_id, |
| 413 | 407 | dismissible : dismissible, |
| 414 | 408 | expired_time : expired_time, |
| 415 | - nonce : '" . esc_js( $nonce ) . "', | |
| 416 | 409 | }, |
| 417 | 410 | }); |
| 418 | 411 | }); |
| 419 | 412 | }); |