PluginProbe ʕ •ᴥ•ʔ
PixelYourSite – Your smart PIXEL (TAG) & API Manager / 9.7.2
PixelYourSite – Your smart PIXEL (TAG) & API Manager v9.7.2
11.2.0.6 trunk 1.0 1.01 1.02 1.03 1.04 1.05 1.05.1 10.0.0 10.0.1 10.0.1.1 10.0.1.2 10.0.2 10.0.3 10.0.3.1 10.0.4 10.1.0 10.1.1 10.1.1.1 10.1.1.2 10.1.2.1 10.1.3 10.2.0 10.2.0.1 10.2.0.2 10.2.1 11.0.0 11.0.0.1 11.0.0.2 11.0.0.3 11.0.0.4 11.0.1 11.0.1.1 11.0.1.2 11.0.2 11.1.0 11.1.1 11.1.2 11.1.3 11.1.4 11.1.4.1 11.1.4.2 11.1.5 11.1.5.1 11.1.5.2 11.2.0 11.2.0.1 11.2.0.2 11.2.0.3 11.2.0.4 11.2.0.5 2.0 2.1 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.7 2.8.10 2.8.9 3.0 3.0.1 3.0.2 3.0.3 3.1.0 4.0.0 4.0.1 4.0.2 4.0.3 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5.2 5.0.6 5.0.7 5.0.8 5.0.9 5.1.0 5.2.0 5.2.1 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 7.0.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1.0 7.1.1 7.1.10 7.1.11 7.1.12 7.1.13 7.1.14 7.1.2 7.1.3 7.1.4 7.1.5 7.1.6 7.1.7 7.1.8 7.1.9 7.2.0 7.2.1 7.2.1.1 7.3.0 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.0.9 8.1.0 8.1.1 8.2.0 8.2.1 8.2.10 8.2.11 8.2.12 8.2.13 8.2.14 8.2.15 8.2.16 8.2.17 8.2.18 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.2.7 8.2.8 9.0.0 9.1.0 9.1.1 9.2.0 9.2.1 9.2.2 9.3.0 9.3.1 9.3.2 9.3.3 9.3.4 9.3.5 9.3.6 9.3.7 9.3.8 9.3.8.1 9.3.9 9.4.0 9.4.0.1 9.4.1 9.4.2 9.4.3 9.4.5 9.4.5.1 9.4.6 9.4.7 9.4.7.1 9.5.0 9.5.0.1 9.5.1 9.5.1.1 9.5.3 9.5.4 9.5.5 9.6.0 9.6.0.1 9.6.1 9.6.1.1 9.6.2 9.7.0 9.7.0.1 9.7.1 9.7.2
pixelyoursite / includes / functions-optin.php
pixelyoursite / includes Last commit date
enrich 1 year ago events 1 year ago formEvents 1 year ago logger 1 year ago views 1 year ago class-custom-event-factory.php 7 years ago class-custom-event.php 1 year ago class-event-id-generator.php 5 years ago class-events-manager-ajax_hook.php 1 year ago class-events-manager.php 1 year ago class-fixed-notices.php 1 year ago class-pixel.php 7 years ago class-plugin-updater.php 1 year ago class-plugin.php 7 years ago class-pys.php 1 year ago class-settings.php 1 year ago functions-admin.php 1 year ago functions-common.php 1 year ago functions-custom-event.php 1 year ago functions-edd.php 1 year ago functions-gdpr.php 1 year ago functions-license.php 1 year ago functions-migrate.php 1 year ago functions-optin.php 1 year ago functions-promo-notices.php 1 year ago functions-system-report.php 7 years ago functions-update-plugin.php 6 years ago functions-woo.php 1 year ago options_defaults.json 1 year ago options_fields.json 1 year ago
functions-optin.php
227 lines
1 <?php
2
3 namespace PixelYourSite;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8 add_action( 'wp_ajax_pys_optin_add', 'PixelYourSite\pys_optin_add' );
9 add_action( 'wp_ajax_nopriv_pys_optin_add', 'PixelYourSite\pys_optin_add' );
10 add_action( 'admin_notices', 'PixelYourSite\adminRenderOptinNotices', 9 );
11 function pys_optin_add()
12 {
13 $body = array(
14 'action' => 'optin_add',
15 'data' => $_POST
16 );
17
18 $response = wp_remote_post( 'https://www.pixelyoursite.com', array(
19 'timeout' => 30,
20 'sslverify' => false,
21 'user-agent' => 'PixelYourSite/' . PYS_FREE_VERSION . '; ' . get_bloginfo( 'url' ),
22 'body' => $body
23 ) );
24
25
26 if (is_wp_error($response)) {
27 wp_send_json_error(null, 420);
28 } else {
29 $body = wp_remote_retrieve_body($response);
30 $decoded_body = json_decode($body, true); // Decode the body to an array
31 if (isset($decoded_body['data'])) {
32 wp_send_json_success($decoded_body['data']); // Return only the 'data' part
33 } else {
34 wp_send_json_error('Invalid response format', 422);
35 }
36 }
37 }
38 function adminRenderOptinNotices() {
39
40 if ( ! current_user_can( 'manage_pys' ) ) {
41 return;
42 }
43
44 $user = wp_get_current_user();
45 $user_id = $user->ID;
46
47 // never show again for opted-in users
48 if ( get_option( 'pys_core_opted_in_dismissed_at' ) || get_user_meta( $user_id, 'pys_core_opted_in_dismissed_at', true ) ) {
49 return;
50 }
51
52 $second_time_dismissed_at = get_option( 'pys_core_optin_second_time_dismissed_at' ) ?? get_user_meta( $user_id, 'pys_core_optin_second_time_dismissed_at', true );
53 $first_time_dismissed_at = get_option( 'pys_core_optin_first_time_dismissed_at' ) ?? get_user_meta( $user_id, 'pys_core_optin_first_time_dismissed_at', true );
54
55 if ( get_option( 'pys_core_optin_third_time_dismissed_at' ) || get_user_meta( $user_id, 'pys_core_optin_third_time_dismissed_at', true ) ) {
56 return; // was dismissed 3 times
57 } elseif ( $second_time_dismissed_at ) {
58 $month_ago = time() - MONTH_IN_SECONDS;
59
60 if ( $month_ago < $second_time_dismissed_at ) {
61 return; // hide if dismissed less then month ago
62 }
63
64 $header = 'Free PIXELYOURSITE HACKS: Improve your ads return and website tracking - LAST CALL';
65 $dismiss_key = 'optin_third_time';
66 } elseif ( $first_time_dismissed_at ) {
67 $week_ago = time() - WEEK_IN_SECONDS;
68
69 if ( $week_ago < $first_time_dismissed_at ) {
70 return; // hide if dismissed less then week ago
71 }
72
73 $header = 'PIXELYOURSITE HACKS: Improve your ads return and website tracking with FREE Facebook, Google and Pinterest hacks';
74 $dismiss_key = 'optin_second_time';
75
76 } else { // was never dismissed
77 $header = 'Free PIXELYOURSITE HACKS: Improve your ads return and website tracking';
78 $dismiss_key = 'optin_first_time';
79 }
80
81 // hide close button on PYS pages
82 $dismissable = empty( $_REQUEST['page'] ) || $_REQUEST['page'] != 'pixelyoursite';
83
84 // on PYS pages message always same
85 if ( ! $dismissable ) {
86 $header = 'Free PIXELYOURSITE HACKS: Improve your ads return and website tracking';
87 $dismiss_key = '';
88 }
89
90 ?>
91
92 <style type="text/css">
93 .notice.pys-notice-wrapper {
94 display: flex;
95 align-items: center;
96 padding-top: 15px;
97 padding-bottom: 15px;
98 }
99 .pys-notice-content h4 {
100 margin-bottom: 10px!important;
101 }
102 .pys-notice-logo {
103 margin-right: 15px;
104 width: 50px;
105 max-width: 50px;
106 height: auto;
107 }
108 .pys-notice-wrapper h4 {
109 margin-top: 0;
110 }
111 .pys-form-text,
112 .pys-notice-label {
113 display: block;
114 margin-top: 4px;
115 font-size: 12px;
116 font-weight: 400;
117 color: #495057 !important;
118 }
119 .pys-notice-form-group:not(:last-child) {
120 margin-right: 12px;
121 }
122 </style>
123
124 <div class="notice <?php echo $dismissable ? 'is-dismissible' : ''; ?> pys-optin-notice pys-notice-wrapper">
125 <img src="<?php echo PYS_FREE_URL . '/dist/images/pys-square-logo-small.png'; ?>" class="pys-notice-logo">
126 <div class="pys-notice-content">
127 <h4><?php echo $header; ?></h4>
128 <form style="display: flex;">
129 <div class="pys-notice-form-group">
130 <input type="text" name="name" placeholder="Your name"
131 value="<?php esc_attr_e( $user->first_name ); ?>">
132 </div>
133 <div class="pys-notice-form-group">
134 <input type="email" name="email" required
135 placeholder="Your e-mail" value="<?php esc_attr_e( $user->user_email ); ?>">
136 </div>
137 <?php if ( isWooCommerceActive() ) : ?>
138 <div class="pys-notice-form-group">
139 <label class="pys-notice-label">
140 <input type="checkbox" name="tag[]" value="with-woo" checked>I use WooCommerce
141 </label>
142 </div>
143 <?php endif; ?>
144 <?php if ( isEddActive() ) : ?>
145 <div class="pys-notice-form-group">
146 <label class="pys-notice-label">
147 <input type="checkbox" name="tag[]" value="with-edd" checked>I use Easy Digital Downloads
148 </label>
149 </div>
150 <?php endif; ?>
151 <div class="pys-notice-form-group">
152 <button class="button button-primary" style="margin-top: -2px;">SEND ME FREE HACKS</button>
153 </div>
154 <div class="pys-notice-form-group">
155 <small class="pys-form-text">No spam. You can unsubscribe at any time.</small>
156 </div>
157 </form>
158 </div>
159 </div>
160
161 <script type="application/javascript">
162 jQuery(document).on('click', '.pys-optin-notice .notice-dismiss', function () {
163 jQuery.ajax({
164 url: ajaxurl,
165 data: {
166 action: 'pys_notice_dismiss',
167 nonce: '<?php esc_attr_e( wp_create_nonce( 'pys_notice_dismiss' ) ); ?>',
168 user_id: '<?php esc_attr_e( $user_id ); ?>',
169 addon_slug: 'core',
170 meta_key: '<?php esc_attr_e( $dismiss_key ); ?>'
171 }
172 })
173 });
174
175 jQuery(document).on('submit', '.pys-optin-notice form', function (e) {
176 e.preventDefault();
177
178 var $form = jQuery(this),
179 name = $form.find('input[name="name"]').val(),
180 email = $form.find('input[name="email"]').val(),
181 $tags = $form.find('input[name="tag[]"]:checked'),
182 tags = [];
183
184 $tags.each(function (i, elem) {
185 tags.push(jQuery(elem).val());
186 });
187
188 jQuery.ajax({
189 url: ajaxurl,
190 method: 'POST',
191 crossDomain: true,
192 data: {
193 action: 'pys_optin_add',
194 name: name,
195 email: email,
196 tags: tags
197 },
198 beforeSend: function () {
199 $form.find('input, button').attr('disabled', true);
200 },
201 success: function (resp) {
202 console.log(resp);
203 $form.closest('.pys-notice-wrapper').fadeOut();
204 if (resp.success) {
205 setOptedInMeta();
206 }
207 }
208 });
209
210 var setOptedInMeta = function () {
211 jQuery.ajax({
212 url: ajaxurl,
213 method: 'POST',
214 data: {
215 action: 'pys_notice_dismiss',
216 nonce: '<?php esc_attr_e( wp_create_nonce( 'pys_notice_dismiss' ) ); ?>',
217 user_id: '<?php esc_attr_e( $user_id ); ?>',
218 addon_slug: 'core',
219 meta_key: 'opted_in'
220 }
221 });
222 };
223 });
224 </script>
225
226 <?php
227 }