@@ 448-470 (lines=23) @@ | ||
445 | * |
|
446 | * @return bool |
|
447 | */ |
|
448 | private function restore_user( $id ) { |
|
449 | ||
450 | $id = self::$instance->get_id( $id ); |
|
451 | $notice = self::$instance->get_notice( $id ); |
|
452 | ||
453 | if ( false === $notice ) { |
|
454 | return false; |
|
455 | } |
|
456 | ||
457 | $dismissed = self::$instance->dismissed_user(); |
|
458 | ||
459 | if ( ! in_array( $id, $dismissed ) ) { |
|
460 | return false; |
|
461 | } |
|
462 | ||
463 | $flip = array_flip( $dismissed ); |
|
464 | $key = $flip[ $id ]; |
|
465 | ||
466 | unset( $dismissed[ $key ] ); |
|
467 | ||
468 | return update_user_meta( get_current_user_id(), 'dnh_dismissed_notices', $dismissed ); |
|
469 | ||
470 | } |
|
471 | ||
472 | /** |
|
473 | * Restore a notice dismissed globally |
|
@@ 481-503 (lines=23) @@ | ||
478 | * |
|
479 | * @return bool |
|
480 | */ |
|
481 | private function restore_global( $id ) { |
|
482 | ||
483 | $id = self::$instance->get_id( $id ); |
|
484 | $notice = self::$instance->get_notice( $id ); |
|
485 | ||
486 | if ( false === $notice ) { |
|
487 | return false; |
|
488 | } |
|
489 | ||
490 | $dismissed = self::$instance->dismissed_global(); |
|
491 | ||
492 | if ( ! in_array( $id, $dismissed ) ) { |
|
493 | return false; |
|
494 | } |
|
495 | ||
496 | $flip = array_flip( $dismissed ); |
|
497 | $key = $flip[ $id ]; |
|
498 | ||
499 | unset( $dismissed[ $key ] ); |
|
500 | ||
501 | return update_option( 'dnh_dismissed_notices', $dismissed ); |
|
502 | ||
503 | } |
|
504 | ||
505 | /** |
|
506 | * Get all dismissed notices |