PluginProbe
Whols – Wholesale Prices and B2B Store Solution for WooCommerce / trunk
Whols – Wholesale Prices and B2B Store Solution for WooCommerce vtrunk
2.4.12 2.4.11 trunk 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 55 releases
whols / includes / Admin / Diagnostic_Data.php

Diagnostic_Data.php in Whols – Wholesale Prices and B2B Store Solution for WooCommerce trunk, at includes/Admin/Diagnostic_Data.php

682 lines 27.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Diagnostic data.
4 */
5
6 // If this file is accessed directly, exit.
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 /**
12 * Class.
13 */
14 if ( ! class_exists( 'Whols_Diagnostic_Data' ) ) {
15 class Whols_Diagnostic_Data {
16
17 /**
18 * Project name.
19 */
20 private $project_name;
21
22 /**
23 * Project type.
24 */
25 private $project_type;
26
27 /**
28 * Project version.
29 */
30 private $project_version;
31
32 /**
33 * Pro version Slug.
34 */
35 private $project_pro_slug;
36
37 /**
38 * Pro active.
39 */
40 private $project_pro_active;
41
42 /**
43 * Pro installed.
44 */
45 private $project_pro_installed;
46
47 /**
48 * Pro version.
49 */
50 private $project_pro_version;
51
52 /**
53 * Data center.
54 */
55 private $data_center;
56
57 /**
58 * Privacy policy.
59 */
60 private $privacy_policy;
61
62 /**
63 * Instance.
64 */
65 private static $_instance = null;
66
67 /**
68 * Get instance.
69 */
70 public static function get_instance() {
71 if ( is_null( self::$_instance ) ) {
72 self::$_instance = new self();
73 }
74
75 return self::$_instance;
76 }
77
78 /**
79 * Constructor.
80 */
81 private function __construct() {
82 $this->project_name = 'Whols';
83 $this->project_type = 'wordpress-plugin';
84 $this->project_version = WHOLS_VERSION;
85 $this->data_center = 'https://n8n.aslamhasib.com/webhook/484fe1ab-9cdf-4318-8b6f-2b218ac47009';
86 $this->privacy_policy = 'https://wpwhols.com/privacy-policy/';
87
88 $this->project_pro_slug = 'whols/whols.php';
89 $this->project_pro_active = $this->is_pro_plugin_active();
90 $this->project_pro_installed = $this->is_pro_plugin_installed();
91 $this->project_pro_version = $this->get_pro_version();
92
93 if ( get_option( 'whols_diagnostic_data_agreed' ) === 'yes' || get_option( 'whols_diagnostic_data_notice' ) === 'no' ) {
94 return;
95 }
96
97 add_action( 'admin_notices', function () {
98 $this->show_notices();
99 }, 0 );
100
101 add_action( 'wp_ajax_whols_diagnostic_data', function () {
102 $this->process_data();
103 } );
104
105 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
106 }
107
108 /**
109 * Enqueue scripts and localize nonce.
110 */
111 public function enqueue_scripts() {
112 wp_register_script( 'whols-diagnostic', '', array(), false, true );
113 wp_enqueue_script( 'whols-diagnostic' );
114 wp_localize_script(
115 'whols-diagnostic',
116 'wholsDiagnosticData',
117 array(
118 'nonce' => wp_create_nonce( 'whols_diagnostic_data_nonce' )
119 )
120 );
121 }
122
123 /**
124 * Is capable user.
125 */
126 private function is_capable_user() {
127 $result = 'no';
128
129 if ( current_user_can( 'manage_options' ) ) {
130 $result = 'yes';
131 }
132
133 return $result;
134 }
135
136 /**
137 * Is show core notice.
138 */
139 private function is_show_core_notice() {
140 $result = get_option( 'whols_diagnostic_data_notice', 'yes' );
141 $result = ( ( 'yes' === $result ) ? 'yes' : 'no' );
142
143 return $result;
144 }
145
146 /**
147 * Is pro active.
148 */
149 private function is_pro_plugin_active() {
150
151 $result = is_plugin_active( $this->project_pro_slug );
152 $result = ( ( true === $result ) ? 'yes' : 'no' );
153
154 return $result;
155 }
156
157 /**
158 * Is pro installed.
159 */
160 private function is_pro_plugin_installed() {
161
162 $plugins = get_plugins();
163 $result = ( isset( $plugins[ $this->project_pro_slug ] ) ? 'yes' : 'no' );
164
165 return $result;
166 }
167
168 /**
169 * Get pro version.
170 */
171 private function get_pro_version() {
172
173 $plugins = get_plugins();
174 $data = ( ( isset( $plugins[ $this->project_pro_slug ] ) && is_array( $plugins[ $this->project_pro_slug ] ) ) ? $plugins[ $this->project_pro_slug ] : array() );
175 $version = ( isset( $data['Version'] ) ? sanitize_text_field( $data['Version'] ) : '' );
176
177 return $version;
178 }
179
180 /**
181 * Process data.
182 */
183 private function process_data() {
184
185 $nonce = isset( $_POST['nonce'] ) ? $_POST['nonce'] : '';
186
187 if ( ! wp_verify_nonce( $nonce, 'whols_diagnostic_data_nonce' ) ) {
188 $errormessage = array(
189 'message' => __('Nonce Varification fail','whols')
190 );
191 wp_send_json_error( $errormessage );
192 }
193
194 $agreed = ( isset( $_POST['agreed'] ) ? sanitize_key( $_POST['agreed'] ) : 'no' );
195 $agreed = ( ( 'yes' === $agreed ) ? 'yes' : 'no' );
196
197 $notice = 'no';
198
199 if ( 'yes' === $agreed ) {
200 $data = $this->get_data();
201
202 if ( ! empty( $data ) ) {
203 $response = $this->send_request( $data );
204
205 if ( is_wp_error( $response ) ) {
206 $agreed = 'no';
207 $notice = 'yes';
208 }
209 }
210 }
211
212 update_option( 'whols_diagnostic_data_agreed', $agreed );
213 update_option( 'whols_diagnostic_data_notice', $notice );
214
215 $response = array(
216 'success' => $agreed,
217 'notice' => $notice,
218 );
219
220 if ( 'yes' === $agreed ) {
221 $response['thanks_notice'] = $this->get_thanks_notice();
222 }
223
224 wp_send_json( $response );
225 }
226
227 /**
228 * Get data.
229 */
230 private function get_data() {
231 $hash = md5( current_time( 'U', true ) );
232
233 $project = array(
234 'name' => $this->project_name,
235 'type' => $this->project_type,
236 'version' => $this->project_version,
237 'pro_active' => $this->project_pro_active,
238 'pro_installed' => $this->project_pro_installed,
239 'pro_version' => $this->project_pro_version,
240 );
241
242 $site_title = get_bloginfo( 'name' );
243 $site_description = get_bloginfo( 'description' );
244 $site_url = wp_parse_url( home_url(), PHP_URL_HOST );
245 $admin_email = get_option( 'admin_email' );
246
247 $admin_first_name = '';
248 $admin_last_name = '';
249 $admin_display_name = '';
250
251 $users = get_users( array(
252 'role' => 'administrator',
253 'orderby' => 'ID',
254 'order' => 'ASC',
255 'number' => 1,
256 'paged' => 1,
257 ) );
258
259 $admin_user = ( ( is_array( $users ) && isset( $users[0] ) && is_object( $users[0] ) ) ? $users[0] : null );
260
261 if ( ! empty( $admin_user ) ) {
262 $admin_first_name = ( isset( $admin_user->first_name ) ? $admin_user->first_name : '' );
263 $admin_last_name = ( isset( $admin_user->last_name ) ? $admin_user->last_name : '' );
264 $admin_display_name = ( isset( $admin_user->display_name ) ? $admin_user->display_name : '' );
265 }
266
267 $ip_address = $this->get_ip_address();
268
269 $data = array(
270 'hash' => $hash,
271 'project' => $project,
272 'site_title' => $site_title,
273 'site_description' => $site_description,
274 'site_address' => $site_url,
275 'site_url' => $site_url,
276 'admin_email' => $admin_email,
277 'admin_first_name' => $admin_first_name,
278 'admin_last_name' => $admin_last_name,
279 'admin_display_name' => $admin_display_name,
280 'server_info' => $this->get_server_info(),
281 'wordpress_info' => $this->get_wordpress_info(),
282 'users_count' => $this->get_users_count(),
283 'plugins_count' => $this->get_plugins_count(),
284 'ip_address' => $ip_address,
285 'country_name' => $this->get_country_from_ip( $ip_address ),
286 'plugin_list' => $this->get_plugins(),
287 'theme_list' => $this->get_themes(),
288 );
289
290 return $data;
291 }
292
293 /**
294 * Get server info.
295 */
296 private function get_server_info() {
297 global $wpdb;
298
299 $software = ( ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) ? $_SERVER['SERVER_SOFTWARE'] : '' );
300 $php_version = ( function_exists( 'phpversion' ) ? phpversion() : '' );
301 $mysql_version = ( method_exists( $wpdb, 'db_version' ) ? $wpdb->db_version() : '' );
302 $php_max_upload_size = size_format( wp_max_upload_size() );
303 $php_default_timezone = date_default_timezone_get();
304 $php_soap = ( class_exists( 'SoapClient' ) ? 'yes' : 'no' );
305 $php_fsockopen = ( function_exists( 'fsockopen' ) ? 'yes' : 'no' );
306 $php_curl = ( function_exists( 'curl_init' ) ? 'yes' : 'no' );
307
308 $server_info = array(
309 'software' => $software,
310 'php_version' => $php_version,
311 'mysql_version' => $mysql_version,
312 'php_max_upload_size' => $php_max_upload_size,
313 'php_default_timezone' => $php_default_timezone,
314 'php_soap' => $php_soap,
315 'php_fsockopen' => $php_fsockopen,
316 'php_curl' => $php_curl,
317 );
318
319 return $server_info;
320 }
321
322 /**
323 * Get wordpress info.
324 */
325 private function get_wordpress_info() {
326 $wordpress_info = array();
327
328 $memory_limit = ( defined( 'WP_MEMORY_LIMIT' ) ? WP_MEMORY_LIMIT : '' );
329 $debug_mode = ( ( defined('WP_DEBUG') && WP_DEBUG ) ? 'yes' : 'no' );
330 $locale = get_locale();
331 $version = get_bloginfo( 'version' );
332 $multisite = ( is_multisite() ? 'yes' : 'no' );
333 $theme_slug = get_stylesheet();
334
335 $wordpress_info = array(
336 'memory_limit' => $memory_limit,
337 'debug_mode' => $debug_mode,
338 'locale' => $locale,
339 'version' => $version,
340 'multisite' => $multisite,
341 'theme_slug' => $theme_slug,
342 );
343
344 $theme = wp_get_theme( $wordpress_info['theme_slug'] );
345
346 if ( is_object( $theme ) && ! empty( $theme ) && method_exists( $theme, 'get' ) ) {
347 $theme_name = $theme->get( 'Name' );
348 $theme_version = $theme->get( 'Version' );
349 $theme_uri = $theme->get( 'ThemeURI' );
350 $theme_author = $theme->get( 'Author' );
351
352 $wordpress_info = array_merge( $wordpress_info, array(
353 'theme_name' => $theme_name,
354 'theme_version' => $theme_version,
355 'theme_uri' => $theme_uri,
356 'theme_author' => $theme_author,
357 ) );
358 }
359
360 return $wordpress_info;
361 }
362
363 /**
364 * Get users count.
365 */
366 private function get_users_count() {
367 $users_count = array();
368
369 $users_count_data = count_users();
370
371 $total_users = ( isset( $users_count_data['total_users'] ) ? $users_count_data['total_users'] : 0 );
372 $avail_roles = ( isset( $users_count_data['avail_roles'] ) ? $users_count_data['avail_roles'] : array() );
373
374 $users_count['total'] = $total_users;
375
376 if ( is_array( $avail_roles ) && ! empty( $avail_roles ) ) {
377 foreach ( $avail_roles as $role => $count ) {
378 $users_count[ $role ] = $count;
379 }
380 }
381
382 return $users_count;
383 }
384
385 /**
386 * Get plugins count.
387 */
388 private function get_plugins_count() {
389 $total_plugins_count = 0;
390 $active_plugins_count = 0;
391 $inactive_plugins_count = 0;
392
393 $plugins = get_plugins();
394 $plugins = ( is_array( $plugins ) ? $plugins : array() );
395
396 $active_plugins = get_option( 'active_plugins', array() );
397 $active_plugins = ( is_array( $active_plugins ) ? $active_plugins : array() );
398
399 if ( ! empty( $plugins ) ) {
400 foreach ( $plugins as $key => $data ) {
401 if ( in_array( $key, $active_plugins, true ) ) {
402 $active_plugins_count++;
403 } else {
404 $inactive_plugins_count++;
405 }
406
407 $total_plugins_count++;
408 }
409 }
410
411 $plugins_count = array(
412 'total' => $total_plugins_count,
413 'active' => $active_plugins_count,
414 'inactive' => $inactive_plugins_count,
415 );
416
417 return $plugins_count;
418 }
419
420 /**
421 * Get IP Address
422 */
423 private function get_ip_address() {
424 $response = wp_remote_get( 'https://icanhazip.com/' );
425
426 if ( is_wp_error( $response ) ) {
427 return '';
428 }
429
430 $ip_address = wp_remote_retrieve_body( $response );
431 $ip_address = trim( $ip_address );
432
433 if ( ! filter_var( $ip_address, FILTER_VALIDATE_IP ) ) {
434 return '';
435 }
436
437 return $ip_address;
438 }
439
440 /**
441 * Get Country Form ID Address
442 */
443 private function get_country_from_ip( $ip_address ) {
444 $api_url = 'http://ip-api.com/json/' . $ip_address;
445
446 // Fetch data from the API
447 $response = wp_remote_get( $api_url );
448
449 if ( is_wp_error( $response ) ) {
450 return 'Error';
451 }
452
453 // Decode the JSON response
454 $data = json_decode( wp_remote_retrieve_body($response) );
455
456 if ($data && $data->status === 'success') {
457 return $data->country;
458 } else {
459 return 'Unknown';
460 }
461 }
462
463 /**
464 * Get plugins list.
465 */
466 private function get_plugins() {
467 $plugins = get_plugins();
468
469 $data = array();
470
471 if ( is_array( $plugins ) && ! empty( $plugins ) ) {
472 foreach ( $plugins as $key => $plugin ) {
473 $data[] = array(
474 'slug' => $key,
475 'name' => $plugin['Name'],
476 'version' => $plugin['Version'],
477 'author' => $plugin['Author'],
478 'active' => ( in_array( $key, get_option( 'active_plugins', array() ), true ) ? 'yes' : 'no' ),
479 );
480 }
481 }
482
483 return $data;
484 }
485
486 /**
487 * Get themes list.
488 */
489 private function get_themes() {
490 $themes = wp_get_themes();
491
492 $data = array();
493
494 if ( is_array( $themes ) && ! empty( $themes ) ) {
495 foreach ( $themes as $key => $theme ) {
496 $data[] = array(
497 'slug' => $key,
498 'name' => $theme->get( 'Name' ),
499 'version' => $theme->get( 'Version' ),
500 'author' => $theme->get( 'Author' ),
501 'active' => ( is_admin() && get_template() === $key ? 'yes' : 'no' ),
502 );
503 }
504 }
505
506 return $data;
507 }
508
509 /**
510 * Send request.
511 */
512 private function send_request( $data = array() ) {
513 if ( ! is_array( $data ) || empty( $data ) ) {
514 return;
515 }
516
517 $site_url = wp_parse_url( home_url(), PHP_URL_HOST );
518
519 $headers = array(
520 'user-agent' => $this->project_name . '/' . md5( $site_url ) . ';',
521 'Accept' => 'application/json',
522 );
523
524 $response = wp_remote_post( $this->data_center, array(
525 'method' => 'POST',
526 'timeout' => 30,
527 'redirection' => 5,
528 'httpversion' => '1.0',
529 'blocking' => false,
530 'headers' => $headers,
531 'body' => $data,
532 'cookies' => array(),
533 ) );
534
535 return $response;
536 }
537
538 /**
539 * Show notices.
540 */
541 /**
542 * Check if this plugin should show the diagnostic data notice.
543 * Returns false if already agreed, dismissed, or another HT plugin takes priority.
544 */
545 public function should_show_notice() {
546 if ( get_option( 'whols_diagnostic_data_agreed' ) === 'yes' || get_option( 'whols_diagnostic_data_notice' ) === 'no' ) {
547 return false;
548 }
549
550 $sibling_plugins = array(
551 'woolentor-addons/woolentor_addons_elementor.php' => array(
552 'agreed' => 'woolentor_diagnostic_data_agreed',
553 'notice' => 'woolentor_diagnostic_data_notice',
554 ),
555 'ht-mega-for-elementor/htmega_addons_elementor.php' => array(
556 'agreed' => 'htmega_diagnostic_data_agreed',
557 'notice' => 'htmega_diagnostic_data_notice',
558 ),
559 'ht-easy-google-analytics/ht-easy-google-analytics.php' => array(
560 'agreed' => 'htga4_diagnostic_data_agreed',
561 'notice' => 'htga4_diagnostic_data_notice',
562 ),
563 'ht-contactform/contact-form-widget-elementor.php' => array(
564 'agreed' => 'ht_contactform_diagnostic_data_agreed',
565 'notice' => 'ht_contactform_diagnostic_data_notice',
566 ),
567 'hashbar-wp-notification-bar/init.php' => array(
568 'agreed' => 'hashbar_diagnostic_data_agreed',
569 'notice' => 'hashbar_diagnostic_data_notice',
570 ),
571 'support-genix-lite/support-genix-lite.php' => array(
572 'agreed' => 'support_genix_lite_diagnostic_data_agreed',
573 'notice' => 'support_genix_lite_diagnostic_data_notice',
574 ),
575 'pixelavo/pixelavo.php' => array(
576 'agreed' => 'pixelavo_diagnostic_data_agreed',
577 'notice' => 'pixelavo_diagnostic_data_notice',
578 ),
579 'swatchly/swatchly.php' => array(
580 'agreed' => 'swatchly_diagnostic_data_agreed',
581 'notice' => 'swatchly_diagnostic_data_notice',
582 ),
583 'extensions-for-cf7/extensions-for-cf7.php' => array(
584 'agreed' => 'ht_cf7extensions_diagnostic_data_agreed',
585 'notice' => 'ht_cf7extensions_diagnostic_data_notice',
586 ),
587 'wp-plugin-manager/plugin-main.php' => array(
588 'agreed' => 'htpm_diagnostic_data_agreed',
589 'notice' => 'htpm_diagnostic_data_notice',
590 ),
591 'just-tables/just-tables.php' => array(
592 'agreed' => 'justtables_diagnostic_data_agreed',
593 'notice' => 'justtables_diagnostic_data_notice',
594 ),
595 'really-simple-google-tag-manager/really-simple-google-tag-manager.php' => array(
596 'agreed' => 'simple_googletag_diagnostic_data_agreed',
597 'notice' => 'simple_googletag_diagnostic_data_notice',
598 ),
599 'insert-headers-and-footers-script/init.php' => array(
600 'agreed' => 'ihafs_diagnostic_data_agreed',
601 'notice' => 'ihafs_diagnostic_data_notice',
602 ),
603 );
604
605 foreach ( $sibling_plugins as $plugin_slug => $options ) {
606 if ( get_option( $options['agreed'] ) === 'yes' ) {
607 update_option( 'whols_diagnostic_data_agreed', 'yes' );
608 update_option( 'whols_diagnostic_data_notice', 'no' );
609 return false;
610 }
611 }
612
613 // Ensure only one HT plugin shows the diagnostic notice per request.
614 global $ht_diagnostic_notice_owner;
615 if ( isset( $ht_diagnostic_notice_owner ) && $ht_diagnostic_notice_owner !== 'whols' ) {
616 return false;
617 }
618 $ht_diagnostic_notice_owner = 'whols';
619
620 return true;
621 }
622
623 private function show_notices() {
624 if ( ! $this->should_show_notice() ) {
625 return;
626 }
627
628 $action = isset($_GET['action'] ) ? sanitize_text_field($_GET['action'] ) : '';
629
630 if ( 'no' === $this->is_capable_user() || 'upload-plugin' == $action ) {
631 return;
632 }
633
634 if ( 'yes' === $this->is_show_core_notice() ) {
635 $this->show_core_notice();
636 }
637 }
638
639 /**
640 * Show core notice.
641 */
642 private function show_core_notice() {
643 $message_l2 = sprintf(
644 /* translators: %1$s: Privacy Policy link, %2$s: Privacy Policy link */
645 esc_html__( 'Server information (Web server, PHP version, MySQL version), WordPress information, site name, site URL, number of plugins, number of users, your name, and email address. You can rest assured that no sensitive data will be collected or tracked. %1$sPrivacy Policy%2$s', 'whols' ), '<a target="_blank" href="' . esc_url( $this->privacy_policy ) . '">', '</a>' );
646
647 $button_text_1 = esc_html__( 'Count Me In', 'whols' );
648 $button_link_1 = add_query_arg( array( 'woolentor-diagnostic-data-agreed' => 1 ) );
649
650 $button_text_2 = esc_html__( 'No thanks', 'whols' );
651 $button_link_2 = add_query_arg( array( 'woolentor-diagnostic-data-agreed' => 0 ) );
652 ?>
653 <div class="woolentor-diagnostic-data-style"><style>.woolentor-diagnostic-data-notice,.woocommerce-embed-page .woolentor-diagnostic-data-notice{padding-top:.75em;padding-bottom:.75em;}.woolentor-diagnostic-data-notice .woolentor-diagnostic-data-buttons,.woolentor-diagnostic-data-notice .woolentor-diagnostic-data-list,.woolentor-diagnostic-data-notice .woolentor-diagnostic-data-message{padding:.25em 2px;margin:0;}.woolentor-diagnostic-data-notice .woolentor-diagnostic-data-list{display:none;color:#646970;}.woolentor-diagnostic-data-notice .woolentor-diagnostic-data-buttons{padding-top:.75em;}.woolentor-diagnostic-data-notice .woolentor-diagnostic-data-buttons .button{margin-right:5px;box-shadow:none;}.woolentor-diagnostic-data-loading{position:relative;}.woolentor-diagnostic-data-loading::before{position:absolute;content:"";width:100%;height:100%;top:0;left:0;background-color:rgba(255,255,255,.5);z-index:999;}.woolentor-diagnostic-data-disagree{border-width:0px !important;background-color: transparent!important; padding: 0!important;}.woolentor-diagnostic-data-list-toogle{cursor:pointer;color:#2271b1;text-decoration:none;}</style></div>
654 <div class="woolentor-diagnostic-data-notice notice notice-info">
655 <p class="woolentor-diagnostic-data-message"><?php echo wp_kses_post( sprintf( esc_html__( 'Want to help make %2$s%1$s%3$s even more awesome? Allow %1$s to collect diagnostic data and usage information. (%4$swhat we collect%5$s)', 'whols' ), esc_html( $this->project_name ), '<strong>', '</strong>', '<a href="#" class="woolentor-diagnostic-data-list-toogle">', '</a>' ) ); ?></p>
656 <p class="woolentor-diagnostic-data-list"><?php echo wp_kses_post( $message_l2 ); ?></p>
657 <p class="woolentor-diagnostic-data-buttons">
658 <a href="<?php echo esc_url( $button_link_1 ); ?>" class="woolentor-diagnostic-data-button woolentor-diagnostic-data-agree button button-primary"><?php echo esc_html( $button_text_1 ); ?></a>
659 <a href="<?php echo esc_url( $button_link_2 ); ?>" class="woolentor-diagnostic-data-button woolentor-diagnostic-data-disagree button button-secondary"><?php echo esc_html( $button_text_2 ); ?></a>
660 </p>
661 </div>
662 <div class="woolentor-diagnostic-data-script"><script type="text/javascript">;(function($){"use strict";function woolentorDissmissThanksNotice(noticeWrap){$('.woolentor-diagnostic-data-thanks .notice-dismiss').on('click',function(e){e.preventDefault();let thisButton=$(this),noticeWrap=thisButton.closest('.woolentor-diagnostic-data-thanks');noticeWrap.fadeTo(100,0,function(){noticeWrap.slideUp(100,function(){noticeWrap.remove()})})})};$(".woolentor-diagnostic-data-list-toogle").on("click",function(e){e.preventDefault();$(this).parents(".woolentor-diagnostic-data-notice").find(".woolentor-diagnostic-data-list").slideToggle("fast")});$(".woolentor-diagnostic-data-button").on("click",function(e){e.preventDefault();let thisButton=$(this),noticeWrap=thisButton.closest(".woolentor-diagnostic-data-notice"),agreed=thisButton.hasClass("woolentor-diagnostic-data-agree")?"yes":"no",styleWrap=$(".woolentor-diagnostic-data-style"),scriptWrap=$(".woolentor-diagnostic-data-script");$.ajax({type:"POST",url:ajaxurl,data:{action:"whols_diagnostic_data",agreed:agreed,nonce: wholsDiagnosticData.nonce},beforeSend:function(){noticeWrap.addClass("woolentor-diagnostic-data-loading")},success:function(response){response="object"===typeof response?response:{};let success=response.hasOwnProperty("success")?response.success:"no",notice=response.hasOwnProperty("notice")?response.notice:"no",thanks_notice=response.hasOwnProperty("thanks_notice")?response.thanks_notice:"";if("yes"===success){noticeWrap.replaceWith(thanks_notice);styleWrap.remove();scriptWrap.remove()}else if("no"===notice){noticeWrap.remove();styleWrap.remove();scriptWrap.remove()};noticeWrap.removeClass("woolentor-diagnostic-data-loading");woolentorDissmissThanksNotice()},error:function(){noticeWrap.removeClass("woolentor-diagnostic-data-loading")},})})})(jQuery);</script></div>
663 <?php
664 }
665
666 /**
667 * Get thanks notice.
668 */
669 private function get_thanks_notice() {
670 $message = sprintf(
671 /* translators: %1$s: Project name, %2$s: Strong tag, %3$s: Strong tag */
672 esc_html__( 'Thank you very much for supporting %2$s%1$s%3$s.', 'whols' ), $this->project_name, '<strong>', '</strong>' );
673 $notice = sprintf( '<div class="woolentor-diagnostic-data-thanks notice notice-success is-dismissible"><p>%1$s</p><button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button></div>', wp_kses_post( $message ) );
674
675 return $notice;
676 }
677
678 }
679
680 // Returns the instance.
681 Whols_Diagnostic_Data::get_instance();
682 }