PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.0.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.0.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / inc / classes / feedback.php

feedback.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.0.9, at inc/classes/feedback.php

249 lines 10.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Inc\Classes;
4
5 use MasterAddons\Inc\Classes\Notifications\Base\User_Data;
6
7 // No, Direct access Sir !!!
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11
12 /**
13 * Feedback
14 *
15 * @author Jewel Theme <support@jeweltheme.com>
16 */
17 if (!class_exists('MasterAddons\Inc\Classes\Feedback')) {
18 class Feedback
19 {
20
21 use User_Data;
22
23 /**
24 * Construct Method
25 *
26 * @return void
27 * @author Jewel Theme <support@jeweltheme.com>
28 */
29 public function __construct()
30 {
31 add_action('admin_enqueue_scripts', [$this, 'admin_suvery_scripts']);
32 add_action('admin_footer', [$this, 'deactivation_footer']);
33 add_action('wp_ajax_jltma_deactivation_survey', array($this, 'jltma_deactivation_survey'));
34 }
35
36
37 public function proceed()
38 {
39
40 global $current_screen;
41 if (
42 isset($current_screen->parent_file)
43 && $current_screen->parent_file == 'plugins.php'
44 && isset($current_screen->id)
45 && $current_screen->id == 'plugins'
46 ) {
47 return true;
48 }
49 return false;
50 }
51
52 public function admin_suvery_scripts($handle)
53 {
54 if ('plugins.php' === $handle) {
55 wp_enqueue_style('jltma-survey', JLTMA_ASSETS . 'css/plugin-survey.css');
56 }
57 }
58
59 /**
60 * Deactivation Survey
61 */
62 public function jltma_deactivation_survey()
63 {
64 check_ajax_referer('jltma_deactivation_nonce');
65
66 $deactivation_reason = !empty($_POST['deactivation_reason']) ? sanitize_text_field(wp_unslash($_POST['deactivation_reason'])) : '';
67
68 if (empty($deactivation_reason)) {
69 return;
70 }
71
72 $email = get_bloginfo('admin_email');
73 $author_obj = get_user_by('email', $email);
74 $user_id = $author_obj->ID;
75 $full_name = $author_obj->display_name;
76
77 $response = $this->get_collect_data($user_id, array(
78 'first_name' => $full_name,
79 'email' => $email,
80 'deactivation_reason' => $deactivation_reason,
81 ));
82
83 return $response;
84 }
85
86
87 public function get_survey_questions()
88 {
89
90 return [
91 'no_longer_needed' => [
92 'title' => esc_html__('I no longer need the plugin', 'master-addons'),
93 'input_placeholder' => '',
94 ],
95 'found_a_better_plugin' => [
96 'title' => esc_html__('I found a better plugin', 'master-addons'),
97 'input_placeholder' => esc_html__('Please share which plugin', 'master-addons'),
98 ],
99 'couldnt_get_the_plugin_to_work' => [
100 'title' => esc_html__('I couldn\'t get the plugin to work', 'master-addons'),
101 'input_placeholder' => '',
102 ],
103 'temporary_deactivation' => [
104 'title' => esc_html__('It\'s a temporary deactivation', 'master-addons'),
105 'input_placeholder' => '',
106 ],
107 'jltma_pro' => [
108 'title' => sprintf(esc_html__('I have %1$s Pro', 'master-addons'), JLTMA),
109 'input_placeholder' => '',
110 'alert' => sprintf(esc_html__('Wait! Don\'t deactivate %1$s. You have to activate both %1$s and %1$s Pro in order for the plugin to work.', 'master-addons'), JLTMA),
111 ],
112 'need_better_design' => [
113 'title' => esc_html__('I need better design and presets', 'master-addons'),
114 'input_placeholder' => esc_html__('Let us know your thoughts', 'master-addons'),
115 ],
116 'other' => [
117 'title' => esc_html__('Other', 'master-addons'),
118 'input_placeholder' => esc_html__('Please share the reason', 'master-addons'),
119 ],
120 ];
121 }
122
123
124 /**
125 * Deactivation Footer
126 */
127 public function deactivation_footer()
128 {
129
130 if (!$this->proceed()) {
131 return;
132 }
133
134 ?>
135 <div class="jltma-deactivate-survey-overlay" id="jltma-deactivate-survey-overlay"></div>
136 <div class="jltma-deactivate-survey-modal" id="jltma-deactivate-survey-modal">
137 <header>
138 <div class="jltma-deactivate-survey-header">
139 <img src="<?php echo esc_url(JLTMA_IMAGE_DIR . 'logo.png'); ?>" />
140 <h3><?php echo wp_sprintf('%1$s %2$s', JLTMA, __('- Feedback', 'master-addons')); ?></h3>
141 </div>
142 </header>
143 <div class="jltma-deactivate-info">
144 <?php echo wp_sprintf('%1$s %2$s', __('If you have a moment, please share why you are deactivating', 'master-addons'), JLTMA); ?>
145 </div>
146 <div class="jltma-deactivate-content-wrapper">
147 <form action="#" class="jltma-deactivate-form-wrapper">
148 <?php foreach ($this->get_survey_questions() as $reason_key => $reason) { ?>
149 <div class="jltma-deactivate-input-wrapper">
150 <input id="jltma-deactivate-feedback-<?php echo esc_attr($reason_key); ?>" class="jltma-deactivate-feedback-dialog-input" type="radio" name="reason_key" value="<?php echo esc_attr($reason_key); ?>">
151 <label for="jltma-deactivate-feedback-<?php echo esc_attr($reason_key); ?>" class="jltma-deactivate-feedback-dialog-label"><?php echo esc_html($reason['title']); ?></label>
152 <?php if (!empty($reason['input_placeholder'])) : ?>
153 <input class="jltma-deactivate-feedback-text" type="text" name="reason_<?php echo esc_attr($reason_key); ?>" placeholder="<?php echo esc_attr($reason['input_placeholder']); ?>" />
154 <?php endif; ?>
155 </div>
156 <?php } ?>
157 <div class="jltma-deactivate-footer">
158 <button id="jltma-dialog-lightbox-submit" class="jltma-dialog-lightbox-submit"><?php echo esc_html__('Submit &amp; Deactivate', 'master-addons'); ?></button>
159 <button id="jltma-dialog-lightbox-skip" class="jltma-dialog-lightbox-skip"><?php echo esc_html__('Skip & Deactivate', 'master-addons'); ?></button>
160 </div>
161 </form>
162 </div>
163 </div>
164
165 <script>
166 var deactivate_url = '#';
167
168 jQuery(document).on('click', '#deactivate-master-addons', function(e) {
169 e.preventDefault();
170 deactivate_url = e.target.href;
171 jQuery('#jltma-deactivate-survey-overlay').addClass('jltma-deactivate-survey-is-visible');
172 jQuery('#jltma-deactivate-survey-modal').addClass('jltma-deactivate-survey-is-visible');
173 });
174
175 jQuery('#jltma-dialog-lightbox-skip').on('click', function(e) {
176 e.preventDefault();
177 window.location.replace(deactivate_url);
178 });
179
180
181 jQuery(document).on('click', '#jltma-dialog-lightbox-submit', async function(e) {
182 e.preventDefault();
183
184 jQuery('#jltma-dialog-lightbox-submit').addClass('jltma-loading');
185
186 var $dialogModal = jQuery('.jltma-deactivate-input-wrapper'),
187 radioSelector = '.jltma-deactivate-feedback-dialog-input';
188 $dialogModal.find(radioSelector).on('change', function() {
189 $dialogModal.attr('data-feedback-selected', jQuery(this).val());
190 });
191 $dialogModal.find(radioSelector + ':checked').trigger('change');
192
193
194 // Reasons for deactivation
195 var deactivation_reason = '';
196 var reasonData = jQuery('.jltma-deactivate-form-wrapper').serializeArray();
197
198 jQuery.each(reasonData, function(reason_index, reason_value) {
199 if ('reason_key' == reason_value.name && reason_value.value != '') {
200 const reason_input_id = '#jltma-deactivate-feedback-' + reason_value.value,
201 reason_title = jQuery(reason_input_id).siblings('label').text(),
202 reason_placeholder_input = jQuery(reason_input_id).siblings('input').val(),
203 format_title_with_key = reason_value.value + ' - ' + reason_placeholder_input,
204 format_title = reason_title + ' - ' + reason_placeholder_input;
205
206 deactivation_reason = reason_value.value;
207
208 if ('found_a_better_plugin' == reason_value.value) {
209 deactivation_reason = format_title_with_key;
210 }
211
212 if ('need_better_design' == reason_value.value) {
213 deactivation_reason = format_title_with_key;
214 }
215
216 if ('other' == reason_value.value) {
217 deactivation_reason = format_title_with_key;
218 }
219 }
220 });
221
222 await jQuery.ajax({
223 url: '<?php echo esc_url(admin_url('admin-ajax.php')); ?>',
224 method: 'POST',
225 // crossDomain: true,
226 async: true,
227 // dataType: 'jsonp',
228 data: {
229 action: 'jltma_deactivation_survey',
230 _wpnonce: '<?php echo esc_js(wp_create_nonce('jltma_deactivation_nonce')); ?>',
231 deactivation_reason: deactivation_reason
232 },
233 success: function(response) {
234 window.location.replace(deactivate_url);
235 }
236 });
237 return true;
238 });
239
240 jQuery('#jltma-deactivate-survey-overlay').on('click', function() {
241 jQuery('#jltma-deactivate-survey-overlay').removeClass('jltma-deactivate-survey-is-visible');
242 jQuery('#jltma-deactivate-survey-modal').removeClass('jltma-deactivate-survey-is-visible');
243 });
244 </script>
245 <?php
246 }
247 } // End class Feedback
248 } // End class_exists check
249