public function dismiss(string $key)
    {
        $notices = $this->get();

        if (!isset($notices[$key])) {
            return; // Nothing to do.
        } // No update necessary in this case.

        $notices[$key] = $this->normalize($notices[$key]);
        $notice        = &$notices[$key]; // By reference.

        if ($notice['recurs_every']) {
            ++$notice['_recurrences']; // Counter.
            // A recurring + persistent notice is counted/updated when it's dismissed.
            // i.e., Last recur time set to the time in which it is dismissed by a user.

            if ($notice['_recurrences'] < $notice['recurs_times']) {
                $notice['_last_recur_dismiss_time'] = time();
            } else {
                unset($notices[$key]); // Dequeue.
            }
        } else {
            unset($notices[$key]); // Dequeue.
        }
        $this->update($notices);
    }
public function dismiss(string $key)
    {
        $notices = $this->get();

        if (!isset($notices[$key])) {
            return; // Nothing to do.
        } // No update necessary in this case.

        $notices[$key] = $this->normalize($notices[$key]);
        $notice        = &$notices[$key]; // By reference.

        if ($notice['recurs_every']) {
            ++$notice['_recurrences']; // Counter.
            // A recurring + persistent notice is counted/updated when it's dismissed.
            // i.e., Last recur time set to the time in which it is dismissed by a user.

            if ($notice['_recurrences'] < $notice['recurs_times']) {
                $notice['_last_recur_dismiss_time'] = time();
            } else {
                unset($notices[$key]); // Dequeue.
            }
        } else {
            unset($notices[$key]); // Dequeue.
        }
        $this->update($notices);
    }
public function dismiss ( string $ key ) { $ notices = $ this -> get ( ) ; if ( ! isset ( $ notices [ $ key ] ) ) { return ; // Nothing to do. } // No update necessary in this case. $ notices [ $ key ] = $ this -> normalize ( $ notices [ $ key ] ) ; $ notice = & $ notices [ $ key ] ; // By reference. if ( $ notice [ 'recurs_every' ] ) { ++ $ notice [ '_recurrences' ] ; // Counter. // A recurring + persistent notice is counted/updated when it's dismissed. // i.e., Last recur time set to the time in which it is dismissed by a user. if ( $ notice [ '_recurrences' ] < $ notice [ 'recurs_times' ] ) { $ notice [ '_last_recur_dismiss_time' ] = time ( ) ; } else { unset ( $ notices [ $ key ] ) ; // Dequeue. } } else { unset ( $ notices [ $ key ] ) ; // Dequeue. } $ this -> update ( $ notices ) ; }
Dismiss a notice.

@since 160524 WP notices.

@param string $key A key to dismiss.
Dismiss a notice .