@@ 465-487 (lines=23) @@ | ||
462 | * |
|
463 | * @return bool |
|
464 | */ |
|
465 | private function restore_user( $id ) { |
|
466 | ||
467 | $id = self::$instance->get_id( $id ); |
|
468 | $notice = self::$instance->get_notice( $id ); |
|
469 | ||
470 | if ( false === $notice ) { |
|
471 | return false; |
|
472 | } |
|
473 | ||
474 | $dismissed = self::$instance->dismissed_user(); |
|
475 | ||
476 | if ( ! in_array( $id, $dismissed ) ) { |
|
477 | return false; |
|
478 | } |
|
479 | ||
480 | $flip = array_flip( $dismissed ); |
|
481 | $key = $flip[ $id ]; |
|
482 | ||
483 | unset( $dismissed[ $key ] ); |
|
484 | ||
485 | return update_user_meta( get_current_user_id(), 'dnh_dismissed_notices', $dismissed ); |
|
486 | ||
487 | } |
|
488 | ||
489 | /** |
|
490 | * Restore a notice dismissed globally |
|
@@ 498-520 (lines=23) @@ | ||
495 | * |
|
496 | * @return bool |
|
497 | */ |
|
498 | private function restore_global( $id ) { |
|
499 | ||
500 | $id = self::$instance->get_id( $id ); |
|
501 | $notice = self::$instance->get_notice( $id ); |
|
502 | ||
503 | if ( false === $notice ) { |
|
504 | return false; |
|
505 | } |
|
506 | ||
507 | $dismissed = self::$instance->dismissed_global(); |
|
508 | ||
509 | if ( ! in_array( $id, $dismissed ) ) { |
|
510 | return false; |
|
511 | } |
|
512 | ||
513 | $flip = array_flip( $dismissed ); |
|
514 | $key = $flip[ $id ]; |
|
515 | ||
516 | unset( $dismissed[ $key ] ); |
|
517 | ||
518 | return update_option( 'dnh_dismissed_notices', $dismissed ); |
|
519 | ||
520 | } |
|
521 | ||
522 | /** |
|
523 | * Get all dismissed notices |