PluginProbe
YayMail – WooCommerce Email Customizer / trunk
YayMail – WooCommerce Email Customizer vtrunk
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 3.4.2 3.4.3 All 55 releases
yaymail / src / Notices / Ajax.php

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

59 lines 2.2 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 wp_send_json_error( [ 'mess' => $error->getMessage() ] );
35 } catch ( \Exception $exception ) {
36 yaymail_get_logger( $exception );
37 wp_send_json_error( [ 'mess' => $exception->getMessage() ] );
38 }
39 }
40
41 public function yaymail_dismiss_upgrade_notice() {
42 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
43 if ( ! wp_verify_nonce( $nonce, 'yaymail_nonce' ) ) {
44 return wp_send_json_error( [ 'mess' => __( 'Verify nonce failed', 'yaymail' ) ] );
45 }
46 try {
47 // The Notice should comeback after 60 days
48 update_option( 'yaymail_next_recommendation_upgrade_notice_time', time() + 60 * 60 * 24 * 60 );
49 wp_send_json_success();
50 } catch ( \Error $error ) {
51 yaymail_get_logger( $error );
52 wp_send_json_error( [ 'mess' => $error->getMessage() ] );
53 } catch ( \Exception $exception ) {
54 yaymail_get_logger( $exception );
55 wp_send_json_error( [ 'mess' => $exception->getMessage() ] );
56 }
57 }
58 }
59