# yaymail/trunk/src/Notices/Ajax.php

YayMail – WooCommerce Email Customizer, version trunk. 59 lines.

- Page: https://pluginprobe.com/plugins/yaymail/trunk/code/src/Notices/Ajax.php
- Raw: https://pluginprobe.com/plugins/yaymail/trunk/raw/src/Notices/Ajax.php
- Modified: 2026-08-23T09:24:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/yaymail/trunk/code/src/Notices/Ajax.php#L10-L20`.

```php
<?php

namespace YayMail\Notices;

use YayMail\Utils\SingletonTrait;

/**
 *
 * @method static Ajax get_instance()
 */
class Ajax {
    use SingletonTrait;

    protected function __construct() {
        $this->init_hooks();
    }

    protected function init_hooks() {
        add_action( 'wp_ajax_yaymail_dismiss_suggest_addons_notice', [ $this, 'yaymail_dismiss_suggest_addons_notice' ] );
        add_action( 'wp_ajax_yaymail_dismiss_upgrade_notice', [ $this, 'yaymail_dismiss_upgrade_notice' ] );
    }

    public function yaymail_dismiss_suggest_addons_notice() {
        $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
        if ( ! wp_verify_nonce( $nonce, 'yaymail_nonce' ) ) {
            return wp_send_json_error( [ 'mess' => __( 'Verify nonce failed', 'yaymail' ) ] );
        }
        try {
            // The Notice should comeback after 60 days
            update_option( 'yaymail_next_recommendation_suggest_addons_notice_time', time() + 60 * 60 * 24 * 60 );
            wp_send_json_success();
        } catch ( \Error $error ) {
            yaymail_get_logger( $error );
            wp_send_json_error( [ 'mess' => $error->getMessage() ] );
        } catch ( \Exception $exception ) {
            yaymail_get_logger( $exception );
            wp_send_json_error( [ 'mess' => $exception->getMessage() ] );
        }
    }

    public function yaymail_dismiss_upgrade_notice() {
        $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
        if ( ! wp_verify_nonce( $nonce, 'yaymail_nonce' ) ) {
            return wp_send_json_error( [ 'mess' => __( 'Verify nonce failed', 'yaymail' ) ] );
        }
        try {
            // The Notice should comeback after 60 days
            update_option( 'yaymail_next_recommendation_upgrade_notice_time', time() + 60 * 60 * 24 * 60 );
            wp_send_json_success();
        } catch ( \Error $error ) {
            yaymail_get_logger( $error );
            wp_send_json_error( [ 'mess' => $error->getMessage() ] );
        } catch ( \Exception $exception ) {
            yaymail_get_logger( $exception );
            wp_send_json_error( [ 'mess' => $exception->getMessage() ] );
        }
    }
}

```
