PluginProbe ʕ •ᴥ•ʔ
PixelYourSite – Your smart PIXEL (TAG) & API Manager / 8.0.9
PixelYourSite – Your smart PIXEL (TAG) & API Manager v8.0.9
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
events 5 years ago views 5 years ago class-custom-event-factory.php 7 years ago class-custom-event.php 5 years ago class-event-id-generator.php 5 years ago class-events-manager.php 5 years ago class-pixel.php 7 years ago class-plugin-updater.php 6 years ago class-plugin.php 7 years ago class-pys.php 5 years ago class-settings.php 5 years ago functions-admin.php 5 years ago functions-common.php 5 years ago functions-custom-event.php 5 years ago functions-edd.php 5 years ago functions-gdpr.php 5 years ago functions-license.php 6 years ago functions-migrate.php 6 years ago functions-optin.php 5 years ago functions-promo-notices.php 5 years ago functions-system-report.php 7 years ago functions-update-plugin.php 6 years ago functions-woo.php 5 years ago options_defaults.json 5 years ago options_fields.json 5 years ago
functions-optin.php
199 lines
1 <?php
2
3 namespace PixelYourSite;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 add_action( 'admin_notices', 'PixelYourSite\adminRenderOptinNotices' );
10 function adminRenderOptinNotices() {
11
12 if ( ! current_user_can( 'manage_pys' ) ) {
13 return;
14 }
15
16 $user = wp_get_current_user();
17 $user_id = $user->ID;
18
19 // never show again for opted-in users
20 if ( get_user_meta( $user_id, 'pys_core_opted_in_dismissed_at', true ) ) {
21 return;
22 }
23
24 $second_time_dismissed_at = get_user_meta( $user_id, 'pys_core_optin_second_time_dismissed_at', true );
25 $first_time_dismissed_at = get_user_meta( $user_id, 'pys_core_optin_first_time_dismissed_at', true );
26
27 if ( get_user_meta( $user_id, 'pys_core_optin_third_time_dismissed_at', true ) ) {
28 return; // was dismissed 3 times
29 } elseif ( $second_time_dismissed_at ) {
30 $month_ago = time() - MONTH_IN_SECONDS;
31
32 if ( $month_ago < $second_time_dismissed_at ) {
33 return; // hide if dismissed less then month ago
34 }
35
36 $header = 'Free PIXELYOURSITE HACKS: Improve your ads return and website tracking - LAST CALL';
37 $dismiss_key = 'optin_third_time';
38 } elseif ( $first_time_dismissed_at ) {
39 $week_ago = time() - WEEK_IN_SECONDS;
40
41 if ( $week_ago < $first_time_dismissed_at ) {
42 return; // hide if dismissed less then week ago
43 }
44
45 $header = 'PIXELYOURSITE HACKS: Improve your ads return and website tracking with FREE Facebook, Google and Pinterest hacks';
46 $dismiss_key = 'optin_second_time';
47
48 } else { // was never dismissed
49 $header = 'Free PIXELYOURSITE HACKS: Improve your ads return and website tracking';
50 $dismiss_key = 'optin_first_time';
51 }
52
53 // hide close button on PYS pages
54 $dismissable = empty( $_REQUEST['page'] ) || $_REQUEST['page'] != 'pixelyoursite';
55
56 // on PYS pages message always same
57 if ( ! $dismissable ) {
58 $header = 'Free PIXELYOURSITE HACKS: Improve your ads return and website tracking';
59 $dismiss_key = '';
60 }
61
62 ?>
63
64 <style type="text/css">
65 .notice.pys-notice-wrapper {
66 display: flex;
67 align-items: center;
68 padding-top: 15px;
69 padding-bottom: 15px;
70 }
71 .pys-notice-content h4 {
72 margin-bottom: 10px;
73 }
74 .pys-notice-logo {
75 margin-right: 15px;
76 width: 50px;
77 max-width: 50px;
78 height: auto;
79 }
80 .pys-notice-wrapper h4 {
81 margin-top: 0;
82 }
83 .pys-form-text,
84 .pys-notice-label {
85 display: block;
86 margin-top: 4px;
87 font-size: 12px;
88 font-weight: 400;
89 color: #495057 !important;
90 }
91 .pys-notice-form-group:not(:last-child) {
92 margin-right: 12px;
93 }
94 </style>
95
96 <div class="notice <?php echo $dismissable ? 'is-dismissible' : ''; ?> pys-optin-notice pys-notice-wrapper">
97 <img src="<?php echo PYS_FREE_URL . '/dist/images/pys-square-logo-small.png'; ?>" class="pys-notice-logo">
98 <div class="pys-notice-content">
99 <h4><?php echo $header; ?></h4>
100 <form style="display: flex;">
101 <div class="pys-notice-form-group">
102 <input type="text" name="name" placeholder="Your name"
103 value="<?php esc_attr_e( $user->first_name ); ?>">
104 </div>
105 <div class="pys-notice-form-group">
106 <input type="email" name="email" required
107 placeholder="Your e-mail" value="<?php esc_attr_e( $user->user_email ); ?>">
108 </div>
109 <?php if ( isWooCommerceActive() ) : ?>
110 <div class="pys-notice-form-group">
111 <label class="pys-notice-label">
112 <input type="checkbox" name="tag[]" value="with-woo" checked>I use WooCommerce
113 </label>
114 </div>
115 <?php endif; ?>
116 <?php if ( isEddActive() ) : ?>
117 <div class="pys-notice-form-group">
118 <label class="pys-notice-label">
119 <input type="checkbox" name="tag[]" value="with-edd" checked>I use Easy Digital Downloads
120 </label>
121 </div>
122 <?php endif; ?>
123 <div class="pys-notice-form-group">
124 <button class="button button-primary" style="margin-top: -2px;">SEND ME FREE HACKS</button>
125 </div>
126 <div class="pys-notice-form-group">
127 <small class="pys-form-text">No spam. You can unsubscribe at any time.</small>
128 </div>
129 </form>
130 </div>
131 </div>
132
133 <script type="application/javascript">
134 jQuery(document).on('click', '.pys-optin-notice .notice-dismiss', function () {
135 jQuery.ajax({
136 url: ajaxurl,
137 data: {
138 action: 'pys_notice_dismiss',
139 nonce: '<?php esc_attr_e( wp_create_nonce( 'pys_notice_dismiss' ) ); ?>',
140 user_id: '<?php esc_attr_e( $user_id ); ?>',
141 addon_slug: 'core',
142 meta_key: '<?php esc_attr_e( $dismiss_key ); ?>'
143 }
144 })
145 });
146
147 jQuery(document).on('submit', '.pys-optin-notice form', function (e) {
148 e.preventDefault();
149
150 var $form = jQuery(this),
151 name = $form.find('input[name="name"]').val(),
152 email = $form.find('input[name="email"]').val(),
153 $tags = $form.find('input[name="tag[]"]:checked'),
154 tags = [];
155
156 $tags.each(function (i, elem) {
157 tags.push(jQuery(elem).val());
158 });
159
160 jQuery.ajax({
161 url: 'https://pixelyoursite.com/wp-admin/admin-ajax.php',
162 method: 'POST',
163 crossDomain: true,
164 data: {
165 action: 'pys_optin_add',
166 name: name,
167 email: email,
168 tags: tags
169 },
170 beforeSend: function () {
171 $form.find('input, button').attr('disabled', true);
172 },
173 success: function (resp) {
174 console.log(resp);
175 $form.closest('.pys-notice-wrapper').fadeOut();
176 if (resp.success) {
177 setOptedInMeta();
178 }
179 }
180 });
181
182 var setOptedInMeta = function () {
183 jQuery.ajax({
184 url: ajaxurl,
185 method: 'POST',
186 data: {
187 action: 'pys_notice_dismiss',
188 nonce: '<?php esc_attr_e( wp_create_nonce( 'pys_notice_dismiss' ) ); ?>',
189 user_id: '<?php esc_attr_e( $user_id ); ?>',
190 addon_slug: 'core',
191 meta_key: 'opted_in'
192 }
193 });
194 };
195 });
196 </script>
197
198 <?php
199 }