PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.0.2
Post Grid Gutenberg Blocks – PostX v4.0.2
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
ultimate-post / classes / Deactive.php

Deactive.php in Post Grid Gutenberg Blocks – PostX 4.0.2, at classes/Deactive.php

585 lines 16.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Deactivation Action.
4 *
5 * @package ULTP\Notice
6 * @since v.1.1.0
7 */
8 namespace ULTP;
9
10 /**
11 * Deactive class.
12 */
13 defined('ABSPATH') || exit;
14
15 /**
16 * Deactive class.
17 */
18 class Deactive{
19
20 private $PLUGIN_NAME = 'PostX';
21 private $PLUGIN_SLUG = 'ultimate-post';
22 private $PLUGIN_VERSION = ULTP_VER;
23 private $API_ENDPOINT = 'https://inside.wpxpo.com';
24
25
26 /**
27 * Setup class.
28 *
29 * @since v.1.1.0
30 */
31 public function __construct() {
32 add_action( 'admin_footer', array( $this, 'get_source_data_callback' ) );
33
34 $is_collect = ultimate_post()->get_tran('wpxpo_data_collect');
35
36 $is_frequency = get_transient( 'wpxpo_data_collect_every' );
37 if ($is_frequency == false && $is_collect == 'yes') {
38 add_action( 'init', array( $this, 'send_frequency_plugin_data' ) );
39 set_transient( 'wpxpo_data_collect_every', 'yes', MONTH_IN_SECONDS ); // every 30 days
40 }
41
42 add_action( 'wp_ajax_ultp_deactive_plugin', array( $this, 'send_plugin_data' ) );
43 }
44
45 public function send_frequency_plugin_data() {
46 $this->send_plugin_data( 'allow' );
47 }
48
49
50 /**
51 * Check is Local or Not
52 *
53 * @since v.1.0.0
54 * @param NULL
55 * @return BOOLEAN | Is local or not
56 */
57 public function is_local() {
58 $seed = isset($_SERVER['REMOTE_ADDR']) ? sanitize_key($_SERVER['REMOTE_ADDR']) : '';
59 return in_array( $seed, array( '127.0.0.1', '::1' ) );
60 }
61
62
63 /**
64 * Sanitize Array
65 *
66 * @since v.2.5.8
67 * @param ARRAY
68 * @return ARRAY | Product return data
69 */
70 public function sanitize_array( &$array ) {
71 foreach ($array as &$value) {
72 if ( !is_array($value) ) {
73 $value = sanitize_text_field( $value );
74 } else {
75 $this->sanitize_array($value);
76 }
77 }
78 return $array;
79 }
80
81
82 /**
83 * Get Plugin Data Response
84 *
85 * @since v.1.0.0
86 * @param STRING
87 * @return ARRAY | Product return data
88 */
89 public function send_plugin_data( $type , $site = '' ) {
90 $data = $this->get_data();
91 $data['site_type'] = $site ? $site : get_option( '__ultp_site_type' );
92
93 $data['type'] = $type ? $type : 'deactive';
94 $form_data = isset($_POST) ? $this->sanitize_array($_POST) : array(); //phpcs:Ignore
95
96 if (current_user_can( 'administrator' ) ) {
97 if (isset( $form_data['action'] )) {
98 unset( $form_data['action'] );
99 }
100
101 $response = wp_remote_post( $this->API_ENDPOINT, array(
102 'method' => 'POST',
103 'timeout' => 30,
104 'redirection' => 5,
105 'headers' => array(
106 'user-agent' => 'wpxpo/' . md5( esc_url( home_url() ) ) . ';',
107 'Accept' => 'application/json',
108 ),
109 'blocking' => true,
110 'httpversion' => '1.0',
111 'body' => array_merge($data, $form_data),
112 ) );
113
114 return $response;
115 }
116 }
117
118
119 /**
120 * Deactive Form Settings Data
121 *
122 * @since v.1.0.0
123 * @param NULL
124 * @return ARRAY | Settings Parameters
125 */
126 public function get_settings() {
127 $attr = array(
128 array(
129 'id' => 'no-need',
130 'input' => false,
131 'text' => __( "I no longer need the plugin.", "ultimate-post" )
132 ),
133 array(
134 'id' => 'better-plugin',
135 'input' => true,
136 'text' => __( "I found a better plugin.", "ultimate-post" ),
137 'placeholder' => __( "Please share which plugin.", "ultimate-post" ),
138 ),
139 array(
140 'id' => 'stop-working',
141 'input' => true,
142 'text' => __( "The plugin suddenly stopped working.", "ultimate-post" ),
143 'placeholder' => __( "Please share more details.", "ultimate-post" ),
144 ),
145 array(
146 'id' => 'not-working',
147 'input' => false,
148 'text' => __( "I could not get the plugin to work.", "ultimate-post" )
149 ),
150 array(
151 'id' => 'temporary-deactivation',
152 'input' => false,
153 'text' => __( "It's a temporary deactivation.", "ultimate-post" )
154 ),
155 array(
156 'id' => 'other',
157 'input' => true,
158 'text' => __( "Other.", "ultimate-post" ),
159 'placeholder' => __( "Please share the reason.", "ultimate-post" ),
160 ),
161 );
162 return $attr;
163 }
164
165
166 /**
167 * Deactive HTML View
168 *
169 * @since v.1.0.0
170 * @param NULL
171 * @return STRING | HTML Data
172 */
173 public function get_source_data_callback() {
174 global $pagenow;
175 if ($pagenow == 'plugins.php' ) {
176 $this->deactive_html();
177 }
178 $this->deactive_css();
179 $this->deactive_js();
180 }
181
182 public function deactive_html() { ?>
183 <div class="ultp-modal" id="ultp-deactive-modal">
184 <div class="ultp-modal-wrap">
185
186 <div class="ultp-modal-header">
187 <h2><?php esc_html_e( "Quick Feedback", "ultimate-post" ); ?></h2>
188 <button class="ultp-modal-cancel"><span class="dashicons dashicons-no-alt"></span></button>
189 </div>
190
191 <div class="ultp-modal-body">
192 <h3><?php esc_html_e( "If you have a moment, please let us know why you are deactivating PostX:", "ultimate-post" ); ?></h3>
193 <ul class="ultp-modal-input">
194 <?php foreach ($this->get_settings() as $key => $setting) { ?>
195 <li>
196 <label>
197 <input type="radio" <?php echo $key == 0 ? 'checked="checked"' : ''; ?> id="<?php echo esc_attr($setting['id']); ?>" name="<?php echo esc_attr($this->PLUGIN_SLUG); ?>" value="<?php echo esc_attr($setting['text']); ?>">
198 <div class="ultp-reason-text"><?php echo esc_html($setting['text']); ?></div>
199 <?php if( isset($setting['input']) && $setting['input'] ) { ?>
200 <textarea placeholder="<?php echo esc_attr($setting['placeholder']); ?>" class="ultp-reason-input <?php echo $key == 0 ? 'ultp-active' : ''; ?> <?php echo esc_html($setting['id']); ?>"></textarea>
201 <?php } ?>
202 </label>
203 </li>
204 <?php } ?>
205 </ul>
206 </div>
207
208 <div class="ultp-modal-footer">
209 <a class="ultp-modal-submit ultp-btn ultp-btn-primary" href="#"><?php esc_html_e( "Submit & Deactivate", "ultimate-post" ); ?><span class="dashicons dashicons-update rotate"></span></a>
210 <a class="ultp-modal-deactive" href="#"><?php esc_html_e( "Skip & Deactivate", "ultimate-post" ); ?></a>
211 </div>
212
213 </div>
214 </div>
215 <?php }
216
217
218 /**
219 * Deactivation Forms CSS File
220 *
221 * @since v.1.0.0
222 * @param NULL
223 * @return STRING | CSS Code
224 */
225 public function deactive_css() { ?>
226 <style type="text/css">
227 .ultp-modal {
228 position: fixed;
229 z-index: 99999;
230 top: 0;
231 right: 0;
232 bottom: 0;
233 left: 0;
234 background: rgba(0,0,0,0.5);
235 display: none;
236 box-sizing: border-box;
237 overflow: scroll;
238 }
239 .ultp-modal * {
240 box-sizing: border-box;
241 }
242 .ultp-modal.modal-active {
243 display: block;
244 }
245 .ultp-modal-wrap {
246 max-width: 870px;
247 width: 100%;
248 position: relative;
249 margin: 10% auto;
250 background: #fff;
251 }
252 .ultp-reason-input{
253 display: none;
254 }
255 .ultp-reason-input.ultp-active{
256 display: block;
257 }
258 .rotate{
259 animation: rotate 1.5s linear infinite;
260 }
261 @keyframes rotate{
262 to{ transform: rotate(360deg); }
263 }
264 .ultp-popup-rotate{
265 animation: popupRotate 1s linear infinite;
266 }
267 @keyframes popupRotate{
268 to{ transform: rotate(360deg); }
269 }
270 #ultp-deactive-modal {
271 background: rgb(0 0 0 / 85%);
272 overflow: hidden;
273 }
274 #ultp-deactive-modal .ultp-modal-wrap {
275 max-width: 570px;
276 border-radius: 5px;
277 margin: 5% auto;
278 overflow: hidden
279 }
280 #ultp-deactive-modal .ultp-modal-header {
281 padding: 17px 30px;
282 border-bottom: 1px solid #ececec;
283 display: flex;
284 align-items: center;
285 background: #f5f5f5;
286 }
287 #ultp-deactive-modal .ultp-modal-header .ultp-modal-cancel {
288 padding: 0;
289 border-radius: 100px;
290 border: 1px solid #b9b9b9;
291 background: none;
292 color: #b9b9b9;
293 cursor: pointer;
294 transition: 400ms;
295 }
296 #ultp-deactive-modal .ultp-modal-header .ultp-modal-cancel:focus {
297 color: red;
298 border: 1px solid red;
299 outline: 0;
300 }
301 #ultp-deactive-modal .ultp-modal-header .ultp-modal-cancel:hover {
302 color: red;
303 border: 1px solid red;
304 }
305 #ultp-deactive-modal .ultp-modal-header h2 {
306 margin: 0;
307 padding: 0;
308 flex: 1;
309 line-height: 1;
310 font-size: 20px;
311 text-transform: uppercase;
312 color: #8e8d8d;
313 }
314 #ultp-deactive-modal .ultp-modal-body {
315 padding: 25px 30px;
316 }
317 #ultp-deactive-modal .ultp-modal-body h3{
318 padding: 0;
319 margin: 0;
320 line-height: 1.4;
321 font-size: 15px;
322 }
323 #ultp-deactive-modal .ultp-modal-body ul {
324 margin: 25px 0 10px;
325 }
326 #ultp-deactive-modal .ultp-modal-body ul li {
327 display: flex;
328 margin-bottom: 10px;
329 color: #807d7d;
330 }
331 #ultp-deactive-modal .ultp-modal-body ul li:last-child {
332 margin-bottom: 0;
333 }
334 #ultp-deactive-modal .ultp-modal-body ul li label {
335 align-items: center;
336 width: 100%;
337 }
338 #ultp-deactive-modal .ultp-modal-body ul li label input {
339 padding: 0 !important;
340 margin: 0;
341 display: inline-block;
342 }
343 #ultp-deactive-modal .ultp-modal-body ul li label textarea {
344 margin-top: 8px;
345 width: 350px;
346 }
347 #ultp-deactive-modal .ultp-modal-body ul li label .ultp-reason-text {
348 margin-left: 8px;
349 display: inline-block;
350 }
351 #ultp-deactive-modal .ultp-modal-footer {
352 padding: 0 30px 30px 30px;
353 display: flex;
354 align-items: center;
355 /* border-top: 1px solid #e5e5e5;
356 box-shadow: 0 0px 8px 0px rgb(0 0 0 / 12%); */
357 }
358 #ultp-deactive-modal .ultp-modal-footer .ultp-modal-submit {
359 display: flex;
360 align-items: center;
361 }
362 #ultp-deactive-modal .ultp-modal-footer .ultp-modal-submit span {
363 margin-left: 4px;
364 display: none;
365 }
366 #ultp-deactive-modal .ultp-modal-footer .ultp-modal-submit.loading span {
367 display: block;
368 }
369 #ultp-deactive-modal .ultp-modal-footer .ultp-modal-deactive {
370 margin-left: auto;
371 color: #c5c5c5;
372 text-decoration: none;
373 }
374 .wpxpo-btn-tracking-notice {
375 display: flex;
376 align-items: center;
377 flex-wrap: wrap;
378 padding: 5px 0;
379 }
380 .wpxpo-btn-tracking-notice .wpxpo-btn-tracking {
381 margin: 0 5px;
382 text-decoration: none;
383 }
384 </style>
385 <?php }
386
387
388 /**
389 * Deactivation Forms JS File
390 *
391 * @since v.1.0.0
392 * @param NULL
393 * @return STRING | JS Code
394 */
395 public function deactive_js() { ?>
396 <script type="text/javascript">
397 jQuery( document ).ready( function( $ ) {
398 'use strict';
399
400 // Modal Radio Input Click Action
401 $('.ultp-modal-input input[type=radio]').on( 'change', function(e) {
402 $('.ultp-reason-input').removeClass('ultp-active');
403 $('.ultp-modal-input').find( '.'+$(this).attr('id') ).addClass('ultp-active');
404 });
405
406 // Modal Cancel Click Action
407 $( document ).on( 'click', '.ultp-modal-cancel', function(e) {
408 $( '#ultp-deactive-modal' ).removeClass( 'modal-active' );
409 });
410
411 // Deactivate Button Click Action
412 $( document ).on( 'click', '#deactivate-ultimate-post', function(e) {
413 e.preventDefault();
414 $( '#ultp-deactive-modal' ).addClass( 'modal-active' );
415 $( '.ultp-modal-deactive' ).attr( 'href', $(this).attr('href') );
416 $( '.ultp-modal-submit' ).attr( 'href', $(this).attr('href') );
417 });
418
419 // Submit to Remote Server
420 $( document ).on( 'click', '.ultp-modal-submit', function(e) {
421 e.preventDefault();
422
423 $(this).addClass('loading');
424 const url = $(this).attr('href')
425
426 $.ajax({
427 url: '<?php echo esc_url(admin_url('admin-ajax.php')); ?>',
428 type: 'POST',
429 data: {
430 action: 'ultp_deactive_plugin',
431 cause_id: $('input[type=radio]:checked').attr('id'),
432 cause_title: $('.ultp-modal-input input[type=radio]:checked').val(),
433 cause_details: $('.ultp-reason-input.ultp-active').val()
434 },
435 success: function (data) {
436 $( '#ultp-deactive-modal' ).removeClass( 'modal-active' );
437 window.location.href = url;
438 // that.parents('.wc-install').hide("slow", function() { that.parents('.wc-install').remove(); });
439 },
440 error: function(xhr) {
441 console.log( 'Error occured. Please try again' + xhr.statusText + xhr.responseText );
442 },
443 });
444
445 });
446
447 });
448 </script>
449 <?php }
450
451
452 /**
453 * Get All the Installed Plugin Data
454 *
455 * @since v.1.0.0
456 * @param NULL
457 * @return ARRAY | Return Plugin Information
458 */
459 public function get_plugins() {
460 if (! function_exists( 'get_plugins' ) ) {
461 include ABSPATH . '/wp-admin/includes/plugin.php';
462 }
463
464 $active = array();
465 $inactive = array();
466 $all_plugins = get_plugins();
467 $active_plugins = get_option( 'active_plugins', array() );
468 if (is_multisite()) {
469 $active_plugins = array_merge($active_plugins, array_keys(get_site_option( 'active_sitewide_plugins', array() )));
470 }
471
472 foreach ( $all_plugins as $key => $plugin ) {
473 $arr = array();
474
475 $arr['name'] = isset( $plugin['Name'] ) ? $plugin['Name'] : '';
476 $arr['url'] = isset( $plugin['PluginURI'] ) ? $plugin['PluginURI'] : '';
477 $arr['author'] = isset( $plugin['Author'] ) ? $plugin['Author'] : '';
478 $arr['version'] = isset( $plugin['Version'] ) ? $plugin['Version'] : '';
479
480 if (in_array( $key, $active_plugins )) {
481 $active[$key] = $arr;
482 } else {
483 $inactive[$key] = $arr;
484 }
485 }
486
487 return array( 'active' => $active, 'inactive' => $inactive );
488 }
489
490
491 /**
492 * Get All the Theme Installed
493 *
494 * @since v.1.0.0
495 * @param NULL
496 * @return ARRAY | Return Theme Information
497 */
498 public function get_themes() {
499 $theme_data = array();
500 $all_themes = wp_get_themes();
501
502 if (is_array($all_themes)) {
503 foreach ($all_themes as $key => $theme) {
504 $attr = array();
505 $attr['name'] = $theme->Name;
506 $attr['url'] = $theme->ThemeURI;
507 $attr['author'] = $theme->Author;
508 $attr['version'] = $theme->Version;
509 $theme_data[$key] = $attr;
510 }
511 }
512 return $theme_data;
513 }
514
515
516 /**
517 * Get Current User IP
518 *
519 * @since v.1.0.0
520 * @param NULL
521 * @return STRING | Return IP
522 */
523 public function get_user_ip() {
524 $response = wp_remote_get( 'https://icanhazip.com/' );
525
526 if (is_wp_error( $response ) ) {
527 return '';
528 } else {
529 $user_ip = trim( wp_remote_retrieve_body( $response ) );
530 return filter_var( $user_ip, FILTER_VALIDATE_IP ) ? $user_ip : '';
531 }
532 }
533
534
535 /**
536 * Get All the Data Collected
537 *
538 * @since v.1.0.0
539 * @param NULL
540 * @return ARRAY | All Send Data
541 */
542 public function get_data() {
543 global $wpdb;
544 $user = wp_get_current_user();
545 $user_count = count_users();
546 $plugins_data = $this->get_plugins();
547
548 $data = array(
549 'name' => get_bloginfo( 'name' ),
550 'home' => esc_url( home_url() ),
551 'admin_email' => $user->user_email,
552 'first_name' => isset($user->user_firstname) ? $user->user_firstname : '',
553 'last_name' => isset($user->user_lastname) ? $user->user_lastname : '',
554 'display_name' => $user->display_name,
555 'wordpress' => get_bloginfo( 'version' ),
556 'memory_limit' => WP_MEMORY_LIMIT,
557 'debug_mode' => ( defined('WP_DEBUG') && WP_DEBUG ) ? 'Yes' : 'No',
558 'locale' => get_locale(),
559 'multisite' => is_multisite() ? 'Yes' : 'No',
560
561 'themes' => $this->get_themes(),
562 'active_theme' => get_stylesheet(),
563 'users' => isset($user_count['total_users']) ? $user_count['total_users'] : 0,
564 'active_plugins' => $plugins_data['active'],
565 'inactive_plugins' => $plugins_data['inactive'],
566 'server' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_key($_SERVER['SERVER_SOFTWARE']) : '',
567
568 'timezone' => date_default_timezone_get(),
569 'php_curl' => function_exists( 'curl_init' ) ? 'Yes' : 'No',
570 'php_version' => function_exists('phpversion') ? phpversion() : '',
571 'upload_size' => size_format( wp_max_upload_size() ),
572 'mysql_version' => $wpdb->db_version(),
573 'php_fsockopen' => function_exists( 'fsockopen' ) ? 'Yes' : 'No',
574
575 'ip' => $this->get_user_ip(),
576 'plugin_name' => $this->PLUGIN_NAME,
577 'plugin_version' => $this->PLUGIN_VERSION,
578 'plugin_slug' => $this->PLUGIN_SLUG
579 );
580
581 return $data;
582 }
583
584
585 }