PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.1.19
Post Grid Gutenberg Blocks – PostX v4.1.19
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.1.19, at classes/Deactive.php

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