Gocodebox_Banner_Notifier::hide_notice()

Move the top notice to the archives if dismissed.


Source Source

File: libraries/banner-notifications/src/notifications.php

	function hide_notice() {
		global $current_user;

		if ( empty( $current_user ) ) {
			exit;
		}

		if ( ! isset( $_POST['notification_id'], $_POST['nonce'] ) ) {
			exit;
		}

		if ( ! wp_verify_nonce( $_POST['nonce'], $this->prefix . '_notification_dismiss_' . $_POST['notification_id'] ) ) {
			exit;
		}

		$notification_id = sanitize_text_field( $_POST['notification_id'] );

		$archived_notifications = get_user_meta( $current_user->ID, "{$this->prefix}_archived_notifications", true );

		if ( ! is_array( $archived_notifications ) ) {
			$archived_notifications = array();
		}

		$archived_notifications[ $notification_id ] = date_i18n( 'c' );

		update_user_meta( $current_user->ID, "{$this->prefix}_archived_notifications", $archived_notifications );
		exit;
	}

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.