PluginProbe
Order Tracking – WordPress Status Tracking Plugin / 3.2.2
Order Tracking – WordPress Status Tracking Plugin v3.2.2
3.5.4 3.5.3 3.5.2 3.5.1 3.5.0 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.3.0 3.3.1 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 All 235 releases
order-tracking / includes / ReviewAsk.class.php

ReviewAsk.class.php in Order Tracking – WordPress Status Tracking Plugin 3.2.2, at includes/ReviewAsk.class.php

129 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit;
3
4 if ( ! class_exists( 'ewdotpReviewAsk' ) ) {
5 /**
6 * Class to handle plugin review ask
7 *
8 * @since 3.0.0
9 */
10 class ewdotpReviewAsk {
11
12 public function __construct() {
13
14 add_action( 'admin_notices', array( $this, 'maybe_add_review_ask' ) );
15
16 add_action( 'wp_ajax_ewd_otp_hide_review_ask', array( $this, 'hide_review_ask' ) );
17 add_action( 'wp_ajax_ewd_otp_send_feedback', array( $this, 'send_feedback' ) );
18
19 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_review_ask_scripts' ) );
20 }
21
22 public function maybe_add_review_ask() {
23
24 $ask_review_time = get_option( 'ewd-otp-review-ask-time' );
25
26 $install_time = get_option( 'ewd-otp-installation-time' );
27 if ( ! $install_time ) { update_option( 'ewd-otp-installation-time', time() ); $install_time = time(); }
28
29 $ask_review_time = $ask_review_time != '' ? $ask_review_time : $install_time + 3600*24*4;
30
31 if ( $ask_review_time < time() and $install_time != '' and $install_time < time() - 3600*24*4 ) {
32
33 global $pagenow;
34
35 if ( $pagenow != 'post.php' && $pagenow != 'post-new.php' ) { ?>
36
37 <div class='notice notice-info is-dismissible ewd-otp-main-dashboard-review-ask' style='display:none'>
38 <div class='ewd-otp-review-ask-plugin-icon'></div>
39 <div class='ewd-otp-review-ask-text'>
40 <p class='ewd-otp-review-ask-starting-text'>Enjoying using the Order Tracking?</p>
41 <p class='ewd-otp-review-ask-feedback-text ewd-otp-hidden'>Help us make the plugin better! Please take a minute to rate the plugin. Thanks!</p>
42 <p class='ewd-otp-review-ask-review-text ewd-otp-hidden'>Please let us know what we could do to make the plugin better!<br /><span>(If you would like a response, please include your email address.)</span></p>
43 <p class='ewd-otp-review-ask-thank-you-text ewd-otp-hidden'>Thank you for taking the time to help us!</p>
44 </div>
45 <div class='ewd-otp-review-ask-actions'>
46 <div class='ewd-otp-review-ask-action ewd-otp-review-ask-not-really ewd-otp-review-ask-white'>Not Really</div>
47 <div class='ewd-otp-review-ask-action ewd-otp-review-ask-yes ewd-otp-review-ask-green'>Yes!</div>
48 <div class='ewd-otp-review-ask-action ewd-otp-review-ask-no-thanks ewd-otp-review-ask-white ewd-otp-hidden'>No Thanks</div>
49 <a href='https://wordpress.org/support/plugin/order-tracking/reviews/' target='_blank'>
50 <div class='ewd-otp-review-ask-action ewd-otp-review-ask-review ewd-otp-review-ask-green ewd-otp-hidden'>OK, Sure</div>
51 </a>
52 </div>
53 <div class='ewd-otp-review-ask-feedback-form ewd-otp-hidden'>
54 <div class='ewd-otp-review-ask-feedback-explanation'>
55 <textarea></textarea>
56 <br>
57 <input type="email" name="feedback_email_address" placeholder="<?php _e('Email Address', 'order-tracking'); ?>">
58 </div>
59 <div class='ewd-otp-review-ask-send-feedback ewd-otp-review-ask-action ewd-otp-review-ask-green'>Send Feedback</div>
60 </div>
61 <div class='ewd-otp-clear'></div>
62 </div>
63
64 <?php
65 }
66 }
67 else {
68 wp_dequeue_script( 'ewd-otp-review-ask-js' );
69 wp_dequeue_style( 'ewd-otp-review-ask-css' );
70 }
71 }
72
73 public function enqueue_review_ask_scripts() {
74
75 wp_enqueue_style( 'ewd-otp-review-ask-css', EWD_OTP_PLUGIN_URL . '/assets/css/dashboard-review-ask.css' );
76 wp_enqueue_script( 'ewd-otp-review-ask-js', EWD_OTP_PLUGIN_URL . '/assets/js/dashboard-review-ask.js', array( 'jquery' ), EWD_OTP_VERSION, true );
77
78 wp_localize_script(
79 'ewd-otp-review-ask-js',
80 'ewd_otp_review_ask',
81 array(
82 'nonce' => wp_create_nonce( 'ewd-otp-review-ask-js' )
83 )
84 );
85 }
86
87 public function hide_review_ask() {
88 global $ewd_otp_controller;
89
90 // Authenticate request
91 if (
92 ! check_ajax_referer( 'ewd-otp-review-ask-js', 'nonce' )
93 or ! current_user_can( $ewd_otp_controller->settings->get_setting( 'access-role' ) )
94 ) {
95 ewdotpHelper::admin_nopriv_ajax();
96 }
97
98 $ask_review_time = intval( $_POST['ask_review_time'] );
99
100 if ( get_option( 'ewd-otp-review-ask-time' ) < time() + 3600*24 * $ask_review_time ) {
101 update_option( 'ewd-otp-review-ask-time', time() + 3600*24 * $ask_review_time );
102 }
103
104 die();
105 }
106
107 public function send_feedback() {
108 global $ewd_otp_controller;
109
110 // Authenticate request
111 if (
112 ! check_ajax_referer( 'ewd-otp-review-ask-js', 'nonce' )
113 or ! current_user_can( $ewd_otp_controller->settings->get_setting( 'access-role' ) )
114 ) {
115 ewdotpHelper::admin_nopriv_ajax();
116 }
117
118 $headers = 'Content-type: text/html;charset=utf-8' . "\r\n";
119 $feedback = sanitize_text_field( $_POST['feedback'] );
120 $feedback .= '<br /><br />Email Address: ';
121 $feedback .= sanitize_email( $_POST['email_address'] );
122
123 wp_mail('contact@etoilewebdesign.com', 'OTP Feedback - Dashboard Form', $feedback, $headers);
124
125 die();
126 }
127 }
128
129 }