PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.20
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.20
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Classes / Notifications / What_We_Collect.php

What_We_Collect.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.20, at Inc/Classes/Notifications/What_We_Collect.php

228 lines 6.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PXLBSAdminify\Inc\Classes\Notifications;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 use PXLBSAdminify\Inc\Classes\Notifications\Base\User_Data;
10 use PXLBSAdminify\Inc\Classes\Notifications\Model\Notice;
11
12 if (! class_exists('What_We_Collect')) {
13 /**
14 * Class for what we collect
15 *
16 * Jewel Theme <support@jeweltheme.com>
17 */
18 class What_We_Collect extends Notice
19 {
20
21
22 use User_Data;
23
24 public $color = 'warning';
25
26 /**
27 * Constructor method
28 *
29 * @author Jewel Theme <support@jeweltheme.com>
30 */
31 public function __construct()
32 {
33 parent::__construct();
34 add_action('wp_ajax_pxlbsadminify_allow_collect', array($this, 'pxlbsadminify_allow_collect'));
35 }
36
37 /**
38 * Allow collect data
39 *
40 * @author Jewel Theme <support@jeweltheme.com>
41 */
42 public function pxlbsadminify_allow_collect()
43 {
44 check_ajax_referer('pxlbsadminify_allow_collect_nonce');
45
46 // Opting in to send diagnostic data to a third party is a
47 // site-wide consent and must only be performed by a site
48 // administrator.
49 if ( ! current_user_can( 'manage_options' ) ) {
50 wp_send_json_error( array( 'mess' => __( 'You are not allowed to perform this action.', 'adminify' ) ), 403 );
51 }
52
53 $this->pxlbsadminify_collect_ajax_data();
54 }
55
56
57 public function pxlbsadminify_collect_ajax_data()
58 {
59
60 if (!empty(get_option('pxlbsadminify_what_we_collect'))) {
61 return;
62 }
63
64 $email = get_bloginfo('admin_email');
65
66 $author_obj = get_user_by('email', $email);
67 $user_id = $author_obj->ID;
68 $full_name = $author_obj->display_name;
69
70 $response = $this->get_collect_data($user_id, array(
71 'first_name' => $full_name,
72 'email' => $email,
73 ));
74
75 update_option('pxlbsadminify_what_we_collect', 'yes');
76 return $response;
77 }
78
79
80
81 /**
82 * Title Content
83 *
84 * @author Jewel Theme <support@jeweltheme.com>
85 */
86 public function set_title()
87 {
88 printf(
89 '<h4>Wanna get some discount for %1$s? No Worries!! We got you!! give us your email we will send you the discount code?</h4>',
90 esc_html__('Adminify', 'adminify')
91 );
92 }
93
94 /**
95 * Link for collect data
96 *
97 * @author Jewel Theme <support@jeweltheme.com>
98 */
99 public function what_we_collect_link()
100 {
101 echo '<a href="!#" class="wp-adminify-wwc-link">' . esc_html__('what we collect', 'adminify') . '</a>';
102 }
103
104 /**
105 * Notice Content
106 *
107 * @author Jewel Theme <support@jeweltheme.com>
108 */
109 public function notice_content()
110 { ?>
111 <div class="wp-adminify-notice-review-box wp-adminify-wwc">
112 <p>
113 <?php
114 echo wp_kses_post( sprintf(
115 /* translators: %1$s: Plugin name */
116 __('Want to help make <strong>%1$s</strong> even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information.', 'adminify'),
117 esc_html( __('Adminify', 'adminify') )
118 ) );
119 ?>
120 (<?php $this->what_we_collect_link(); ?>)</p>
121 <div class="wp-adminify-wwc-content" style="display:none">
122 <?php echo wp_kses_post( sprintf(
123 /* translators: %1$s: Privacy Policy page URL */
124 __('Server environment details (php, mysql, server, WordPress versions), Number of users in your site, Site language, Number of active and inactive plugins, Local or Production Site, IP Address, Site name and url, Your name and email address etc. No sensitive data is tracked. Learn more about our <a href="%1$s" target="_blank">Privacy Policy</a>, how we handle and collects your data.', 'adminify'),
125 esc_url('https://wpadminify.com/privacy-policy')
126 ) ); ?>
127 </div>
128 </div>
129
130 <?php
131 }
132
133 /**
134 * Plugin rate url
135 *
136 * @author Jewel Theme <support@jeweltheme.com>
137 */
138 public function plugin_rate_url()
139 {
140 return '#';
141 }
142
143 /**
144 * Footer Content
145 *
146 * @author Jewel Theme <support@jeweltheme.com>
147 */
148 public function footer_content()
149 {
150 ?>
151 <a class="button button-primary allow-button" href="<?php echo esc_url($this->plugin_rate_url()); ?>" rel="nofollow" target="_blank">
152 <?php echo esc_html__('Allow', 'adminify'); ?>
153 </a>
154 <a class="button button-secondary button-reject wp-adminify-notice-dismiss" href="#" rel="nofollow">
155 <?php echo esc_html__('No Thanks', 'adminify'); ?>
156 </a>
157 <?php
158 }
159
160 /**
161 * Intervals
162 *
163 * @author Jewel Theme <support@jeweltheme.com>
164 */
165 public function intervals()
166 {
167 return array(0, 7, 10, 15, 20, 15, 25, 30);
168 }
169
170 /**
171 * Core Script
172 *
173 * @param [type] $trigger_time .
174 * @author Jewel Theme <support@jeweltheme.com>
175 */
176 public function core_script($trigger_time)
177 {
178 parent::core_script($trigger_time);
179 ?>
180
181 <script>
182 jQuery('body').on('click', '.wp-adminify-notice-what_we_collect .wp-adminify-wwc-link', function(e) {
183 e.preventDefault();
184 if (jQuery(this).hasClass('show')) {
185 jQuery(this).removeClass("show");
186 jQuery('.wp-adminify-wwc-content').stop().slideUp(200);
187 } else {
188 jQuery(this).addClass("show");
189 jQuery('.wp-adminify-wwc-content').stop().slideDown(200);
190 }
191 });
192
193 jQuery('body').on('click', '.wp-adminify-notice-what_we_collect .allow-button, .wp-adminify-notice-what_we_collect .wp-adminify-notice-dismiss', function(e) {
194
195 e.preventDefault();
196
197 let noticeWrapper = jQuery(this).closest('.notice-wp-adminify');
198
199 noticeWrapper.css('opacity', '0.4').find('button').prop('disabled', true);
200
201 jQuery.ajax({
202 url: '<?php echo esc_url(admin_url('admin-ajax.php')); ?>',
203 method: 'POST',
204 crossDomain: true,
205 data: {
206 action: 'pxlbsadminify_allow_collect',
207 _wpnonce: '<?php echo esc_js(wp_create_nonce('pxlbsadminify_allow_collect_nonce')); ?>',
208 }
209 })
210 .done(function(response) {
211 noticeWrapper.children(':not(.notice-dismiss)').hide().end().append('<p class="wp-adminify--notice-message"><strong>' + response.data + '</strong></p>');
212 let subsTimeout = setTimeout(function() {
213 pxlbsadminify_notice_action(null, noticeWrapper.children(), 'disable');
214 clearTimeout(subsTimeout);
215 }, 1500);
216 })
217 .always(function() {
218 noticeWrapper.css('opacity', '1').find('button').prop('disabled', false);
219 })
220
221 });
222 </script>
223
224 <?php
225 }
226 }
227 }
228