PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.1
YayMail – WooCommerce Email Customizer v4.4.1
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
yaymail / src / Notices / Ajax.php

Ajax.php in YayMail – WooCommerce Email Customizer 4.4.1, at src/Notices/Ajax.php

55 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Notices;
4
5 use YayMail\Utils\SingletonTrait;
6
7 /**
8 *
9 * @method static Ajax get_instance()
10 */
11 class Ajax {
12 use SingletonTrait;
13
14 protected function __construct() {
15 $this->init_hooks();
16 }
17
18 protected function init_hooks() {
19 add_action( 'wp_ajax_yaymail_dismiss_suggest_addons_notice', [ $this, 'yaymail_dismiss_suggest_addons_notice' ] );
20 add_action( 'wp_ajax_yaymail_dismiss_upgrade_notice', [ $this, 'yaymail_dismiss_upgrade_notice' ] );
21 }
22
23 public function yaymail_dismiss_suggest_addons_notice() {
24 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
25 if ( ! wp_verify_nonce( $nonce, 'yaymail_nonce' ) ) {
26 return wp_send_json_error( [ 'mess' => __( 'Verify nonce failed', 'yaymail' ) ] );
27 }
28 try {
29 // The Notice should comeback after 60 days
30 update_option( 'yaymail_next_recommendation_suggest_addons_notice_time', time() + 60 * 60 * 24 * 60 );
31 wp_send_json_success();
32 } catch ( \Error $error ) {
33 yaymail_get_logger( $error );
34 } catch ( \Exception $exception ) {
35 yaymail_get_logger( $exception );
36 }
37 }
38
39 public function yaymail_dismiss_upgrade_notice() {
40 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
41 if ( ! wp_verify_nonce( $nonce, 'yaymail_nonce' ) ) {
42 return wp_send_json_error( [ 'mess' => __( 'Verify nonce failed', 'yaymail' ) ] );
43 }
44 try {
45 // The Notice should comeback after 60 days
46 update_option( 'yaymail_next_recommendation_upgrade_notice_time', time() + 60 * 60 * 24 * 60 );
47 wp_send_json_success();
48 } catch ( \Error $error ) {
49 yaymail_get_logger( $error );
50 } catch ( \Exception $exception ) {
51 yaymail_get_logger( $exception );
52 }
53 }
54 }
55