PluginProbe ʕ •ᴥ•ʔ
reCaptcha by BestWebSoft / 1.65
reCaptcha by BestWebSoft v1.65
1.79 1.80 1.82 1.83 1.84 1.85 1.86 1.87 trunk 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 1.22 1.23 1.24 1.25 1.26 1.27 1.28 1.29 1.30 1.31 1.32 1.33 1.34 1.35 1.36 1.37 1.38 1.39 1.40 1.41 1.42 1.43 1.44 1.45 1.46 1.47 1.48 1.49 1.50 1.51 1.52 1.53 1.54 1.55 1.56 1.57 1.58 1.59 1.60 1.61 1.62 1.63 1.64 1.65 1.66 1.67 1.68 1.70 1.71 1.72 1.73 1.74 1.75 1.78
google-captcha / bws_menu / deactivation-form.php
google-captcha / bws_menu Last commit date
css 4 years ago fonts 4 years ago icons 4 years ago images 4 years ago js 4 years ago languages 4 years ago bws_functions.php 4 years ago bws_include.php 4 years ago bws_menu.php 4 years ago class-bws-settings.php 4 years ago deactivation-form.php 4 years ago deprecated.php 4 years ago product_list.php 4 years ago
deactivation-form.php
421 lines
1 <?php
2 /**
3 * Displays the content of the dialog box when the user clicks on the "Deactivate" link on the plugin settings page
4 * @package BestWebSoft
5 * @since 2.1.3
6 */
7 if ( ! defined( 'ABSPATH' ) )
8 exit;
9
10 /**
11 * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
12 * page.
13 *
14 * @since 2.1.3
15 */
16 if ( ! function_exists( 'bws_add_deactivation_feedback_dialog_box' ) ) {
17 function bws_add_deactivation_feedback_dialog_box() {
18 global $bstwbsftwppdtplgns_active_plugins;
19 if ( empty( $bstwbsftwppdtplgns_active_plugins ) )
20 return;
21
22 $contact_support_template = __( 'Need help? We are ready to answer your questions.', 'bestwebsoft' ) . ' <a href="https://support.bestwebsoft.com/hc/en-us/requests/new" target="_blank">' . __( 'Contact Support', 'bestwebsoft' ) . '</a>';
23
24 $reasons = array(
25 array(
26 'id' => 'NOT_WORKING',
27 'text' => __( 'The plugin is not working', 'bestwebsoft' ),
28 'input_type' => 'textarea',
29 'input_placeholder' => esc_attr__( "Kindly share what didn't work so we can fix it in future updates...", 'bestwebsoft' )
30 ),
31 array(
32 'id' => 'DIDNT_WORK_AS_EXPECTED',
33 'text' => __( "The plugin didn't work as expected", 'bestwebsoft' ),
34 'input_type' => 'textarea',
35 'input_placeholder' => esc_attr__( 'What did you expect?', 'bestwebsoft' )
36 ),
37 array(
38 'id' => 'SUDDENLY_STOPPED_WORKING',
39 'text' => __( 'The plugin suddenly stopped working', 'bestwebsoft' ),
40 'input_type' => '',
41 'input_placeholder' => '',
42 'internal_message' => $contact_support_template
43 ),
44 array(
45 'id' => 'BROKE_MY_SITE',
46 'text' => __( 'The plugin broke my site', 'bestwebsoft' ),
47 'input_type' => '',
48 'input_placeholder' => '',
49 'internal_message' => $contact_support_template
50 ),
51 array(
52 'id' => 'COULDNT_MAKE_IT_WORK',
53 'text' => __( "I couldn't understand how to get it work", 'bestwebsoft' ),
54 'input_type' => '',
55 'input_placeholder' => '',
56 'internal_message' => $contact_support_template
57 ),
58 array(
59 'id' => 'FOUND_A_BETTER_PLUGIN',
60 'text' => __( 'I found a better plugin', 'bestwebsoft' ),
61 'input_type' => 'textfield',
62 'input_placeholder' => esc_attr__( "What's the plugin name?", 'bestwebsoft' )
63 ),
64 array(
65 'id' => 'GREAT_BUT_NEED_SPECIFIC_FEATURE',
66 'text' => __( "The plugin is great, but I need specific feature that you don't support", 'bestwebsoft' ),
67 'input_type' => 'textarea',
68 'input_placeholder' => esc_attr__( 'What feature?', 'bestwebsoft' )
69 ),
70 array(
71 'id' => 'NO_LONGER_NEEDED',
72 'text' => __( 'I no longer need the plugin', 'bestwebsoft' ),
73 'input_type' => '',
74 'input_placeholder' => ''
75 ),
76 array(
77 'id' => 'TEMPORARY_DEACTIVATION',
78 'text' => __( "It's a temporary deactivation, I'm just debugging an issue", 'bestwebsoft' ),
79 'input_type' => '',
80 'input_placeholder' => ''
81 ),
82 array(
83 'id' => 'OTHER',
84 'text' => __( 'Other', 'bestwebsoft' ),
85 'input_type' => 'textfield',
86 'input_placeholder' => ''
87 )
88 );
89
90 $modal_html = '<div class="bws-modal bws-modal-deactivation-feedback">
91 <div class="bws-modal-dialog">
92 <div class="bws-modal-body">
93 <h2>' . __( 'Quick Feedback', 'bestwebsoft' ) . '</h2>
94 <div class="bws-modal-panel active">
95 <p>' . __( 'If you have a moment, please let us know why you are deactivating', 'bestwebsoft' ) . ":</p><ul>";
96
97 foreach ( $reasons as $reason ) {
98 $list_item_classes = 'bws-modal-reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' );
99
100 if ( ! empty( $reason['internal_message'] ) ) {
101 $list_item_classes .= ' has-internal-message';
102 $reason_internal_message = $reason['internal_message'];
103 } else {
104 $reason_internal_message = '';
105 }
106
107 $modal_html .= '<li class="' . $list_item_classes . '" data-input-type="' . $reason['input_type'] . '" data-input-placeholder="' . $reason['input_placeholder'] . '">
108 <label>
109 <span>
110 <input type="radio" name="selected-reason" value="' . $reason['id'] . '"/>
111 </span>
112 <span>' . $reason['text'] . '</span>
113 </label>
114 <div class="bws-modal-internal-message">' . $reason_internal_message . '</div>
115 </li>';
116 }
117 $modal_html .= '</ul>
118 <label class="bws-modal-anonymous-label">
119 <input type="checkbox" />' .
120 __( 'Send website data and allow to contact me back', 'bestwebsoft' ) .
121 '</label>
122 </div>
123 </div>
124 <div class="bws-modal-footer">
125 <a href="#" class="button button-primary bws-modal-button-deactivate disabled">' . __( 'Submit and Deactivate', 'bestwebsoft' ) . '</a>
126 <a href="#" class="bws-modal-skip-link">' . __( 'Skip and Deactivate', 'bestwebsoft' ) . '</a>
127 <span class="bws-modal-processing hidden">' . __( 'Processing', 'bestwebsoft' ) . '...</span>
128 <div class="clear"></div>
129 </div>
130 </div>
131 </div>';
132
133 $script = '';
134
135 foreach ( $bstwbsftwppdtplgns_active_plugins as $basename => $plugin_data ) {
136
137 $slug = dirname( $basename );
138 $plugin_id = sanitize_title( $plugin_data['Name'] );
139
140 $script .= "(function($) {
141 var modalHtml = " . json_encode( $modal_html ) . ",
142 \$modal = $( modalHtml ),
143 \$deactivateLink = $( '#the-list .active[data-plugin=\"" . $basename . "\"] .deactivate a' ),
144 \$anonymousFeedback = \$modal.find( '.bws-modal-anonymous-label' ),
145 selectedReasonID = false;
146
147 /* WP added data-plugin attr after 4.5 version/ In prev version was id attr */
148 if ( 0 == \$deactivateLink.length )
149 \$deactivateLink = $( '#the-list .active#" . $plugin_id . " .deactivate a' );
150
151 \$modal.appendTo( $( 'body' ) );
152
153 BwsModalRegisterEventHandlers();
154
155 function BwsModalRegisterEventHandlers() {
156 \$deactivateLink.click( function( evt ) {
157 evt.preventDefault();
158
159 /* Display the dialog box.*/
160 BwsModalReset();
161 \$modal.addClass( 'active' );
162 $( 'body' ).addClass( 'has-bws-modal' );
163 });
164
165 \$modal.on( 'input propertychange', '.bws-modal-reason-input input', function() {
166 if ( ! BwsModalIsReasonSelected( 'OTHER' ) ) {
167 return;
168 }
169
170 var reason = $( this ).val().trim();
171
172 /* If reason is not empty, remove the error-message class of the message container to change the message color back to default. */
173 if ( reason.length > 0 ) {
174 \$modal.find( '.message' ).removeClass( 'error-message' );
175 BwsModalEnableDeactivateButton();
176 }
177 });
178
179 \$modal.on( 'blur', '.bws-modal-reason-input input', function() {
180 var \$userReason = $( this );
181
182 setTimeout( function() {
183 if ( ! BwsModalIsReasonSelected( 'OTHER' ) ) {
184 return;
185 }
186 }, 150 );
187 });
188
189 \$modal.on( 'click', '.bws-modal-footer .bws-modal-skip-link', function( evt ) {
190 evt.preventDefault();
191
192 /* If no selected reason, just deactivate the plugin. */
193 window.location.href = \$deactivateLink.attr( 'href' );
194 return;
195 });
196
197 \$modal.on( 'click', '.bws-modal-footer .button', function( evt ) {
198 evt.preventDefault();
199
200 if ( $( this ).hasClass( 'disabled' ) ) {
201 return;
202 }
203
204 var _parent = $( this ).parents( '.bws-modal:first' ),
205 _this = $( this );
206
207 var \$radio = \$modal.find( 'input[type=\"radio\"]:checked' );
208
209 if ( 0 === \$radio.length ) {
210 /* If no selected reason */
211 BwsModalDisableDeactivateButton();
212 return;
213 }
214
215 var \$selected_reason = \$radio.parents( 'li:first' ),
216 \$input = \$selected_reason.find( 'textarea, input[type=\"text\"]' ),
217 userReason = ( 0 !== \$input.length ) ? \$input.val().trim() : '';
218
219 var is_anonymous = ( \$anonymousFeedback.find( 'input' ).is( ':checked' ) ) ? 0 : 1;
220
221 $.ajax({
222 url : ajaxurl,
223 method : 'POST',
224 data : {
225 'action' : 'bws_submit_uninstall_reason_action',
226 'plugin' : '" . $basename . "',
227 'reason_id' : \$radio.val(),
228 'reason_info' : userReason,
229 'is_anonymous' : is_anonymous,
230 'bws_ajax_nonce' : '" . wp_create_nonce( 'bws_ajax_nonce' ) . "'
231 },
232 beforeSend: function() {
233 _parent.find( '.bws-modal-footer .button' ).hide();
234 _parent.find( '.bws-modal-footer .bws-modal-processing' ).show();
235 },
236 complete : function( message ) {
237 /* Do not show the dialog box, deactivate the plugin. */
238 window.location.href = \$deactivateLink.attr( 'href' );
239 }
240 });
241 });
242
243 \$modal.on( 'click', 'input[type=\"radio\"]', function() {
244 var \$selectedReasonOption = $( this );
245
246 /* If the selection has not changed, do not proceed. */
247 if ( selectedReasonID === \$selectedReasonOption.val() )
248 return;
249
250 selectedReasonID = \$selectedReasonOption.val();
251
252 \$anonymousFeedback.show();
253
254 var _parent = $( this ).parents( 'li:first' );
255
256 \$modal.find( '.bws-modal-reason-input' ).remove();
257 \$modal.find( '.bws-modal-internal-message' ).hide();
258
259 BwsModalEnableDeactivateButton();
260
261 if ( _parent.hasClass( 'has-internal-message' ) ) {
262 _parent.find( '.bws-modal-internal-message' ).show();
263 }
264
265 if (_parent.hasClass('has-input')) {
266 var reasonInputHtml = '<div class=\"bws-modal-reason-input\"><span class=\"message\"></span>' + ( ( 'textfield' === _parent.data( 'input-type' ) ) ? '<input type=\"text\" />' : '<textarea rows=\"5\" maxlength=\"200\"></textarea>' ) + '</div>';
267
268 _parent.append( $( reasonInputHtml ) );
269 _parent.find( 'input, textarea' ).attr( 'placeholder', _parent.data( 'input-placeholder' ) ).focus();
270
271 if ( BwsModalIsReasonSelected( 'OTHER' ) ) {
272 \$modal.find( '.message' ).text( '" . __( 'Please tell us the reason so we can improve it.', 'bestwebsoft' ) . "' ).show();
273 }
274 }
275 });
276
277 /* If the user has clicked outside the window, cancel it. */
278 \$modal.on( 'click', function( evt ) {
279 var \$target = $( evt.target );
280
281 /* If the user has clicked anywhere in the modal dialog, just return. */
282 if ( \$target.hasClass( 'bws-modal-body' ) || \$target.hasClass( 'bws-modal-footer' ) ) {
283 return;
284 }
285
286 /* If the user has not clicked the close button and the clicked element is inside the modal dialog, just return. */
287 if ( ! \$target.hasClass( 'bws-modal-button-close' ) && ( \$target.parents( '.bws-modal-body' ).length > 0 || \$target.parents( '.bws-modal-footer' ).length > 0 ) ) {
288 return;
289 }
290
291 /* Close the modal dialog */
292 \$modal.removeClass( 'active' );
293 $( 'body' ).removeClass( 'has-bws-modal' );
294
295 return false;
296 });
297 }
298
299 function BwsModalIsReasonSelected( reasonID ) {
300 /* Get the selected radio input element.*/
301 return ( reasonID == \$modal.find('input[type=\"radio\"]:checked').val() );
302 }
303
304 function BwsModalReset() {
305 selectedReasonID = false;
306
307 /* Uncheck all radio buttons.*/
308 \$modal.find( 'input[type=\"radio\"]' ).prop( 'checked', false );
309
310 /* Remove all input fields ( textfield, textarea ).*/
311 \$modal.find( '.bws-modal-reason-input' ).remove();
312
313 \$modal.find( '.message' ).hide();
314
315 /* Hide, since by default there is no selected reason.*/
316 \$anonymousFeedback.hide();
317
318 BwsModalDisableDeactivateButton();
319
320 BwsModalShowPanel();
321 }
322
323 function BwsModalEnableDeactivateButton() {
324 \$modal.find( '.bws-modal-button-deactivate' ).removeClass( 'disabled' ).show();
325 \$modal.find( '.bws-modal-processing' ).hide();
326 }
327
328 function BwsModalDisableDeactivateButton() {
329 \$modal.find( '.bws-modal-button-deactivate' ).addClass( 'disabled' );
330 }
331
332 function BwsModalShowPanel() {
333 \$modal.find( '.bws-modal-panel' ).addClass( 'active' );
334 }
335 })(jQuery);";
336 }
337
338 /* add script in FOOTER */
339 wp_register_script( 'bws-deactivation-feedback-dialog-boxes', '', array( 'jquery' ), false, true );
340 wp_enqueue_script( 'bws-deactivation-feedback-dialog-boxes' );
341 wp_add_inline_script( 'bws-deactivation-feedback-dialog-boxes', $script );
342 }
343 }
344
345 /**
346 * Called after the user has submitted his reason for deactivating the plugin.
347 *
348 * @since 2.1.3
349 */
350 if ( ! function_exists( 'bws_submit_uninstall_reason_action' ) ) {
351 function bws_submit_uninstall_reason_action() {
352 global $bstwbsftwppdtplgns_options, $wp_version, $bstwbsftwppdtplgns_active_plugins, $current_user;
353
354 wp_verify_nonce( $_REQUEST['bws_ajax_nonce'], 'bws_ajax_nonce' );
355
356 $reason_id = isset( $_REQUEST['reason_id'] ) ? stripcslashes( sanitize_text_field( $_REQUEST['reason_id'] ) ) : '';
357 $basename = isset( $_REQUEST['plugin'] ) ? stripcslashes( sanitize_text_field( $_REQUEST['plugin'] ) ) : '';
358
359 if ( empty( $reason_id ) || empty( $basename ) ) {
360 exit;
361 }
362
363 $reason_info = isset( $_REQUEST['reason_info'] ) ? stripcslashes( sanitize_text_field( $_REQUEST['reason_info'] ) ) : '';
364 if ( ! empty( $reason_info ) ) {
365 $reason_info = substr( $reason_info, 0, 255 );
366 }
367 $is_anonymous = isset( $_REQUEST['is_anonymous'] ) && 1 == $_REQUEST['is_anonymous'];
368
369 $options = array(
370 'product' => $basename,
371 'reason_id' => $reason_id,
372 'reason_info' => $reason_info,
373 );
374
375 if ( ! $is_anonymous ) {
376 if ( ! isset( $bstwbsftwppdtplgns_options ) )
377 $bstwbsftwppdtplgns_options = ( is_multisite() ) ? get_site_option( 'bstwbsftwppdtplgns_options' ) : get_option( 'bstwbsftwppdtplgns_options' );
378
379 if ( ! empty( $bstwbsftwppdtplgns_options['track_usage']['usage_id'] ) ) {
380 $options['usage_id'] = $bstwbsftwppdtplgns_options['track_usage']['usage_id'];
381 } else {
382 $options['usage_id'] = false;
383 $options['url'] = get_bloginfo( 'url' );
384 $options['wp_version'] = $wp_version;
385 $options['is_active'] = false;
386 $options['version'] = $bstwbsftwppdtplgns_active_plugins[ $basename ]['Version'];
387 }
388
389 $options['email'] = $current_user->data->user_email;
390 }
391
392 /* send data */
393 $raw_response = wp_remote_post( 'https://bestwebsoft.com/wp-content/plugins/products-statistics/deactivation-feedback/', array(
394 'method' => 'POST',
395 'body' => $options,
396 'timeout' => 15,
397 ) );
398
399 if ( ! is_wp_error( $raw_response ) && 200 == wp_remote_retrieve_response_code( $raw_response ) ) {
400 if ( ! $is_anonymous ) {
401 $response = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
402
403 if ( is_array( $response ) && ! empty( $response['usage_id'] ) && $response['usage_id'] != $options['usage_id'] ) {
404 $bstwbsftwppdtplgns_options['track_usage']['usage_id'] = $response['usage_id'];
405
406 if ( is_multisite() )
407 update_site_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
408 else
409 update_option( 'bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options );
410 }
411 }
412
413 echo 'done';
414 } else {
415 echo $response->get_error_code() . ': ' . $response->get_error_message();
416 }
417 exit;
418 }
419 }
420
421 add_action( 'wp_ajax_bws_submit_uninstall_reason_action', 'bws_submit_uninstall_reason_action' );