PixelYourSite – Facebook Pixel (Events, WooCommerce & Easy Digital Downloads) - Version 3.1.0

Version Description

Download this release

Release Info

Developer PixelYourSite
Plugin Icon 128x128 PixelYourSite – Facebook Pixel (Events, WooCommerce & Easy Digital Downloads)
Version 3.1.0
Comparing to
See all releases

Code changes from version 3.0.3 to 3.1.0

facebook-pixel-master.php CHANGED
@@ -5,7 +5,7 @@
5
  Plugin URI: http://www.pixelyoursite.com/facebook-pixel-plugin-help
6
  Author: PixelYourSite
7
  Author URI: http://www.pixelyoursite.com
8
- Version: 3.0.3
9
  License: GPLv3
10
  */
11
 
@@ -16,7 +16,8 @@ if( defined( 'WP_DEBUG' ) && WP_DEBUG == true ) {
16
  error_reporting( E_ALL );
17
  }
18
 
19
- define( 'PYS_FREE_VERSION', '3.0.2');
 
20
 
21
  require_once( 'inc/common.php' );
22
  require_once( 'inc/admin_notices.php' );
@@ -26,23 +27,21 @@ require_once( 'inc/ajax-standard.php' );
26
  add_action( 'plugins_loaded', 'pys_free_init' );
27
  function pys_free_init() {
28
 
29
- if( !is_admin() && pys_get_option( 'general', 'enabled' ) == true && ! pys_is_disabled_for_role() ){
30
-
31
- add_action( 'wp_head', 'pys_pixel_code', 1 ); // display Facebook Pixel Code
32
- add_action( 'wp_enqueue_scripts', 'pys_public_scripts' );
33
-
34
- // add addtocart ajax support only if woocommerce installed and event is enabled
35
- if( pys_is_woocommerce_active() && pys_get_option( 'woo', 'enabled' ) && pys_get_option( 'woo', 'on_add_to_cart_btn' ) ){
36
- add_filter( 'woocommerce_loop_add_to_cart_link', 'pys_add_code_to_woo_cart_link', 10, 2 );
37
- }
38
-
39
- }
40
-
41
  $options = get_option( 'pixel_your_site' );
42
  if ( ! $options || ! isset( $options['general']['pixel_id'] ) || empty( $options['general']['pixel_id'] ) ) {
43
-
44
  pys_initialize_settings();
 
 
 
 
 
 
 
 
45
 
 
 
 
46
  }
47
 
48
  }
@@ -53,7 +52,7 @@ if( !function_exists( 'pys_admin_menu' ) ) {
53
  add_action( 'admin_menu', 'pys_admin_menu' );
54
  function pys_admin_menu() {
55
 
56
- add_menu_page( 'PixelYourSite', 'PixelYourSite', 'manage_options', 'pixel-your-site', 'pys_admin_page_callback' );
57
 
58
  }
59
 
5
  Plugin URI: http://www.pixelyoursite.com/facebook-pixel-plugin-help
6
  Author: PixelYourSite
7
  Author URI: http://www.pixelyoursite.com
8
+ Version: 3.1.0
9
  License: GPLv3
10
  */
11
 
16
  error_reporting( E_ALL );
17
  }
18
 
19
+ define( 'PYS_FREE_VERSION_REAL', '3.1.0');
20
+ define( 'PYS_FREE_VERSION', '3.0.2'); // for plugin notices capability
21
 
22
  require_once( 'inc/common.php' );
23
  require_once( 'inc/admin_notices.php' );
27
  add_action( 'plugins_loaded', 'pys_free_init' );
28
  function pys_free_init() {
29
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  $options = get_option( 'pixel_your_site' );
31
  if ( ! $options || ! isset( $options['general']['pixel_id'] ) || empty( $options['general']['pixel_id'] ) ) {
 
32
  pys_initialize_settings();
33
+ }
34
+
35
+ if( is_admin() || pys_get_option( 'general', 'enabled' ) == false || pys_is_disabled_for_role() || ! pys_get_option( 'general', 'pixel_id' ) ) {
36
+ return;
37
+ }
38
+
39
+ add_action( 'wp_head', 'pys_pixel_code', 1 ); // display Facebook Pixel Code
40
+ add_action( 'wp_enqueue_scripts', 'pys_public_scripts' );
41
 
42
+ // add addtocart ajax support only if woocommerce installed and events enabled
43
+ if ( pys_is_woocommerce_active() && pys_get_option( 'woo', 'enabled' ) && pys_get_option( 'woo', 'on_add_to_cart_btn' ) ) {
44
+ add_filter( 'woocommerce_loop_add_to_cart_link', 'pys_add_code_to_woo_cart_link', 10, 2 );
45
  }
46
 
47
  }
52
  add_action( 'admin_menu', 'pys_admin_menu' );
53
  function pys_admin_menu() {
54
 
55
+ add_menu_page( 'PixelYourSite', 'PixelYourSite', 'manage_options', 'pixel-your-site', 'pys_admin_page_callback', plugins_url( 'pixelyoursite/img/favicon.png' ) );
56
 
57
  }
58
 
img/favicon.png ADDED
Binary file
inc/admin_notices.php CHANGED
@@ -9,11 +9,11 @@ $version = get_option('pysf_plugin_version', '');
9
  $current_time = time();
10
 
11
  if( empty($activation_time) || version_compare($version, PYS_FREE_VERSION, '<') ){
12
- $activation_time = $current_time;
13
- update_option( 'pysf_activation_date', $activation_time);
14
- update_option( 'pysf_plugin_version', PYS_FREE_VERSION);
15
- update_option( 'pysf_notice_dismiss', '');
16
- update_option( 'woo_pysf_notice_dismiss', '');
17
  }
18
 
19
 
@@ -33,80 +33,80 @@ $link_2 = 'http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wadmin&
33
 
34
 
35
  //Message for day 1
36
- $day_1_text = '<span class="pysf_note"><b>Update to PixelYourSite Pro </b></span> and optimize your FB ads for clicks on links or buttons with Dynamic Events: ';
37
- $day_1_text .= '<a href="http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click to download PixelYourSite Pro for a big discount</a>';
38
 
39
  //Message for day 2
40
- $day_2_text = '<span class="pysf_note"><b>Use Dynamic Events: </b></span> and optimize your ads for actions on site (clicks on links or buttons): ';
41
- $day_2_text .= '<a href="http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Download PixelYourSite Pro for a limited discount</a>';
42
 
43
  //Message for day 3
44
- $day_3_text = '<span class="pysf_note"><b>Last Chance Now</b></span> With Dynamic Events you can improve List Generation or Affiliate Campaigns. Optimize your FB Ads for actions on your site with PixelYourSite Pro: ';
45
- $day_3_text .= '<a href="http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Download Now (offer ending soon)</a>';
46
 
47
  //Message for day 4 to 7;
48
- $day_4_to_7_text = '<span class="pysf_note"><b>Thank You for Using PixelYourSite!</b></span> We put many hours into developing and mantaining this plugin, but having you on board makes us proud and happy. If you like PixelYourSite <a href="https://wordpress.org/support/view/plugin-reviews/pixelyoursite?rate=5#postform" target="_blank">click here to give us a 5 stars rating</a>, because it will mean a lot for our team';
49
 
50
 
51
  //Message for day 7 to 12
52
- $day_7_to_12_text = '<span class="pysf_note"><b>Grab Your Free Guide Now: </b></span> The new Generarl Event option can be used to create powerful Custom Audiences. Since it is a very useful tool, we made a free guide about how to use it: <a href="http://www.pixelyoursite.com/general-event?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click here for your Guide</a>';
53
 
54
  $options = array(
55
 
56
 
57
- //message for day 1
58
- array(
59
 
60
- 'day' => 1,
61
- 'message' => $day_1_text,
62
- 'visibility' => 'visible', /* visible OR hidden */
63
 
64
- ),
65
 
66
- //message for day 2
67
- array(
68
 
69
- 'day' => 2,
70
- 'message' => $day_2_text,
71
- 'visibility' => 'visible', /* visible OR hidden */
72
 
73
 
74
- ),
75
 
76
- //message for day 3
77
- array(
78
 
79
- 'day' => 3,
80
- 'message' => $day_3_text,
81
- 'visibility' => 'visible', /* visible OR hidden */
82
 
83
 
84
- ),
85
 
86
 
87
- //message for day 4-7
88
- //This will start on day 4
89
- //and end on day 7
90
- array(
91
 
92
- 'day' => '4-7',
93
- 'message' => $day_4_to_7_text,
94
- 'visibility' => 'hidden', /* visible OR hidden */
95
 
96
 
97
- ),
98
 
99
- //message for day 7-12
100
- //This will start on day 7
101
- //and end on day 12
102
- array(
103
 
104
- 'day' => '7-12',
105
- 'message' => $day_7_to_12_text,
106
- 'visibility' => 'visible', /* visible OR hidden */
107
 
108
 
109
- ),
110
 
111
 
112
  );
@@ -115,90 +115,92 @@ $options = array(
115
  //Messages when WooCommerce is installed and activated
116
 
117
  //WooCommerce Message for day 1
118
- $woo_day_1_text = 'WooCommerce Day 2 Message.';
119
- $woo_day_1_text = '<span class="pysf_note"><b>PixelYourSite PRO + Product Catalog Feed Plugin Bundle:</b></span> Track Conversion Value and start with Facebook Dynamic Ads for WooCommerce in minutes. Get both plugins for a fantastic price: ';
120
- $woo_day_1_text .= '<a href="http://www.pixelyoursite.com/bundle-offer?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click to DOWNLOAD the bundle now (best deal)</a>';
121
 
122
 
123
 
124
  //WooCommerce Message for day 2
125
  $woo_day_2_text = 'WooCommerce Day 2 Message.';
126
- $woo_day_2_text = '<span class="pysf_note"><b>Customize and Track WooCommerce Conversion Value</b></span> With PixelYourSite Pro you can fine tune each Event value and improve conversion tracking. ';
127
- $woo_day_2_text .= '<a href="http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click to download PixelYourSite Pro for a serious discount</a>';
128
 
129
 
130
  //WooCommerce Message for day 3
131
  $woo_day_3_text = 'WooCommerce Day 3 Message.';
132
- $woo_day_3_text = '<span class="pysf_note"><b>Product Catalog Feed Plugin</b></span> Create unlimited WooCommerce XML feeds for Facebook Dynamic Ads with just a few clicks. ';
133
- $woo_day_3_text .= '<a href="http://www.pixelyoursite.com/product-catalog-facebook?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click to download Product Catalog Feed</a>';
134
 
135
 
136
  //WooCommerce Message for day 4 to 7;
137
  $woo_day_4_to_7_text = 'WooCommerce Day 4 to 7 Message.';
138
- $woo_day_4_to_7_text = '<span class="pysf_note"><b>Get Your Free Guide</b></span> We have a new General Event Option that you can use to create Custom Audiences. Since this is a powerful feature, we made a <a href="http://www.pixelyoursite.com/general-event?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Special Guide on how to use it - click here to download</a>';
 
 
139
 
140
  //WooCommerce Message for day 7 to 12
141
  $woo_day_7_to_12_text = 'WooCommerce Day 7 to 12 Message.';
142
- $woo_day_7_to_12_text = '<span class="pysf_note"><b>Download Free Guide:</b></span> Find out powerful strategies for your WooCommerce website in the free guide about the General Event option <a href="http://www.pixelyoursite.com/general-event?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click here for your own copy</a>';
143
 
144
 
145
 
146
  $woo_options = array(
147
 
148
 
149
- //woocommerce message for day 1
150
- array(
151
 
152
- 'day' => 1,
153
- 'message' => $woo_day_1_text,
154
- 'visibility' => 'visible', /* visible OR hidden */
155
 
156
- ),
157
 
158
- //woocommerce message for day 2
159
- array(
160
 
161
- 'day' => 2,
162
- 'message' => $woo_day_2_text,
163
- 'visibility' => 'visible', /* visible OR hidden */
164
 
165
 
166
- ),
167
 
168
- //woocommerce message for day 3
169
- array(
170
 
171
- 'day' => 3,
172
- 'message' => $woo_day_3_text,
173
- 'visibility' => 'visible', /* visible OR hidden */
174
 
175
 
176
- ),
177
 
178
 
179
- //woocommerce message for day 4-7
180
- //This will start on day 4
181
- //and end on day 7
182
- array(
183
 
184
- 'day' => '4-7',
185
- 'message' => $woo_day_4_to_7_text,
186
- 'visibility' => 'hidden', /* visible OR hidden */
187
 
188
 
189
- ),
190
 
191
- //woocommerce message for day 7-12
192
- //This will start on day 7
193
- //and end on day 12
194
- array(
195
 
196
- 'day' => '7-12',
197
- 'message' => $woo_day_7_to_12_text,
198
- 'visibility' => 'visible', /* visible OR hidden */
199
 
200
 
201
- ),
202
 
203
 
204
  );
@@ -206,156 +208,158 @@ $woo_options = array(
206
 
207
 
208
 
209
-
210
- //we will store the message of each day
211
- $notice_message = '';
212
-
213
-
214
- if ( class_exists( 'WooCommerce' ) ) {
215
- //WooCommerce is installed
216
-
217
- //Get dismissed notices
218
- $dismiss_option = get_option( 'woo_pysf_notice_dismiss', '');
219
- $options = $woo_options;
220
-
221
- } else {
222
- //No WooCommerce
223
-
224
- //Get dismissed notices
225
- $dismiss_option = get_option( 'pysf_notice_dismiss', '');
226
-
227
- }
228
-
229
-
230
- //loop through notice settings
231
- foreach ($options as $key => $option) {
232
-
233
- $is_dismissed = isset( $dismiss_option[$option['day']] ) ? true : false;
234
-
235
- if( is_integer( $option['day']) ){
236
-
237
- //check if there is a message for a day and that it is on
238
- if( !$is_dismissed && $option['day'] == $days_passed && $option['visibility'] == 'visible' ){
239
-
240
- $dismiss_option = $option['day'];
241
- $notice_message = $option['message'];
242
- break;
243
- }
244
-
245
- } else {
246
-
247
- //check range of days
248
-
249
- $pieces = explode('-', $option['day']);
250
- $start = $pieces[0];
251
- $end = $pieces[1];
252
-
253
- //check if there is a message for a day and that it is on
254
- if( !$is_dismissed && ( $days_passed >= $start && $days_passed <= $end) && $option['visibility'] == 'visible' ){
255
-
256
- $dismiss_option = $option['day'];
257
- $notice_message = $option['message'];
258
- break;
259
- }
260
-
261
-
262
- }
263
- }
264
-
265
-
266
- if( !empty( $notice_message ) ){
267
-
268
- $notice = '<style type="text/css">
269
- .pysf_note{ color: #dd4e4e; }
270
- #pysf_notice {
271
- border-left-width: 10px;
272
- display: block;
273
- margin: 25px 20px 10px 2px;
274
- padding: 4px 10px;
275
- }
276
- #pysf_notice p{ width:98%;}
277
- .pysf_clear{ clear:both;}
278
- </style>';
279
-
280
- $html_class = '';
281
- $html_id = 'pysf_notice_tab';
282
- $button_html = '<button type="button" class="notice-dismiss" title="Dismiss Notice"><span class="screen-reader-text">Dismiss this notice.</span></button>';
283
- if( !$return){
284
- $html_class = 'update-nag notice is-dismissible';
285
- $html_id = 'pysf_notice';
286
- $button_html = '';
287
- }
288
-
289
- $notice .= '<div id="'.$html_id.'" class="'.$html_class.' pysf_clear pysf_notice pysf_notice_day_'.$dismiss_option.'" data-pysf="pysf_notice_day_'.$dismiss_option.'">';
290
- $notice .= '<p>'.$notice_message.'</p>';
291
- $notice .= $button_html;
292
- $notice .= '</div>';
293
-
294
- $notice .= "<script type='text/javascript'>
295
- jQuery(function($){
296
-
297
- jQuery(document).on( 'click', '.pysf_notice .notice-dismiss', function() {
298
-
299
- jQuery(this).closest('.notice-dismiss').fadeOut('slow');
300
-
301
- jQuery.ajax({
302
- url: ajaxurl,
303
- data: {
304
- action: 'pysf_notice_dismiss',
305
- option: '".$dismiss_option."'
306
- }
307
- });
308
-
309
- });
310
-
311
- });
312
- </script>";
313
-
314
- if( !$return)
315
- echo $notice;
316
- else
317
- return $notice;
318
- }
319
 
320
  }
321
 
322
 
323
 
324
  function woofp_admin_notices_action(){
325
- woofp_admin_notices();
326
  }
327
  if( isset($_GET['page']) && $_GET['page'] == 'woo-facebookpixel' ){
328
 
329
  } else {
330
- add_action( 'admin_notices', 'woofp_admin_notices_action' );
331
  }
332
 
333
  function ajax_pysf_notice_dismiss(){
334
 
335
- if ( class_exists( 'WooCommerce' ) ) {
336
- $name = 'woo_pysf_notice_dismiss';
337
- } else {
338
- $name = 'pysf_notice_dismiss';
339
- }
340
 
341
- if( isset($_REQUEST['option'])){
342
- $dismiss_option = get_option( $name, '');
343
- $dismiss_option[$_REQUEST['option']] = 1;
344
- update_option( $name, $dismiss_option);
345
- }
346
 
347
- die();
348
  }
349
  add_action('wp_ajax_pysf_notice_dismiss', 'ajax_pysf_notice_dismiss');
350
 
351
  //get number of days passed since activation
352
  function woofp_days_passed($current_time, $activation_time){
353
 
354
- $timepassed = $current_time-$activation_time;
355
- $timepassed = ( ( ( $timepassed/24 )/60 )/60 );
356
- $dayspassed = floor($timepassed);
357
- $dayspassed = $dayspassed + 1;
 
 
 
 
358
 
359
- return $dayspassed;
360
 
361
- }
9
  $current_time = time();
10
 
11
  if( empty($activation_time) || version_compare($version, PYS_FREE_VERSION, '<') ){
12
+ $activation_time = $current_time;
13
+ update_option( 'pysf_activation_date', $activation_time);
14
+ update_option( 'pysf_plugin_version', PYS_FREE_VERSION);
15
+ update_option( 'pysf_notice_dismiss', '');
16
+ update_option( 'woo_pysf_notice_dismiss', '');
17
  }
18
 
19
 
33
 
34
 
35
  //Message for day 1
36
+ $day_1_text = '<span class="pysf_note"><b>Update to PixelYourSite Pro </b></span> and optimize your FB ads for clicks on links or buttons with <b>Dynamic Events</b>. Enable <i>time on page</i> parameter, or improve conversion attribution and retargeting reach by using <b>Advanced Matching</b>. Don’t miss this limited discount:<br> ';
37
+ $day_1_text .= '<a href="http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank"><b>Click to download PixelYourSite Pro for a big discount</b></a>';
38
 
39
  //Message for day 2
40
+ $day_2_text = '<span class="pysf_note"><b>Use Dynamic Events </b></span> and optimize your ads for <b>actions on site</b> (clicks on links or buttons). Use Time on Page for key pages Custom Audiences:<br>';
41
+ $day_2_text .= '<a href="http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank"><b>Download PixelYourSite Pro for a limited discount</b></a>';
42
 
43
  //Message for day 3
44
+ $day_3_text = '<span class="pysf_note"><b>Last Chance for this discount:</b></span> With PixelYourSite Pro you can use <b>Dynamic Events</b> (optimize campaigns for actions on your site), track <b>Time on Page</b> (create super powerful Custom Audiences for key pages), plus enable <b>Advanced Matching</b> (new FB feature that increases conversion attribution and reach for retargeting campaigns): <br>';
45
+ $day_3_text .= '<a href="http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank"><b>Download Now (offer ending soon)</b></a>';
46
 
47
  //Message for day 4 to 7;
48
+ $day_4_to_7_text = '<span class="pysf_note"><b>How to Build Custom Audiences with PixelYourSite:</b></span> The new GeneralEvent option can be used to create powerful Custom Audiences. Since it is a very useful tool, we made this <b>FREE guide</b> about how to use it: <a href="http://www.pixelyoursite.com/general-event?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click here for your Guide</a>';
49
 
50
 
51
  //Message for day 7 to 12
52
+ $day_7_to_12_text = '<span class="pysf_note"><b>Grab Your Free Guide from PixelYourSite Now: </b></span> This is how the new GeneralEvent option can be used to create powerful Custom Audiences that will improve your Facebook Ads profitability:<br><a href="http://www.pixelyoursite.com/general-event?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click here for your FREE Guide</a>';
53
 
54
  $options = array(
55
 
56
 
57
+ //message for day 1
58
+ array(
59
 
60
+ 'day' => 1,
61
+ 'message' => $day_1_text,
62
+ 'visibility' => 'visible', /* visible OR hidden */
63
 
64
+ ),
65
 
66
+ //message for day 2
67
+ array(
68
 
69
+ 'day' => 2,
70
+ 'message' => $day_2_text,
71
+ 'visibility' => 'visible', /* visible OR hidden */
72
 
73
 
74
+ ),
75
 
76
+ //message for day 3
77
+ array(
78
 
79
+ 'day' => 3,
80
+ 'message' => $day_3_text,
81
+ 'visibility' => 'visible', /* visible OR hidden */
82
 
83
 
84
+ ),
85
 
86
 
87
+ //message for day 4-7
88
+ //This will start on day 4
89
+ //and end on day 7
90
+ array(
91
 
92
+ 'day' => '4-7',
93
+ 'message' => $day_4_to_7_text,
94
+ 'visibility' => 'hidden', /* visible OR hidden */
95
 
96
 
97
+ ),
98
 
99
+ //message for day 7-12
100
+ //This will start on day 7
101
+ //and end on day 12
102
+ array(
103
 
104
+ 'day' => '7-12',
105
+ 'message' => $day_7_to_12_text,
106
+ 'visibility' => 'visible', /* visible OR hidden */
107
 
108
 
109
+ ),
110
 
111
 
112
  );
115
  //Messages when WooCommerce is installed and activated
116
 
117
  //WooCommerce Message for day 1
118
+ $woo_day_1_text = 'WooCommerce Day 1 Message.';
119
+ $woo_day_1_text = '<span class="pysf_note"><b>PixelYourSite PRO + Product Catalog Feed Plugin Bundle:</b></span> Track Conversion Value and start with Facebook Dynamic Ads for WooCommerce in minutes. <br>Get <b>PixelYourSite Pro</b> (<i>fine tune Conversion Vaule</i>, optimize WooCommerce events for Cutom Audiences, track tags, product tags and Time on Page, enable Advanced Matching and use <i>Dynamic Events</i>)<br>Get <b>Product Catalog Feed Plugin</b> (create WooCommerce Dynamic Ads Product Catalog XML feeds)<br> ';
120
+ $woo_day_1_text .= '<a href="http://www.pixelyoursite.com/bundle-offer?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank"><b>Click to DOWNLOAD the bundle now (best deal)</b></a>';
121
 
122
 
123
 
124
  //WooCommerce Message for day 2
125
  $woo_day_2_text = 'WooCommerce Day 2 Message.';
126
+ $woo_day_2_text = '<span class="pysf_note"><b>Customize and Track WooCommerce Conversion Value:</b></span> With PixelYourSite Pro you can <b>fine tune WooCommerce Events Values</b> and improve conversion tracking. <b>Time on page</b> is tracked and can be used for Custom Audiences, as well as tags or <b>product tags</b>. With <b>Dynamic Events</b> you can optimize FB ads for actions on your site (clicks on links and buttons) and <b>Advanced Matching</b> will improve conversion attribution and reach of retargeting campaigns.<br> ';
127
+ $woo_day_2_text .= '<a href="http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank"><b>Click to download PixelYourSite Pro for a serious discount</b></a>';
128
 
129
 
130
  //WooCommerce Message for day 3
131
  $woo_day_3_text = 'WooCommerce Day 3 Message.';
132
+ $woo_day_3_text = '<span class="pysf_note"><b>Product Catalog Feed Plugin:</b></span> Create unlimited <b>WooCommerce XML feeds for Facebook Dynamic Ads Product Catalog</b> with just a few clicks. ';
133
+ $woo_day_3_text .= '<a href="http://www.pixelyoursite.com/product-catalog-facebook?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank"><b>Click to download Product Catalog Feed</b></a>';
134
 
135
 
136
  //WooCommerce Message for day 4 to 7;
137
  $woo_day_4_to_7_text = 'WooCommerce Day 4 to 7 Message.';
138
+ $woo_day_4_to_7_text = '<span class="pysf_note"><b>Track Time on Page:</b></span> With PixelYourSite Pro you can track <b>Time on Page</b> and use it to build super powerful Custom Audiences for key pages. <b>Advanced Matching</b> is supported and will improve conversion attribution and retargeting reach. Improving your Facebook Ads is easy: <br> ';
139
+ $woo_day_4_to_7_text .= '<a href="http://www.pixelyoursite.com/facebook-pixel-plugin?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click to download PixelYourSite Pro for a serious discount</a>';
140
+
141
 
142
  //WooCommerce Message for day 7 to 12
143
  $woo_day_7_to_12_text = 'WooCommerce Day 7 to 12 Message.';
144
+ $woo_day_7_to_12_text = '<span class="pysf_note"><b>How build Custom Audiences - PixelYourSite Free Guide:</b></span> Find out powerful strategies for your WooCommerce website in this <b>FREE guide</b> about the new General Event option (it helps you with Custom Audiences):<br> <a href="http://www.pixelyoursite.com/general-event?utm_source=wpadmin-update&utm_medium=update&utm_campaign=update" target="_blank">Click here for your own FREE copy</a>';
145
 
146
 
147
 
148
  $woo_options = array(
149
 
150
 
151
+ //woocommerce message for day 1
152
+ array(
153
 
154
+ 'day' => 1,
155
+ 'message' => $woo_day_1_text,
156
+ 'visibility' => 'visible', /* visible OR hidden */
157
 
158
+ ),
159
 
160
+ //woocommerce message for day 2
161
+ array(
162
 
163
+ 'day' => 2,
164
+ 'message' => $woo_day_2_text,
165
+ 'visibility' => 'visible', /* visible OR hidden */
166
 
167
 
168
+ ),
169
 
170
+ //woocommerce message for day 3
171
+ array(
172
 
173
+ 'day' => 3,
174
+ 'message' => $woo_day_3_text,
175
+ 'visibility' => 'visible', /* visible OR hidden */
176
 
177
 
178
+ ),
179
 
180
 
181
+ //woocommerce message for day 4-7
182
+ //This will start on day 4
183
+ //and end on day 7
184
+ array(
185
 
186
+ 'day' => '4-7',
187
+ 'message' => $woo_day_4_to_7_text,
188
+ 'visibility' => 'hidden', /* visible OR hidden */
189
 
190
 
191
+ ),
192
 
193
+ //woocommerce message for day 7-12
194
+ //This will start on day 7
195
+ //and end on day 12
196
+ array(
197
 
198
+ 'day' => '7-12',
199
+ 'message' => $woo_day_7_to_12_text,
200
+ 'visibility' => 'visible', /* visible OR hidden */
201
 
202
 
203
+ ),
204
 
205
 
206
  );
208
 
209
 
210
 
211
+
212
+ //we will store the message of each day
213
+ $notice_message = '';
214
+
215
+
216
+ if ( class_exists( 'WooCommerce' ) ) {
217
+ //WooCommerce is installed
218
+
219
+ //Get dismissed notices
220
+ $dismiss_option = get_option( 'woo_pysf_notice_dismiss', '');
221
+ $options = $woo_options;
222
+
223
+ } else {
224
+ //No WooCommerce
225
+
226
+ //Get dismissed notices
227
+ $dismiss_option = get_option( 'pysf_notice_dismiss', '');
228
+
229
+ }
230
+
231
+
232
+ //loop through notice settings
233
+ foreach ($options as $key => $option) {
234
+
235
+ $is_dismissed = isset( $dismiss_option[$option['day']] ) ? true : false;
236
+
237
+ if( is_integer( $option['day']) ){
238
+
239
+ //check if there is a message for a day and that it is on
240
+ if( !$is_dismissed && $option['day'] == $days_passed && $option['visibility'] == 'visible' ){
241
+
242
+ $dismiss_option = $option['day'];
243
+ $notice_message = $option['message'];
244
+ break;
245
+ }
246
+
247
+ } else {
248
+
249
+ //check range of days
250
+
251
+ $pieces = explode('-', $option['day']);
252
+ $start = $pieces[0];
253
+ $end = $pieces[1];
254
+
255
+ //check if there is a message for a day and that it is on
256
+ if( !$is_dismissed && ( $days_passed >= $start && $days_passed <= $end) && $option['visibility'] == 'visible' ){
257
+
258
+ $dismiss_option = $option['day'];
259
+ $notice_message = $option['message'];
260
+ break;
261
+ }
262
+
263
+
264
+ }
265
+ }
266
+
267
+
268
+ if( !empty( $notice_message ) ){
269
+
270
+ $notice = '<style type="text/css">
271
+ .pysf_note{ color: #dd4e4e; }
272
+ #pysf_notice {
273
+ border-left-width: 10px;
274
+ display: block;
275
+ margin: 25px 20px 10px 2px;
276
+ padding: 4px 10px;
277
+ }
278
+ #pysf_notice p{ width:98%;}
279
+ .pysf_clear{ clear:both;}
280
+ </style>';
281
+
282
+ $html_class = '';
283
+ $html_id = 'pysf_notice_tab';
284
+ $button_html = '<button type="button" class="notice-dismiss" title="Dismiss Notice"><span class="screen-reader-text">Dismiss this notice.</span></button>';
285
+ if( !$return){
286
+ $html_class = 'update-nag notice is-dismissible';
287
+ $html_id = 'pysf_notice';
288
+ $button_html = '';
289
+ }
290
+
291
+ $notice .= '<div id="'.$html_id.'" class="'.$html_class.' pysf_clear pysf_notice pysf_notice_day_'.$dismiss_option.'" data-pysf="pysf_notice_day_'.$dismiss_option.'">';
292
+ $notice .= '<p>'.$notice_message.'</p>';
293
+ $notice .= $button_html;
294
+ $notice .= '</div>';
295
+
296
+ $notice .= "<script type='text/javascript'>
297
+ jQuery(function($){
298
+
299
+ jQuery(document).on( 'click', '.pysf_notice .notice-dismiss', function() {
300
+
301
+ jQuery(this).closest('.notice-dismiss').fadeOut('slow');
302
+
303
+ jQuery.ajax({
304
+ url: ajaxurl,
305
+ data: {
306
+ action: 'pysf_notice_dismiss',
307
+ option: '".$dismiss_option."'
308
+ }
309
+ });
310
+
311
+ });
312
+
313
+ });
314
+ </script>";
315
+
316
+ if( !$return)
317
+ echo $notice;
318
+ else
319
+ return $notice;
320
+ }
321
 
322
  }
323
 
324
 
325
 
326
  function woofp_admin_notices_action(){
327
+ woofp_admin_notices();
328
  }
329
  if( isset($_GET['page']) && $_GET['page'] == 'woo-facebookpixel' ){
330
 
331
  } else {
332
+ add_action( 'admin_notices', 'woofp_admin_notices_action' );
333
  }
334
 
335
  function ajax_pysf_notice_dismiss(){
336
 
337
+ if ( class_exists( 'WooCommerce' ) ) {
338
+ $name = 'woo_pysf_notice_dismiss';
339
+ } else {
340
+ $name = 'pysf_notice_dismiss';
341
+ }
342
 
343
+ if( isset($_REQUEST['option'])){
344
+ $dismiss_option = get_option( $name, '');
345
+ $dismiss_option[$_REQUEST['option']] = 1;
346
+ update_option( $name, $dismiss_option);
347
+ }
348
 
349
+ die();
350
  }
351
  add_action('wp_ajax_pysf_notice_dismiss', 'ajax_pysf_notice_dismiss');
352
 
353
  //get number of days passed since activation
354
  function woofp_days_passed($current_time, $activation_time){
355
 
356
+ $timepassed = $current_time-$activation_time;
357
+ $timepassed = ( ( ( $timepassed/24 )/60 )/60 );
358
+ $dayspassed = floor($timepassed);
359
+ $dayspassed = $dayspassed + 1;
360
+
361
+ return $dayspassed;
362
+
363
+ }
364
 
 
365
 
 
inc/ajax-standard.php CHANGED
@@ -24,7 +24,7 @@ if( !function_exists( 'pys_edit_std_event' ) ) {
24
  <tr>
25
  <td class="legend"><p class="label">URL:</p></td>
26
  <td>
27
- <input type="text" name="std_event[pageurl]" value="<?php echo $std_event['pageurl']; ?>">
28
  <span class="help">Event will trigger when this URL is visited.<br>If you add * at the end of the URL string, it will match all URLs starting with the this string.</span>
29
  </td>
30
  </tr>
@@ -140,7 +140,7 @@ if( !function_exists( 'pys_edit_std_event' ) ) {
140
  <tr class="CustomEvent-visible">
141
  <td class="legend"></td>
142
  <td>
143
- <p><strong>This is a PRO feature</strong> - <a href="http://www.pixelyoursite.com/facebook-pixel-plugin">Update NOW</a></p>
144
  </td>
145
  </tr>
146
 
@@ -148,7 +148,7 @@ if( !function_exists( 'pys_edit_std_event' ) ) {
148
 
149
  <div class="actions-row">
150
  <a href="#" class="button button-close action">Cancel</a>
151
- <a href="#" class="button button-save button-primary action"><?php echo isset( $_REQUEST['id'] ) == true ? 'Save' : 'Add'; ?></a>
152
  </div>
153
 
154
  </form>
@@ -156,6 +156,8 @@ if( !function_exists( 'pys_edit_std_event' ) ) {
156
  <script>
157
  jQuery(function ($) {
158
 
 
 
159
  /* Standard event fields show/hide on event type change. */
160
  $('#std-event-type').on('change', function () {
161
  var wrapper = $(this).closest('table');
@@ -163,6 +165,9 @@ if( !function_exists( 'pys_edit_std_event' ) ) {
163
  wrapper.removeClass(); // clear all classes
164
  wrapper.addClass('layout');
165
  wrapper.addClass(this.value);
 
 
 
166
  });
167
 
168
  /* Close modal window */
@@ -175,6 +180,10 @@ if( !function_exists( 'pys_edit_std_event' ) ) {
175
  $('.button-save').on('click', function (e) {
176
  e.preventDefault();
177
 
 
 
 
 
178
  $('#std-event-form').addClass('disabled');
179
  $(this).text('Saving...');
180
 
@@ -197,6 +206,40 @@ if( !function_exists( 'pys_edit_std_event' ) ) {
197
 
198
  });
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  });
201
  </script>
202
 
24
  <tr>
25
  <td class="legend"><p class="label">URL:</p></td>
26
  <td>
27
+ <input type="text" name="std_event[pageurl]" value="<?php echo $std_event['pageurl']; ?>" id="std-url">
28
  <span class="help">Event will trigger when this URL is visited.<br>If you add * at the end of the URL string, it will match all URLs starting with the this string.</span>
29
  </td>
30
  </tr>
140
  <tr class="CustomEvent-visible">
141
  <td class="legend"></td>
142
  <td>
143
+ <a href="#" class="button button-add-row button-primary action">Add Param</a>
144
  </td>
145
  </tr>
146
 
148
 
149
  <div class="actions-row">
150
  <a href="#" class="button button-close action">Cancel</a>
151
+ <a href="#" class="button button-save button-primary action disabled"><?php echo isset( $_REQUEST['id'] ) == true ? 'Save' : 'Add'; ?></a>
152
  </div>
153
 
154
  </form>
156
  <script>
157
  jQuery(function ($) {
158
 
159
+ validate();
160
+
161
  /* Standard event fields show/hide on event type change. */
162
  $('#std-event-type').on('change', function () {
163
  var wrapper = $(this).closest('table');
165
  wrapper.removeClass(); // clear all classes
166
  wrapper.addClass('layout');
167
  wrapper.addClass(this.value);
168
+
169
+ validate();
170
+
171
  });
172
 
173
  /* Close modal window */
180
  $('.button-save').on('click', function (e) {
181
  e.preventDefault();
182
 
183
+ if( validate() == false ) {
184
+ return;
185
+ }
186
+
187
  $('#std-event-form').addClass('disabled');
188
  $(this).text('Saving...');
189
 
206
 
207
  });
208
 
209
+ // Form validation
210
+ $('form').submit(function(e) {
211
+
212
+ if( validate() == false ) {
213
+ e.preventDefault();
214
+ }
215
+
216
+ });
217
+
218
+ $('#std-url').on( 'change, keyup', function(e){
219
+ validate();
220
+ });
221
+
222
+ function validate() {
223
+
224
+ var pageURL = $('#std-url').val(),
225
+ eventType = $('#std-event-type').val(),
226
+ btnSave = $('.button-save'),
227
+ isValid = true;
228
+
229
+ if( eventType == null || pageURL.length == 0 ) {
230
+ isValid = false;
231
+ }
232
+
233
+ if( isValid ) {
234
+ btnSave.removeClass('disabled');
235
+ } else {
236
+ btnSave.addClass('disabled');
237
+ }
238
+
239
+ return isValid;
240
+
241
+ }
242
+
243
  });
244
  </script>
245
 
inc/common.php CHANGED
@@ -172,7 +172,6 @@ if( !function_exists( 'pys_get_relative_path' ) ) {
172
 
173
  /**
174
  * Check if needle URL (full or relative) matches with current.
175
- * @todo: review and test
176
  */
177
  if( !function_exists( 'pys_match_url' ) ) {
178
 
@@ -235,6 +234,8 @@ if( !function_exists( 'pys_clean_param_value' ) ) {
235
 
236
  function pys_clean_param_value( $value ) {
237
 
 
 
238
  $replace = array(
239
  '&lt;' => '',
240
  '&gt;' => '',
@@ -517,38 +518,42 @@ if( !function_exists( 'pys_clean_param_value' ) ) {
517
  if( !function_exists( 'pys_currency_options' ) ) {
518
 
519
  function pys_currency_options( $current = 'USD' ) {
520
- ?>
521
 
522
- <option <?php echo selected( 'AUD', $current, true ); ?> value="AUD">Australian Dollar</option>
523
- <option <?php echo selected( 'BRL', $current, true ); ?> value="BRL">Brazilian Real</option>
524
- <option <?php echo selected( 'CAD', $current, true ); ?> value="CAD">Canadian Dollar</option>
525
- <option <?php echo selected( 'CZK', $current, true ); ?> value="CZK">Czech Koruna</option>
526
- <option <?php echo selected( 'DKK', $current, true ); ?> value="DKK">Danish Krone</option>
527
- <option <?php echo selected( 'EUR', $current, true ); ?> value="EUR">Euro</option>
528
- <option <?php echo selected( 'HKD', $current, true ); ?> value="HKD">Hong Kong Dollar</option>
529
- <option <?php echo selected( 'HUF', $current, true ); ?> value="HUF">Hungarian Forint</option>
530
- <option <?php echo selected( 'IDR', $current, true ); ?> value="IDR">Indonesian Rupiah</option>
531
- <option <?php echo selected( 'ILS', $current, true ); ?> value="ILS">Israeli New Sheqel</option>
532
- <option <?php echo selected( 'JPY', $current, true ); ?> value="JPY">Japanese Yen</option>
533
- <option <?php echo selected( 'KRW', $current, true ); ?> value="KRW">Korean Won</option>
534
- <option <?php echo selected( 'MYR', $current, true ); ?> value="MYR">Malaysian Ringgit</option>
535
- <option <?php echo selected( 'MXN', $current, true ); ?> value="MXN">Mexican Peso</option>
536
- <option <?php echo selected( 'NOK', $current, true ); ?> value="NOK">Norwegian Krone</option>
537
- <option <?php echo selected( 'NZD', $current, true ); ?> value="NZD">New Zealand Dollar</option>
538
- <option <?php echo selected( 'PHP', $current, true ); ?> value="PHP">Philippine Peso</option>
539
- <option <?php echo selected( 'PLN', $current, true ); ?> value="PLN">Polish Zloty</option>
540
- <option <?php echo selected( 'RON', $current, true ); ?> value="RON">Romanian Leu</option>
541
- <option <?php echo selected( 'GBP', $current, true ); ?> value="GBP">Pound Sterling</option>
542
- <option <?php echo selected( 'SGD', $current, true ); ?> value="SGD">Singapore Dollar</option>
543
- <option <?php echo selected( 'SEK', $current, true ); ?> value="SEK">Swedish Krona</option>
544
- <option <?php echo selected( 'CHF', $current, true ); ?> value="CHF">Swiss Franc</option>
545
- <option <?php echo selected( 'TWD', $current, true ); ?> value="TWD">Taiwan New Dollar</option>
546
- <option <?php echo selected( 'THB', $current, true ); ?> value="THB">Thai Baht</option>
547
- <option <?php echo selected( 'TRY', $current, true ); ?> value="TRY">Turkish Lira</option>
548
- <option <?php echo selected( 'USD', $current, true ); ?> value="USD">U.S. Dollar</option>
549
- <option <?php echo selected( 'ZAR', $current, true ); ?> value="USD">South African Rands</option>
 
 
 
 
 
 
550
 
551
- <?php
552
  }
553
 
554
  }
@@ -631,9 +636,9 @@ if( !function_exists( 'pys_explode_taxonomies' ) ) {
631
  $str = '';
632
  foreach ( $tree as $node ) {
633
 
634
- if ( isset( $node['children'] ) && count( $node['children'] ) ) {
635
 
636
- $str .= $node['name'] . ' > ';
637
  $str .= pys_explode_taxonomies( $node['children'] );
638
 
639
  } else {
@@ -670,113 +675,50 @@ if( !function_exists( 'pys_get_noscript_code' ) ) {
670
 
671
  $src = add_query_arg( $args, 'https://www.facebook.com/tr' );
672
 
673
- $nojscode = "<noscript>\n";
674
- $nojscode .= "<img height='1' width='1' style='display:none' src='" . $src . "'>\n";
675
- $nojscode .= "</noscript>";
676
- $nojscode .= "\n\n";
677
-
678
- return $nojscode;
679
-
680
- }
681
-
682
- }
683
-
684
- /**
685
- * Prepare event code string for Standard Event.
686
- */
687
- if( !function_exists( 'pys_get_event_code' ) ) {
688
-
689
- //@todo: replace this function with `pys_build_event_pixel_code`
690
- function pys_get_event_code( $event ) {
691
-
692
- $result = array();
693
-
694
- // remember event type
695
- $type = $event['eventtype'];
696
-
697
- // remove unused params
698
- unset( $event['pageurl'] );
699
- unset( $event['eventtype'] );
700
- unset( $event['code'] );
701
- unset( $event['trigger_type'] ); // pro
702
- unset( $event['url'] ); // pro
703
- unset( $event['css'] ); // pro
704
- unset( $event['custom_name'] ); // custom events
705
-
706
- if ( $event['content_type'] == 'none' ) {
707
- unset( $event['content_type'] );
708
- }
709
-
710
- $track = pys_is_standard_event( $type ) ? 'track' : 'trackCustom';
711
-
712
- // @todo: sanitize event type name
713
-
714
- $js_str = "";
715
- $nojs_params = array();
716
-
717
- // build js and no js codes from params
718
- if ( isset( $event ) && ! empty( $event ) ) {
719
- foreach ( $event as $param => $value ) {
720
-
721
- if ( empty( $value ) ) {
722
- continue;
723
- }
724
-
725
- $val = pys_clean_param_value( $value );
726
-
727
- $js_str .= "$param: '" . $val . "', ";
728
- $nojs_params[ $param ] = $val;
729
-
730
- }
731
- }
732
-
733
- $result['js'] = "fbq('$track', '$type', {" . $js_str . "} );";
734
- $result['nojs'] = pys_get_noscript_code( $type, $nojs_params );
735
 
736
- return $result;
737
  }
738
 
739
  }
740
 
741
  if( !function_exists( 'pys_build_event_pixel_code' ) ) {
742
 
743
- function pys_build_event_pixel_code( $name, array $params, $type ) {
 
 
744
 
745
- $result = array();
 
746
 
747
  // explode params to formatted string
748
- $js_str = "";
749
- $nojs_params = array();
750
- foreach ( $params as $param => $value ) {
751
 
752
- // skip cleanup
753
- if ( ! in_array( $param, array( 'content_ids', 'value', 'time' ) ) ) {
754
- $value = pys_clean_param_value( $value );
755
  }
756
 
757
- $js_str .= "$param: '" . $value . "', ";
758
- $nojs_params[ $param ] = $value;
 
 
 
759
 
760
- }
 
 
761
 
762
- $track = pys_is_standard_event( $type ) ? 'track' : 'trackCustom';
 
763
 
764
- // build complete event pixel code
765
- if ( $name ) {
766
- $pixelcode = "// " . ucfirst( $name ) . " Event \n";
767
- $pixelcode .= "fbq('$track', '$type', { $js_str } );";
768
- $pixelcode .= "\n\n";
769
- } else {
770
- $pixelcode = "fbq('$track', '$type', { $js_str } );";
771
  }
772
 
773
- $nojscode = "<!-- " . ucfirst( $name ) . " Event -->\n";
774
- $nojscode .= pys_get_noscript_code( $type, $nojs_params );
775
 
776
- $result['js'] = $pixelcode;
777
- $result['nojs'] = $nojscode;
 
 
778
 
779
- return $result;
780
  }
781
 
782
  }
@@ -850,7 +792,18 @@ if( !function_exists( 'pys_insert_attribute' ) ) {
850
  $attr_value = trim( $attr_value );
851
 
852
  $doc = new DOMDocument();
853
- $doc->loadHTML( '<?xml encoding="UTF-8">' . $tag, LIBXML_NOEMPTYTAG );
 
 
 
 
 
 
 
 
 
 
 
854
  $node = $doc->getElementsByTagName( $tag_name )->item(0);
855
 
856
  if( is_null( $node ) ) {
@@ -926,17 +879,22 @@ if( !function_exists( 'pys_is_disabled_for_role' ) ) {
926
 
927
  function pys_is_disabled_for_role() {
928
 
929
- // if disabled for current role
930
- $disabled_roles = get_option( 'pixel_your_site' );
 
931
  $user = wp_get_current_user();
932
  foreach ( (array) $user->roles as $role ) {
933
 
934
- if ( array_key_exists( "disable_for_$role", $disabled_roles['general'] ) ) {
935
  return true;
936
  }
937
 
938
  }
939
 
 
 
 
 
940
  return false;
941
 
942
  }
@@ -950,32 +908,19 @@ if( !function_exists( 'pys_pixel_code' ) ) {
950
 
951
  function pys_pixel_code() {
952
 
953
- // put pixel only on front-end
954
- if ( is_admin() ) {
955
- return;
956
- }
957
-
958
- // if pixel setup disabled
959
- if ( pys_get_option( 'general', 'enabled' ) == false ) {
960
- return;
961
- }
962
-
963
- // if ID is not set
964
  $pixel_id = pys_get_option( 'general', 'pixel_id' );
965
- if ( ! isset( $pixel_id ) || empty( $pixel_id ) ) {
966
- return;
967
- }
968
 
969
  // build pixel code...
970
  $pixelcode = "\n";
971
  $nojscode = "\n";
972
 
973
  // pixel id
974
- $pixelcode .= "fbq('init', '$pixel_id' " . pys_get_additional_matching_code() ." ); \n\n";
975
 
976
  // default event
977
- $pixelcode .= "// Default Event \n" . "fbq('track', 'PageView');" . "\n\n";
978
- $nojscode .= "<!-- Default Event -->\n" . pys_get_noscript_code( 'PageView', array() );
 
979
 
980
  // general event
981
  if ( pys_get_option( 'general', 'general_event_enabled' ) ) {
@@ -983,21 +928,19 @@ if( !function_exists( 'pys_pixel_code' ) ) {
983
  $code = pys_get_general_event_code();
984
 
985
  $pixelcode .= $code['js'];
986
- $nojscode .= $code['nojs'];
987
 
988
  }
989
 
990
  // search event
991
  if ( pys_get_option( 'general', 'search_event_enabled' ) && is_search() && isset( $_REQUEST['s'] ) ) {
992
 
993
- $pixelcode .= "// Search Event \n";
994
- $pixelcode .= "fbq('track', 'Search', { search_string: '" . pys_clean_param_value( $_REQUEST['s'] ) . "'} );";
995
- $pixelcode .= "\n\n";
996
 
997
- $nojscode .= "<!-- Search Event -->\n";
998
- $nojscode .= pys_get_noscript_code( 'Search', array(
999
- 'search_string' => pys_clean_param_value( $_REQUEST['s'] )
1000
- ) );
1001
 
1002
  }
1003
 
@@ -1005,27 +948,33 @@ if( !function_exists( 'pys_pixel_code' ) ) {
1005
  $std_events = get_option( 'pixel_your_site_std_events', array() );
1006
  if ( pys_get_option( 'std', 'enabled' ) && count( $std_events ) > 0 ) {
1007
 
1008
- foreach ( $std_events as $event ) {
 
 
 
 
 
1009
 
1010
  // add event on url's match
1011
- if ( pys_match_url( $event['pageurl'] ) ) {
1012
 
1013
- if ( $event['eventtype'] == 'CustomCode' ) {
1014
 
1015
- $custom_code = $event['code'];
1016
  $custom_code = stripcslashes( $custom_code );
1017
  $custom_code = trim( $custom_code );
1018
 
1019
- $pixelcode .= "// Standard Event (custom code) \n" . $custom_code . " \n\n";
1020
 
1021
  } else {
1022
 
1023
- $event_code = pys_get_event_code( $event );
 
1024
 
1025
- $pixelcode .= "// Standard Event \n" . $event_code['js'] . " \n\n";
1026
 
1027
- $nojscode .= "<!-- Standard Event -->\n";
1028
- $nojscode .= $event_code['nojs'];
1029
 
1030
  }
1031
 
@@ -1038,10 +987,10 @@ if( !function_exists( 'pys_pixel_code' ) ) {
1038
  // add woocommerce events
1039
  if ( pys_get_option( 'woo', 'enabled' ) && pys_is_woocommerce_active() ) {
1040
 
1041
- $event_code = pys_get_woo_code();
1042
 
1043
- $pixelcode .= $event_code['js'];
1044
- $nojscode .= $event_code['nojs'];
1045
 
1046
  }
1047
 
@@ -1055,16 +1004,25 @@ if( !function_exists( 'pys_pixel_code' ) ) {
1055
  }
1056
 
1057
  $params = pys_get_woo_ajax_addtocart_params( $product_id );
1058
- $event_code = pys_build_event_pixel_code( 'WooCommerce', $params, 'AddToCart' );
1059
 
1060
  $pixelcode .= $event_code['js'];
1061
- $nojscode .= $event_code['nojs'];
1062
 
1063
  }
1064
 
 
 
 
 
 
 
 
 
 
1065
  ?>
1066
 
1067
- <!-- Facebook Pixel Code -->
1068
  <script>
1069
  var PYS_DOMReady = function (a, b, c) {
1070
  b = document, c = 'addEventListener';
@@ -1106,6 +1064,25 @@ if( !function_exists( 'pys_pixel_code' ) ) {
1106
 
1107
  }
1108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1109
  /**
1110
  * Build General Event code.
1111
  */
@@ -1122,16 +1099,21 @@ if( !function_exists( 'pys_get_general_event_code' ) ) {
1122
  // Posts
1123
  if ( pys_get_option( 'general', 'general_event_on_posts_enabled' ) && is_singular( 'post' ) ) {
1124
 
1125
- $params['content_type'] = 'post';
1126
  $params['content_name'] = $post->post_title;
1127
- $params['content_ids'] = $post->ID;
1128
 
1129
  $terms = pys_get_content_taxonomies();
1130
  if ( $terms ) {
1131
  $params['content_category'] = $terms;
1132
  }
1133
 
1134
- return pys_build_event_pixel_code( 'General', $params, $event_name );
 
 
 
 
 
1135
 
1136
  }
1137
 
@@ -1143,25 +1125,25 @@ if( !function_exists( 'pys_get_general_event_code' ) ) {
1143
  return false;
1144
  }
1145
 
1146
- $params['content_type'] = 'page';
1147
  $params['content_name'] = is_home() == true ? get_bloginfo( 'name' ) : $post->post_title;
1148
 
1149
- is_home() != true ? $params['content_ids'] = $post->ID : null;
1150
 
1151
- return pys_build_event_pixel_code( 'General', $params, $event_name );
1152
 
1153
  }
1154
 
1155
  // WooCommerce Shop page
1156
- if( pys_get_option( 'general', 'general_event_on_pages_enabled' ) && pys_is_woocommerce_active() && is_shop() ) {
1157
 
1158
  $page_id = wc_get_page_id( 'shop' );
1159
 
1160
- $params['content_type'] = 'page';
1161
- $params['content_ids'] = $page_id;
1162
  $params['content_name'] = get_the_title( $page_id );;
1163
 
1164
- return pys_build_event_pixel_code( 'General', $params, $event_name );
1165
 
1166
  }
1167
 
@@ -1176,30 +1158,30 @@ if( !function_exists( 'pys_get_general_event_code' ) ) {
1176
  $cat = get_query_var( 'cat' );
1177
  $term = get_category( $cat );
1178
 
1179
- $params['content_type'] = 'category';
1180
  $params['content_name'] = $term->name;
1181
- $params['content_ids'] = $cat;
1182
 
1183
  } elseif ( is_tag() ) {
1184
 
1185
  $slug = get_query_var( 'tag' );
1186
  $term = get_term_by( 'slug', $slug, 'post_tag' );
1187
 
1188
- $params['content_type'] = 'tag';
1189
  $params['content_name'] = $term->name;
1190
- $params['content_ids'] = $term->term_id;
1191
 
1192
  } else {
1193
 
1194
  $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
1195
 
1196
- $params['content_type'] = get_query_var( 'taxonomy' );
1197
  $params['content_name'] = $term->name;
1198
- $params['content_ids'] = $term->term_id;
1199
 
1200
  }
1201
 
1202
- return pys_build_event_pixel_code( 'General', $params, $event_name );
1203
 
1204
  }
1205
 
@@ -1213,9 +1195,9 @@ if( !function_exists( 'pys_get_general_event_code' ) ) {
1213
  return false;
1214
  }
1215
 
1216
- $params['content_type'] = $post_type;
1217
  $params['content_name'] = $post->post_title;
1218
- $params['content_ids'] = $post->ID;
1219
 
1220
  $taxonomies = get_post_taxonomies( get_post() );
1221
  $terms = pys_get_content_taxonomies( $taxonomies[0] );
@@ -1223,7 +1205,12 @@ if( !function_exists( 'pys_get_general_event_code' ) ) {
1223
  $params['content_category'] = $terms;
1224
  }
1225
 
1226
- return pys_build_event_pixel_code( 'General', $params, $event_name );
 
 
 
 
 
1227
 
1228
  }
1229
 
@@ -1232,9 +1219,9 @@ if( !function_exists( 'pys_get_general_event_code' ) ) {
1232
 
1233
  $download = new EDD_Download( $post->ID );
1234
 
1235
- $params['content_type'] = 'download';
1236
  $params['content_name'] = $download->post_title;
1237
- $params['content_ids'] = $post->ID;
1238
  $params['value'] = $download->get_price();
1239
  $params['currency'] = edd_get_currency();
1240
 
@@ -1243,7 +1230,7 @@ if( !function_exists( 'pys_get_general_event_code' ) ) {
1243
  $params['content_category'] = $terms;
1244
  }
1245
 
1246
- return pys_build_event_pixel_code( 'General', $params, $event_name );
1247
  }
1248
 
1249
  return false;
@@ -1311,6 +1298,7 @@ if( !function_exists( 'pys_get_default_options' ) ) {
1311
 
1312
  $options['general']['pixel_id'] = '';
1313
  $options['general']['enabled'] = 0;
 
1314
 
1315
  $options['general']['general_event_enabled'] = 1;
1316
  $options['general']['general_event_name'] = 'GeneralEvent';
@@ -1318,6 +1306,7 @@ if( !function_exists( 'pys_get_default_options' ) ) {
1318
  $options['general']['general_event_on_pages_enabled'] = 1;
1319
  $options['general']['general_event_on_tax_enabled'] = 1;
1320
  $options['general']['general_event_on_edd_enabled'] = 0;
 
1321
 
1322
  $options['general']['timeonpage_enabled'] = 1;
1323
 
@@ -1335,6 +1324,7 @@ if( !function_exists( 'pys_get_default_options' ) ) {
1335
  $options['woo']['variation_id'] = 'main';
1336
 
1337
  $options['woo']['enable_additional_params'] = 1;
 
1338
  $options['woo']['tax'] = 'incl';
1339
 
1340
  $options['woo']['on_view_content'] = 1;
@@ -1363,8 +1353,6 @@ if( !function_exists( 'pys_get_default_options' ) ) {
1363
  $options['woo']['purchase_percent_value'] = '';
1364
  $options['woo']['purchase_global_value'] = '';
1365
 
1366
- $options['woo']['purchase_additional_matching'] = 1;
1367
-
1368
  $options['woo']['purchase_add_address'] = 1;
1369
  $options['woo']['purchase_add_payment_method'] = 1;
1370
  $options['woo']['purchase_add_shipping_method'] = 1;
@@ -1446,6 +1434,7 @@ if( !function_exists( 'pys_is_standard_event' ) ) {
1446
  function pys_is_standard_event( $eventtype ) {
1447
 
1448
  $std_events = array(
 
1449
  'ViewContent',
1450
  'Search',
1451
  'AddToCart',
@@ -1460,4 +1449,36 @@ if( !function_exists( 'pys_is_standard_event' ) ) {
1460
 
1461
  }
1462
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1463
  }
172
 
173
  /**
174
  * Check if needle URL (full or relative) matches with current.
 
175
  */
176
  if( !function_exists( 'pys_match_url' ) ) {
177
 
234
 
235
  function pys_clean_param_value( $value ) {
236
 
237
+ //@todo: remove deprecated function
238
+
239
  $replace = array(
240
  '&lt;' => '',
241
  '&gt;' => '',
518
  if( !function_exists( 'pys_currency_options' ) ) {
519
 
520
  function pys_currency_options( $current = 'USD' ) {
 
521
 
522
+ $currencies = apply_filters( 'pys_currencies_list', array(
523
+ 'AUD' => 'Australian Dollar',
524
+ 'BRL' => 'Brazilian Real',
525
+ 'CAD' => 'Canadian Dollar',
526
+ 'CZK' => 'Czech Koruna',
527
+ 'DKK' => 'Danish Krone',
528
+ 'EUR' => 'Euro',
529
+ 'HKD' => 'Hong Kong Dollar',
530
+ 'HUF' => 'Hungarian Forint',
531
+ 'IDR' => 'Indonesian Rupiah',
532
+ 'ILS' => 'Israeli New Sheqel',
533
+ 'JPY' => 'Japanese Yen',
534
+ 'KRW' => 'Korean Won',
535
+ 'MYR' => 'Malaysian Ringgit',
536
+ 'MXN' => 'Mexican Peso',
537
+ 'NOK' => 'Norwegian Krone',
538
+ 'NZD' => 'New Zealand Dollar',
539
+ 'PHP' => 'Philippine Peso',
540
+ 'PLN' => 'Polish Zloty',
541
+ 'RON' => 'Romanian Leu',
542
+ 'GBP' => 'Pound Sterling',
543
+ 'SGD' => 'Singapore Dollar',
544
+ 'SEK' => 'Swedish Krona',
545
+ 'CHF' => 'Swiss Franc',
546
+ 'TWD' => 'Taiwan New Dollar',
547
+ 'THB' => 'Thai Baht',
548
+ 'TRY' => 'Turkish Lira',
549
+ 'USD' => 'U.S. Dollar',
550
+ 'ZAR' => 'South African Rands'
551
+ ) );
552
+
553
+ foreach( $currencies as $symbol => $name ) {
554
+ echo '<option ' . selected( $symbol, $current, false ) . ' value="' . esc_attr( $symbol ) . '">' . esc_html( $name ) . '</option>';
555
+ }
556
 
 
557
  }
558
 
559
  }
636
  $str = '';
637
  foreach ( $tree as $node ) {
638
 
639
+ if ( isset( $node['children'] ) ) {
640
 
641
+ $str .= $node['name'] . ', ';
642
  $str .= pys_explode_taxonomies( $node['children'] );
643
 
644
  } else {
675
 
676
  $src = add_query_arg( $args, 'https://www.facebook.com/tr' );
677
 
678
+ return "<noscript><img height='1' width='1' style='display:none' src='" . $src . "'></noscript>\n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
679
 
 
680
  }
681
 
682
  }
683
 
684
  if( !function_exists( 'pys_build_event_pixel_code' ) ) {
685
 
686
+ function pys_build_event_pixel_code( $params, $event ) {
687
+
688
+ $params = apply_filters( 'pys_event_params', $params, $event );
689
 
690
+ $js = null;
691
+ $nojs = array();
692
 
693
  // explode params to formatted string
694
+ foreach ( $params as $name => $value ) {
 
 
695
 
696
+ if( empty( $value ) ) {
697
+ continue;
 
698
  }
699
 
700
+ // skip cleanup
701
+ //@todo: remove after tests
702
+ // if ( ! in_array( $name, array( 'content_ids', 'value', 'time' ) ) ) {
703
+ // $value = pys_clean_param_value( $value );
704
+ // }
705
 
706
+ // sanitize prams
707
+ $key = esc_js( $name );
708
+ $value = esc_js( $value );
709
 
710
+ $js .= "{$key}: '{$value}', ";
711
+ $nojs[ $name ] = esc_attr( $value );
712
 
 
 
 
 
 
 
 
713
  }
714
 
715
+ $track = pys_is_standard_event( $event ) ? 'track' : 'trackCustom';
 
716
 
717
+ return array(
718
+ 'js' => "fbq('{$track}', '{$event}', {{$js}} );\n",
719
+ 'nojs' => pys_get_noscript_code( $event, $nojs )
720
+ );
721
 
 
722
  }
723
 
724
  }
792
  $attr_value = trim( $attr_value );
793
 
794
  $doc = new DOMDocument();
795
+
796
+ /**
797
+ * Old libxml does not support options parameter.
798
+ * @since 3.2.0
799
+ */
800
+ if( defined('LIBXML_DOTTED_VERSION') && version_compare( LIBXML_DOTTED_VERSION, '2.6.0', '>=' ) &&
801
+ version_compare( phpversion(), '5.4.0', '>=' ) ) {
802
+ @$doc->loadHTML( '<?xml encoding="UTF-8">' . $tag, LIBXML_NOEMPTYTAG );
803
+ } else {
804
+ @$doc->loadHTML( '<?xml encoding="UTF-8">' . $tag );
805
+ }
806
+
807
  $node = $doc->getElementsByTagName( $tag_name )->item(0);
808
 
809
  if( is_null( $node ) ) {
879
 
880
  function pys_is_disabled_for_role() {
881
 
882
+ $options = get_option( 'pixel_your_site' );
883
+ $disabled_roles = $options['general'];
884
+
885
  $user = wp_get_current_user();
886
  foreach ( (array) $user->roles as $role ) {
887
 
888
+ if ( array_key_exists( "disable_for_$role", $disabled_roles ) ) {
889
  return true;
890
  }
891
 
892
  }
893
 
894
+ if( empty( $user->roles ) && isset( $disabled_roles['disable_for_guest'] ) ) {
895
+ return true;
896
+ }
897
+
898
  return false;
899
 
900
  }
908
 
909
  function pys_pixel_code() {
910
 
 
 
 
 
 
 
 
 
 
 
 
911
  $pixel_id = pys_get_option( 'general', 'pixel_id' );
 
 
 
912
 
913
  // build pixel code...
914
  $pixelcode = "\n";
915
  $nojscode = "\n";
916
 
917
  // pixel id
918
+ $pixelcode .= "fbq('init', '{$pixel_id}', {" . pys_pixel_init_params() . "});\n";
919
 
920
  // default event
921
+ $default_event = pys_build_event_pixel_code( array(), 'PageView' );
922
+ $pixelcode .= $default_event['js'];
923
+ $nojscode .= $default_event['nojs'];
924
 
925
  // general event
926
  if ( pys_get_option( 'general', 'general_event_enabled' ) ) {
928
  $code = pys_get_general_event_code();
929
 
930
  $pixelcode .= $code['js'];
931
+ $nojscode .= $code['nojs'];
932
 
933
  }
934
 
935
  // search event
936
  if ( pys_get_option( 'general', 'search_event_enabled' ) && is_search() && isset( $_REQUEST['s'] ) ) {
937
 
938
+ $search_event = pys_build_event_pixel_code( array(
939
+ 'search_string' => $_REQUEST['s']
940
+ ), 'Search' );
941
 
942
+ $pixelcode .= $search_event['js'];
943
+ $nojscode .= $search_event['nojs'];
 
 
944
 
945
  }
946
 
948
  $std_events = get_option( 'pixel_your_site_std_events', array() );
949
  if ( pys_get_option( 'std', 'enabled' ) && count( $std_events ) > 0 ) {
950
 
951
+ foreach ( $std_events as $std_event_params ) {
952
+
953
+ // skip wrong events
954
+ if( ! isset( $std_event_params['pageurl'] ) || ! isset( $std_event_params['eventtype'] ) ) {
955
+ continue;
956
+ }
957
 
958
  // add event on url's match
959
+ if ( pys_match_url( $std_event_params['pageurl'] ) ) {
960
 
961
+ if ( $std_event_params['eventtype'] == 'CustomCode' ) {
962
 
963
+ $custom_code = $std_event_params['code'];
964
  $custom_code = stripcslashes( $custom_code );
965
  $custom_code = trim( $custom_code );
966
 
967
+ $pixelcode .= "{$custom_code}\n";
968
 
969
  } else {
970
 
971
+ $std_event_type = $std_event_params['eventtype'];
972
+ $std_event_params = pys_clean_system_event_params( $std_event_params );
973
 
974
+ $std_event_code = pys_build_event_pixel_code( $std_event_params, $std_event_type );
975
 
976
+ $pixelcode .= $std_event_code['js'];
977
+ $nojscode .= $std_event_code['nojs'];
978
 
979
  }
980
 
987
  // add woocommerce events
988
  if ( pys_get_option( 'woo', 'enabled' ) && pys_is_woocommerce_active() ) {
989
 
990
+ $woo_event_code = pys_get_woo_code();
991
 
992
+ $pixelcode .= $woo_event_code['js'];
993
+ $nojscode .= $woo_event_code['nojs'];
994
 
995
  }
996
 
1004
  }
1005
 
1006
  $params = pys_get_woo_ajax_addtocart_params( $product_id );
1007
+ $event_code = pys_build_event_pixel_code( $params, 'AddToCart' );
1008
 
1009
  $pixelcode .= $event_code['js'];
1010
+ $nojscode .= $event_code['nojs'];
1011
 
1012
  }
1013
 
1014
+ // version data
1015
+ if( defined('PYS_PRO_VERSION') ) {
1016
+ $version = "PRO v".PYS_PRO_VERSION;
1017
+ } elseif( defined('PYS_FREE_VERSION') ) {
1018
+ $version = "FREE v".PYS_FREE_VERSION_REAL;
1019
+ } else {
1020
+ $version = null;
1021
+ }
1022
+
1023
  ?>
1024
 
1025
+ <!-- Facebook Pixel Code ( <?php echo esc_attr( $version ); ?> ) -->
1026
  <script>
1027
  var PYS_DOMReady = function (a, b, c) {
1028
  b = document, c = 'addEventListener';
1064
 
1065
  }
1066
 
1067
+ if( !function_exists( 'pys_clean_system_event_params' ) ) {
1068
+
1069
+ function pys_clean_system_event_params( $params ) {
1070
+
1071
+ // remove unused params
1072
+ unset( $params['pageurl'] );
1073
+ unset( $params['eventtype'] );
1074
+ unset( $params['code'] );
1075
+ unset( $params['trigger_type'] ); // pro
1076
+ unset( $params['url'] ); // pro
1077
+ unset( $params['css'] ); // pro
1078
+ unset( $params['custom_name'] ); // custom events
1079
+
1080
+ return $params;
1081
+
1082
+ }
1083
+
1084
+ }
1085
+
1086
  /**
1087
  * Build General Event code.
1088
  */
1099
  // Posts
1100
  if ( pys_get_option( 'general', 'general_event_on_posts_enabled' ) && is_singular( 'post' ) ) {
1101
 
1102
+ $params['post_type'] = 'post';
1103
  $params['content_name'] = $post->post_title;
1104
+ $params['post_id'] = $post->ID;
1105
 
1106
  $terms = pys_get_content_taxonomies();
1107
  if ( $terms ) {
1108
  $params['content_category'] = $terms;
1109
  }
1110
 
1111
+ // track post tags
1112
+ if ( pys_get_option( 'general', 'general_event_add_tags', 0 ) && $tags = pys_get_post_tags( $post->ID ) ) {
1113
+ $params['tags'] = implode( ', ', $tags );
1114
+ }
1115
+
1116
+ return pys_build_event_pixel_code( $params, $event_name );
1117
 
1118
  }
1119
 
1125
  return false;
1126
  }
1127
 
1128
+ $params['post_type'] = 'page';
1129
  $params['content_name'] = is_home() == true ? get_bloginfo( 'name' ) : $post->post_title;
1130
 
1131
+ is_home() != true ? $params['post_id'] = $post->ID : null;
1132
 
1133
+ return pys_build_event_pixel_code( $params, $event_name );
1134
 
1135
  }
1136
 
1137
  // WooCommerce Shop page
1138
+ if ( pys_get_option( 'general', 'general_event_on_pages_enabled' ) && pys_is_woocommerce_active() && is_shop() ) {
1139
 
1140
  $page_id = wc_get_page_id( 'shop' );
1141
 
1142
+ $params['post_type'] = 'page';
1143
+ $params['post_id'] = $page_id;
1144
  $params['content_name'] = get_the_title( $page_id );;
1145
 
1146
+ return pys_build_event_pixel_code( $params, $event_name );
1147
 
1148
  }
1149
 
1158
  $cat = get_query_var( 'cat' );
1159
  $term = get_category( $cat );
1160
 
1161
+ $params['post_type'] = 'category';
1162
  $params['content_name'] = $term->name;
1163
+ $params['post_id'] = $cat;
1164
 
1165
  } elseif ( is_tag() ) {
1166
 
1167
  $slug = get_query_var( 'tag' );
1168
  $term = get_term_by( 'slug', $slug, 'post_tag' );
1169
 
1170
+ $params['post_type'] = 'tag';
1171
  $params['content_name'] = $term->name;
1172
+ $params['post_id'] = $term->term_id;
1173
 
1174
  } else {
1175
 
1176
  $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
1177
 
1178
+ $params['post_type'] = get_query_var( 'taxonomy' );
1179
  $params['content_name'] = $term->name;
1180
+ $params['post_id'] = $term->term_id;
1181
 
1182
  }
1183
 
1184
+ return pys_build_event_pixel_code( $params, $event_name );
1185
 
1186
  }
1187
 
1195
  return false;
1196
  }
1197
 
1198
+ $params['post_type'] = $post_type;
1199
  $params['content_name'] = $post->post_title;
1200
+ $params['post_id'] = $post->ID;
1201
 
1202
  $taxonomies = get_post_taxonomies( get_post() );
1203
  $terms = pys_get_content_taxonomies( $taxonomies[0] );
1205
  $params['content_category'] = $terms;
1206
  }
1207
 
1208
+ // track custom post type tags
1209
+ if ( pys_get_option( 'general', 'general_event_add_tags', 0 ) && $tags = pys_get_post_tags( $post->ID ) ) {
1210
+ $params['tags'] = implode( ', ', $tags );
1211
+ }
1212
+
1213
+ return pys_build_event_pixel_code( $params, $event_name );
1214
 
1215
  }
1216
 
1219
 
1220
  $download = new EDD_Download( $post->ID );
1221
 
1222
+ $params['post_type'] = 'download';
1223
  $params['content_name'] = $download->post_title;
1224
+ $params['post_id'] = $post->ID;
1225
  $params['value'] = $download->get_price();
1226
  $params['currency'] = edd_get_currency();
1227
 
1230
  $params['content_category'] = $terms;
1231
  }
1232
 
1233
+ return pys_build_event_pixel_code( $params, $event_name );
1234
  }
1235
 
1236
  return false;
1298
 
1299
  $options['general']['pixel_id'] = '';
1300
  $options['general']['enabled'] = 0;
1301
+ $options['general']['enable_advance_matching'] = 1;
1302
 
1303
  $options['general']['general_event_enabled'] = 1;
1304
  $options['general']['general_event_name'] = 'GeneralEvent';
1306
  $options['general']['general_event_on_pages_enabled'] = 1;
1307
  $options['general']['general_event_on_tax_enabled'] = 1;
1308
  $options['general']['general_event_on_edd_enabled'] = 0;
1309
+ $options['general']['general_event_add_tags'] = 0;
1310
 
1311
  $options['general']['timeonpage_enabled'] = 1;
1312
 
1324
  $options['woo']['variation_id'] = 'main';
1325
 
1326
  $options['woo']['enable_additional_params'] = 1;
1327
+ $options['woo']['enable_tags'] = 1;
1328
  $options['woo']['tax'] = 'incl';
1329
 
1330
  $options['woo']['on_view_content'] = 1;
1353
  $options['woo']['purchase_percent_value'] = '';
1354
  $options['woo']['purchase_global_value'] = '';
1355
 
 
 
1356
  $options['woo']['purchase_add_address'] = 1;
1357
  $options['woo']['purchase_add_payment_method'] = 1;
1358
  $options['woo']['purchase_add_shipping_method'] = 1;
1434
  function pys_is_standard_event( $eventtype ) {
1435
 
1436
  $std_events = array(
1437
+ 'PageView',
1438
  'ViewContent',
1439
  'Search',
1440
  'AddToCart',
1449
 
1450
  }
1451
 
1452
+ }
1453
+
1454
+ /**
1455
+ * Add extra params to FB init call.
1456
+ */
1457
+ if( !function_exists( 'pys_pixel_init_params' ) ) {
1458
+
1459
+ function pys_pixel_init_params() {
1460
+
1461
+ $params = array();
1462
+ $params = apply_filters( 'pys_pixel_init_params', $params );
1463
+
1464
+ $code = null;
1465
+ foreach ( $params as $key => $value ) {
1466
+
1467
+ // remove empty params
1468
+ if ( empty( $value ) ) {
1469
+ unset( $params[ $key ] );
1470
+ }
1471
+
1472
+ // sanitize prams
1473
+ $key = esc_js( $key );
1474
+ $value = esc_js( $value );
1475
+
1476
+ $code .= "{$key}: '{$value}', ";
1477
+
1478
+ }
1479
+
1480
+ return $code;
1481
+
1482
+ }
1483
+
1484
  }
inc/core.php CHANGED
@@ -17,6 +17,17 @@ if( !function_exists( 'pys_get_woo_ajax_addtocart_params' ) ) {
17
 
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Build WooCommerce related events code.
22
  */
@@ -34,7 +45,7 @@ if( !function_exists( 'pys_get_woo_code' ) ) {
34
 
35
  $params['content_ids'] = '[' . pys_get_product_content_id( $post->ID ) . ']';
36
 
37
- return pys_build_event_pixel_code( 'WooCommerce', $params, 'ViewContent' );
38
 
39
  }
40
 
@@ -53,7 +64,7 @@ if( !function_exists( 'pys_get_woo_code' ) ) {
53
 
54
  $params['content_ids'] = '[' . implode( ',', $ids ) . ']';
55
 
56
- return pys_build_event_pixel_code( 'WooCommerce', $params, 'AddToCart' );
57
 
58
  }
59
 
@@ -62,7 +73,7 @@ if( !function_exists( 'pys_get_woo_code' ) ) {
62
 
63
  $params = pys_get_woo_checkout_params( false );
64
 
65
- return pys_build_event_pixel_code( 'WooCommerce', $params, 'InitiateCheckout' );
66
 
67
  }
68
 
@@ -85,7 +96,7 @@ if( !function_exists( 'pys_get_woo_code' ) ) {
85
 
86
  $params['content_ids'] = '[' . implode( ',', $ids ) . ']';
87
 
88
- return pys_build_event_pixel_code( 'WooCommerce', $params, 'Purchase' );
89
 
90
  }
91
 
@@ -119,7 +130,7 @@ if( !function_exists( 'pys_add_code_to_woo_cart_link' ) ) {
119
  return $tag;
120
  }
121
 
122
- $code = pys_build_event_pixel_code( null, $params, 'AddToCart' );
123
 
124
  return pys_insert_attribute( 'data-pixelcode', $code['js'], $tag, true );
125
 
@@ -143,9 +154,7 @@ if( !function_exists( 'pys_get_additional_matching_code' ) ) {
143
  * @return string
144
  */
145
  function pys_get_additional_matching_code() {
146
-
147
- return '';
148
-
149
  }
150
 
151
  }
17
 
18
  }
19
 
20
+ /**
21
+ * Return array of product tags.
22
+ */
23
+ if( !function_exists( 'pys_get_post_tags' ) ) {
24
+
25
+ function pys_get_post_tags( $post_id ) {
26
+ return array(); // PRO feature
27
+ }
28
+
29
+ }
30
+
31
  /**
32
  * Build WooCommerce related events code.
33
  */
45
 
46
  $params['content_ids'] = '[' . pys_get_product_content_id( $post->ID ) . ']';
47
 
48
+ return pys_build_event_pixel_code( $params, 'ViewContent' );
49
 
50
  }
51
 
64
 
65
  $params['content_ids'] = '[' . implode( ',', $ids ) . ']';
66
 
67
+ return pys_build_event_pixel_code( $params, 'AddToCart' );
68
 
69
  }
70
 
73
 
74
  $params = pys_get_woo_checkout_params( false );
75
 
76
+ return pys_build_event_pixel_code( $params, 'InitiateCheckout' );
77
 
78
  }
79
 
96
 
97
  $params['content_ids'] = '[' . implode( ',', $ids ) . ']';
98
 
99
+ return pys_build_event_pixel_code( $params, 'Purchase' );
100
 
101
  }
102
 
130
  return $tag;
131
  }
132
 
133
+ $code = pys_build_event_pixel_code( $params, 'AddToCart' );
134
 
135
  return pys_insert_attribute( 'data-pixelcode', $code['js'], $tag, true );
136
 
154
  * @return string
155
  */
156
  function pys_get_additional_matching_code() {
157
+ return ''; // PRO feature
 
 
158
  }
159
 
160
  }
inc/html-tab-pixel-general.php CHANGED
@@ -8,9 +8,17 @@
8
  <td class="alignright"><p class="label">Enable general event setup</p></td>
9
  <td>
10
  <input type="checkbox" name="pys[general][general_event_enabled]" value="1"
11
- <?php echo pys_checkbox_state( 'general', 'general_event_enabled' ); ?> ></input>
12
  </td>
13
  </tr>
 
 
 
 
 
 
 
 
14
 
15
  <tr>
16
  <td class="alignright"><p class="label">General event name</p></td>
@@ -120,7 +128,7 @@
120
  <td class="alignright"><p class="label">Enable Search event setup</p></td>
121
  <td>
122
  <input type="checkbox" name="pys[general][search_event_enabled]" value="1"
123
- <?php echo pys_checkbox_state( 'general', 'search_event_enabled' ); ?> ></input>
124
  </td>
125
  </tr>
126
 
@@ -154,11 +162,19 @@
154
  <td class="alignright"><?php echo $role_name; ?></td>
155
  <td>
156
  <input type="checkbox" name="pys[general][disable_for_<?php echo $role_value; ?>]" value="1"
157
- <?php echo pys_checkbox_state( 'general', 'disable_for_' . $role_value ); ?> ></input>
158
  </td>
159
  </tr>
160
 
161
  <?php endforeach; ?>
 
 
 
 
 
 
 
 
162
 
163
  </table>
164
 
8
  <td class="alignright"><p class="label">Enable general event setup</p></td>
9
  <td>
10
  <input type="checkbox" name="pys[general][general_event_enabled]" value="1"
11
+ <?php echo pys_checkbox_state( 'general', 'general_event_enabled' ); ?> >
12
  </td>
13
  </tr>
14
+
15
+ <tr class="tall">
16
+ <td></td>
17
+ <td>
18
+ <input type="checkbox" name="" value="1" class="disabled">Track tags - <strong>This is a PRO feature</strong> - <a href="http://www.pixelyoursite.com/facebook-pixel-plugin">Update NOW</a>
19
+ <span class="help">Will pull <code>tags</code> param on posts and custom post types</span>
20
+ </td>
21
+ </tr>
22
 
23
  <tr>
24
  <td class="alignright"><p class="label">General event name</p></td>
128
  <td class="alignright"><p class="label">Enable Search event setup</p></td>
129
  <td>
130
  <input type="checkbox" name="pys[general][search_event_enabled]" value="1"
131
+ <?php echo pys_checkbox_state( 'general', 'search_event_enabled' ); ?> >
132
  </td>
133
  </tr>
134
 
162
  <td class="alignright"><?php echo $role_name; ?></td>
163
  <td>
164
  <input type="checkbox" name="pys[general][disable_for_<?php echo $role_value; ?>]" value="1"
165
+ <?php echo pys_checkbox_state( 'general', 'disable_for_' . $role_value ); ?> >
166
  </td>
167
  </tr>
168
 
169
  <?php endforeach; ?>
170
+
171
+ <tr>
172
+ <td class="alignright">Guest</td>
173
+ <td>
174
+ <input type="checkbox" name="pys[general][disable_for_guest]" value="1"
175
+ <?php echo pys_checkbox_state( 'general', 'disable_for_guest' ); ?> >
176
+ </td>
177
+ </tr>
178
 
179
  </table>
180
 
inc/html-tab-pixel-id.php CHANGED
@@ -12,6 +12,15 @@
12
  <span class="help">Where to find the Pixel ID? <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Click here for help</a></span>
13
  </td>
14
  </tr>
 
 
 
 
 
 
 
 
 
15
  </table>
16
  </div>
17
  </div>
12
  <span class="help">Where to find the Pixel ID? <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Click here for help</a></span>
13
  </td>
14
  </tr>
15
+
16
+ <tr>
17
+ <td></td>
18
+ <td>
19
+ <input type="checkbox" name="" value="1" class="disabled">Enable Advance Matching - <strong>This is a PRO feature</strong> - <a href="http://www.pixelyoursite.com/facebook-pixel-plugin">Update NOW</a>
20
+ <span class="help">Advance Matching can lead to 10% increase in attributed conversions and 20% increase in reach of retargeting campaigns - <a href="http://www.pixelyoursite.com/enable-advance-matching-woocommerce" target="_blank">Click to read more</a> </span>
21
+ </td>
22
+ </tr>
23
+
24
  </table>
25
  </div>
26
  </div>
inc/html-tab-std-event-list.php CHANGED
@@ -19,29 +19,40 @@
19
  </thead>
20
  <tbody>
21
 
22
- <?php if( $std_events ) : ?>
23
 
24
- <?php foreach ($std_events as $key => $event) : ?>
 
 
 
 
 
 
 
 
 
25
 
26
  <tr>
27
  <th scope="row" class="check-column">
28
  <input type="checkbox" class="std-event-check" data-id="<?php echo $key; ?>">
29
  </th>
30
 
31
- <td><?php echo $event['eventtype']; ?></td>
32
- <td><pre><?php echo $event['pageurl']; ?></pre></td>
33
  <td>
34
  <?php
35
 
36
  $code = '';
37
- if( $event['eventtype'] == 'CustomCode' ) {
38
 
39
- $code = $event['code'];
40
 
41
  } else {
42
-
43
- $code = pys_get_event_code( $event );
44
- $code = $code['js'];
 
 
45
 
46
  }
47
 
19
  </thead>
20
  <tbody>
21
 
22
+ <?php if( $std_events = get_option( 'pixel_your_site_std_events' ) ) : ?>
23
 
24
+ <?php foreach( $std_events as $key => $params ) : ?>
25
+
26
+ <?php
27
+
28
+ // skip wrong events
29
+ if( ! isset( $params['eventtype'] ) || ! isset( $params['pageurl'] ) ) {
30
+ continue;
31
+ }
32
+
33
+ ?>
34
 
35
  <tr>
36
  <th scope="row" class="check-column">
37
  <input type="checkbox" class="std-event-check" data-id="<?php echo $key; ?>">
38
  </th>
39
 
40
+ <td><?php echo $params['eventtype']; ?></td>
41
+ <td><pre><?php echo $params['pageurl']; ?></pre></td>
42
  <td>
43
  <?php
44
 
45
  $code = '';
46
+ if( $params['eventtype'] == 'CustomCode' ) {
47
 
48
+ $code = $params['code'];
49
 
50
  } else {
51
+
52
+ $event_type = $params['eventtype'];
53
+ $params = pys_clean_system_event_params( $params );
54
+ $code = pys_build_event_pixel_code( $params, $event_type );
55
+ $code = $code['js'];
56
 
57
  }
58
 
inc/html-tab-woo-general.php CHANGED
@@ -53,8 +53,12 @@
53
 
54
  <input type="checkbox">Enable Additional Parameters</input>
55
  <span class="help">Product name will be pulled as <code>content_name</code>, and Product Category as <code>category_name</code> for all WooCommerce events.</span>
56
- <span class="help">The nubmer of items is <code>num_items</code> for InitiateCheckout and Purchase events.</span>
57
-
 
 
 
 
58
  </td>
59
  <td>
60
 
@@ -309,15 +313,6 @@
309
  </td>
310
  </tr>
311
 
312
- <tr class="tall">
313
- <td class="alignright"><p class="label big">Advanced Matching on Purchase event:</p></td>
314
- <td>
315
- <input type="checkbox" name="" value="1" class="disabled">
316
- Enable - <strong>This is a PRO feature</strong> - <a href="http://www.pixelyoursite.com/facebook-pixel-plugin">Update NOW</a>
317
- <span class="help">Advance Matching can lead to 10% increase in attributed conversions and 20% increase in reach of retargeting campaigns - <a href="http://www.pixelyoursite.com/enable-advance-matching-woocommerce" target="_blank">Click to read more</a> </span>
318
- </td>
319
- </tr>
320
-
321
  <tr>
322
  <td class="alignright"><p class="label big">Custom Audience Optimization:</p></td>
323
  <td>
53
 
54
  <input type="checkbox">Enable Additional Parameters</input>
55
  <span class="help">Product name will be pulled as <code>content_name</code>, and Product Category as <code>category_name</code> for all WooCommerce events.</span>
56
+ <span class="help" style="margin-bottom: 20px;">The number of items is <code>num_items</code> for InitiateCheckout and Purchase events.</span>
57
+
58
+ <input type="checkbox" name="" disabled>Track tags
59
+ <span class="help">Will pull <code>tags</code> param on all WooCommerce events.</span>
60
+
61
+
62
  </td>
63
  <td>
64
 
313
  </td>
314
  </tr>
315
 
 
 
 
 
 
 
 
 
 
316
  <tr>
317
  <td class="alignright"><p class="label big">Custom Audience Optimization:</p></td>
318
  <td>
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: PixelYourSite, c0d3fev3r, themister
3
  Tags: Facebook Pixel, New Facebook Pixel, Facebook Conversion Pixel, Facebook Pixel Events, Facebook, New Facebook Pixel Events, Dynamic Events, Standard Events, Facebook Events, Facebook Standard Events, Facebook Dynamic Product Ads, WooCommerce, WooCommerce Facebook Pixel, Facebook Custom Events, Facebook Conversion Value, WooCommerce Affiliate Products, Facebook Pixel PayPal
4
  Requires at least: 3.0.1
5
- Tested up to: 4.5.2
6
- Stable tag: 3.0.3
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -14,21 +14,23 @@ Insert the new Facebook Pixel on WordPress, add Standard Events, enjoy superb Wo
14
 
15
  As you probably know, Facebook will retire the old Facebook Conversion Pixel in 2016. They recommend us to use the New Facebook Pixel for conversion tracking, optimization and remarketing.
16
 
17
- **PixelYourSite will help you insert the pixel code on every page with just one click** and set up Custom or Standard Events on any page or post. There is an **out of the box WooCommerce setup** that will configure all the necessary standard events for you.
 
 
 
 
18
 
19
- **Facebook Dynamic Ads are fully supported on WooCommerce**, with ViewContent, AddToCart and Purchase events being added on the corresponding pages (content_ids and content_type are pulled automatically by the plugin).
20
-
21
- The plugin is **Custom Audience super-friendly**, extracting content_name, content_type, content_ids on every page of your site. We also have a guide that you can download for free on how to handle this option and how to build Custom Audiences.
22
-
23
- There is a **[Learning Section](http://www.pixelyoursite.com/learn)** on our website, with helpful articles that answer to our users common (and sometimes uncommon) questions, together with top notch “how to”pages.
24
 
25
  Find more info [about how to use the FB pixel plugin - Click here](http://www.pixelyoursite.com/facebook-pixel-plugin-help)
26
 
27
- Not ready to install yet? Read on some of the key features that make PYS a powerful tool in any Facebook marketer arsenal.
28
 
29
  <strong>PixelYourSite Key Features:</strong></br>
30
 
31
- * You can **insert the pixel on every page of your website with just a few clicks**. No need to edit any posts or pages
 
 
32
 
33
  * **Search Event** on the search page with the search string pulled as parameter - super useful for creating search based Custom Audiences
34
 
@@ -36,13 +38,15 @@ Not ready to install yet? Read on some of the key features that make PYS a power
36
 
37
  * You can **set up and track Standard or Custom Events** and add parameters for each of them
38
 
39
- * **Dynamic Events:** optimize your Facebook Campaigns for actions on your website (CLICKS on links, buttons, forms). Works with **Contact Form 7** and any other form or pop-up plugins. ([Pro Version](http://www.pixelyoursite.com))
 
 
40
 
41
- * Track **conversion value** for standard or custom events
42
 
43
- * We automatically add a TimeOnPage event that measures the time each visitor spends on every page. It can be used for Custom Audiences ([Pro Version](http://www.pixelyoursite.com))
44
 
45
- * You have a General Event option that you can customize. It is triggered on every page and automatically tracks content_type, content_id and content_name. Extremely useful for Custom Audiences
46
 
47
  > <strong>How to create powerful Custom Audiences with PixelyourSite</strong>
48
 
@@ -54,50 +58,45 @@ Not ready to install yet? Read on some of the key features that make PYS a power
54
 
55
  * You can **insert the Facebook pixel and start tracking events on any WooCommerce** website with just a few clicks (Purchase, ViewContent, AddToCart, InitiateCheckout)
56
 
57
- * Out of the box **Facebook Dynamic Ads** setup for your Woocommerce website (we also have a dedicated feed plugin for Facebook Dynamic Ads Product Catalog)
58
 
59
  * **Dynamic AddToCart** is fully supported (the AddToCart event will fire on add to cart button click)
60
 
61
  * **Track conversion value for WooCommerce** ([Pro Version](http://www.pixelyoursite.com))
62
 
63
- * **WooCommerce Conversion Value Optimization:** You can include or exclude TAX for all the WooCommere events and Shipping cost for the Purchase event. You can use the full product price or just a percent of the price for each event Value. You can also set a general value for each event.
64
 
65
  * You can turn ON/OFF each WooCommerce event.
66
 
67
  * You can turn ON/OFF value for each WooCommerce event.
68
 
69
- * **Super Powerful Custom Audiences for WooCommerce:** we automatically track product name and product category (you can create audiences based on them), together with customer's city, state and country. Additionally we track payment and shipping methods. Use of coupons and coupon names are also automatically extracted. With this data you can unleash some fantastic retargeting campaigns based on highly granulated audiences. ([Pro Version](http://www.pixelyoursite.com))
70
 
71
- * **Advance Matching** is supported for the Purchase Event - this is a useful feature from Facebook that increases the chances to correctly identify users visiting your website without being logged to their Facebook accounts ([Pro Version](http://www.pixelyoursite.com))
 
 
72
 
73
  * **WooCommerce Affiliate Products Events:** you can add a dynamic event that will trigger on affiliate button clicks ([Pro Version](http://www.pixelyoursite.com))
74
 
75
  * **WooCommerce PayPal Standard Events:** you can add a dynamic AddPaymentInfo event that will trigger on WooCommerce PayPal button clicks ([Pro Version](http://www.pixelyoursite.com))
76
 
77
- * Fully tested with WooCommerce 2.6 and above
78
-
79
 
80
  <strong>What's next<strong>
81
 
82
  We are working on some new handy features for the plugin and we will release them soon.
83
 
84
- <strong>Pixel Helper False Errors</strong>
85
-
86
- If you are testing your pixel with Pixel Helper Chrome Extension, it is possible that you will see some **false** errors:
87
-
88
- **Event ID: AddToCart**: Facebook Pixel did not load.
89
 
90
- You can safely ignore it. It is a normal error trigger by the dynamic AddToCart event that will disappear after you click on the add to cart button.
91
 
 
92
 
93
- **Event ID: GeneralEvent**: Content_type is missing, should be either 'product' or 'product_group'
94
 
95
- You can safely ignore it. It’s a Dynamic Ads warning, but this event is not meant to be used for Dynamic Ads. It is completely dedicated to Custom Audiences and works perfectly. If you are using WooCommerce, there is a ViewContent event fully ready for the Dynamic Ads job.
96
 
97
-
98
- For more details on how to use Facebook Pixel Helper and how to interpret its reported errors [read this special article](http://www.pixelyoursite.com/facebook-pixel-helper-errors)
99
-
100
- **Let’s start now!** Join other thousands of users and instal the plugin, because it is easy to use, and will help you with your Facebook campaigns for real
101
 
102
 
103
  == Installation ==
@@ -131,7 +130,7 @@ We maintain an up to date FAQ page on our site:
131
 
132
  **Do I need to copy/paste the Facebook Pixel code somewhere?**
133
 
134
- No, you just have to enter your pixel ID in the dedicated filed. The plugin will do the rest for you.
135
 
136
  **Where can I find the Facebook Pixel ID?**
137
 
@@ -144,7 +143,7 @@ There are multiple ways to do that. One simple method is to:
144
 
145
  a. The pixel code will be added on every page of your site
146
 
147
- b. A "Search" standard event will be added on the search page of your site
148
 
149
  c. A GeneralEvent will be added on every page, pulling content_name, content_ids and content_type. It can be used for Custom Audiences.
150
 
@@ -158,7 +157,7 @@ Purchase event is added on the Thank You page
158
 
159
  **Can I define new standard events?**
160
 
161
- Yes, you can! There is a simple menu where you can do that. You'll need to add an URL and select the event type you want to add. If necessary, you can give each event a monetary value and its own currency.
162
 
163
  **Can I have more than just one event on a page?**
164
 
@@ -166,14 +165,14 @@ Yes, you can! You can have any number of events you want on a page.
166
 
167
  **Can I use your plugin for Facebook Dynamic Ads?**
168
 
169
- Yes, you can! Facebook Dynamic Product Ads are fully supported for WooCommerce. We plan to add a similar integration for Easy Digital Downoads soon.
170
 
171
  **Are there any known incompatibilities with other themes or plugins?**
172
 
173
  Any program, service, code or plugin that adds the Pixel Code, since you can't have to similar pixels on a page.
174
 
175
  * We had a problem with Mamaya, a retargeting service
176
- * It won't work with LeadPages or any similar system, because that pages are generated outside WordPress
177
 
178
  If any incompatibilities will arise we will add them here and, of course, will try to fix them as soon is possible.
179
 
@@ -188,7 +187,7 @@ We have an article about how to optimize Facebook Ads Reports:
188
  2. You don’t have to copy/paste all the pixel code, but just the pixel ID. You can find it in your Ads Manager, under Pixels
189
  3. The Search Event will pull each search on your site as a parameter. You can use it to create Custom Audiences
190
  4. The GeneralEvent is triggered on every page and can be used for Custom Audiences. We have a free guide on how to use it, liked from the plugin itself
191
- 5. Adding events on any URL of any page of your website is easy: just add the URL, select event type and fill the desired parameters values
192
  6. If you want you can insert a custom event code
193
  7. Or you can select a standard event and use the default parameters
194
  8. WooCommerce integration comes with out of the box Facebook Dynamic Ads setup
@@ -196,7 +195,15 @@ We have an article about how to optimize Facebook Ads Reports:
196
 
197
  == Changelog ==
198
 
199
- = PixelYourSite 3.0.2 =
 
 
 
 
 
 
 
 
200
 
201
  * Fixing PHP warnings and errors
202
 
@@ -206,9 +213,9 @@ We have an article about how to optimize Facebook Ads Reports:
206
 
207
  = PixelYourSite 3.0.2 =
208
 
209
- * Small fixes related to some possible html errors
210
 
211
- * Admin Notice modiffications
212
 
213
  = PixelYourSite 3.0.1 =
214
 
@@ -232,7 +239,7 @@ This is a major release, with new design and new features:
232
 
233
  = PixelYourSite 2.2.4 =
234
 
235
- * Fixig a few back*end errors and conflicts
236
 
237
  * Adding new currencies
238
 
@@ -296,7 +303,7 @@ This is a major release, with new design and new features:
296
 
297
  = PixelYourSite 1.0 =
298
 
299
- * A new plugin is borne: It will let you manage the Facebook Pixel with just a few clicks
300
 
301
 
302
  == Upgrade Notice ==
@@ -304,4 +311,3 @@ This is a major release, with new design and new features:
304
  = 3.0 =
305
 
306
  3.0 is a complete rewrite, with a new design and improve functionality. You have a new GeneralEvent that can be used to create Custom Audiences (plus a FREE guide on how to do it!) and Facebook Dynamic Ads are fully supported for WooCommerce. Update, then open the plugin menu for details
307
-
2
  Contributors: PixelYourSite, c0d3fev3r, themister
3
  Tags: Facebook Pixel, New Facebook Pixel, Facebook Conversion Pixel, Facebook Pixel Events, Facebook, New Facebook Pixel Events, Dynamic Events, Standard Events, Facebook Events, Facebook Standard Events, Facebook Dynamic Product Ads, WooCommerce, WooCommerce Facebook Pixel, Facebook Custom Events, Facebook Conversion Value, WooCommerce Affiliate Products, Facebook Pixel PayPal
4
  Requires at least: 3.0.1
5
+ Tested up to: 4.6
6
+ Stable tag: 3.1.0
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
14
 
15
  As you probably know, Facebook will retire the old Facebook Conversion Pixel in 2016. They recommend us to use the New Facebook Pixel for conversion tracking, optimization and remarketing.
16
 
17
+ >**PixelYourSite will help you insert the pixel code on every page with just one click** and set up Custom or Standard Events. There is **out of the box WooCommerce setup** that will configure all the necessary standard events for you.
18
+ >
19
+ >**Facebook Dynamic Ads is fully supported for WooCommerce**, with ViewContent, AddToCart and Purchase events being added on the corresponding pages (content_ids and content_type are pulled automatically by the plugin).
20
+ >
21
+ >The plugin is **Custom Audience Super-Friendly**, extracting content_name, post_type, content_ids, content_category on every page of your site. Tags and product tags are tracked by the pro version of the plugin.
22
 
23
+ You’ll find a **[Learning Section](http://www.pixelyoursite.com/learn)** on our website, with helpful articles that answer to our users common (and sometimes uncommon) questions, together with top notch “how to”pages.
 
 
 
 
24
 
25
  Find more info [about how to use the FB pixel plugin - Click here](http://www.pixelyoursite.com/facebook-pixel-plugin-help)
26
 
27
+ Not ready to install yet? Read on some of the key features that make PYS a powerful tool in any Facebook marketer arsenal.
28
 
29
  <strong>PixelYourSite Key Features:</strong></br>
30
 
31
+ * You can **insert the pixel on every page of your website with just ONE click**. No need to edit any posts or pages
32
+
33
+ * **Optimize your site for Facebook Custom Audiences.** We add a special event (GeneralEvent) on every page that will send Facebook key parameters, like content name, content ID, category name and post type. You can use them to create super-powerful Custom Audiences to retarget with your ads, or to expand your reach with Lookalike Audiences (we have a free guide and helpful articles on how to do it)
34
 
35
  * **Search Event** on the search page with the search string pulled as parameter - super useful for creating search based Custom Audiences
36
 
38
 
39
  * You can **set up and track Standard or Custom Events** and add parameters for each of them
40
 
41
+ * **Dynamic Events:** optimize your Facebook Campaigns for actions on your website (CLICKS on links, buttons, forms). Works with **Contact Form 7 and any other form or pop-up plugins.** ([Pro Version](http://www.pixelyoursite.com))
42
+
43
+ * Track **conversion value** for standard and custom events
44
 
45
+ * Track tags and use them for Custom Audiences ([Pro Version](http://www.pixelyoursite.com))
46
 
47
+ * Enable **Advanced Matching** - this new FB feature increases the chances to correctly identify users visiting your website without being logged to their Facebook accounts ([Pro Version](http://www.pixelyoursite.com))
48
 
49
+ * We automatically add a TimeOnPage event that measures the time each visitor spends on every page. It can be used for Custom Audiences and is super useful when you have key pages with offers or video content. You'll find an article on our site about how to use this feature. ([Pro Version](http://www.pixelyoursite.com))
50
 
51
  > <strong>How to create powerful Custom Audiences with PixelyourSite</strong>
52
 
58
 
59
  * You can **insert the Facebook pixel and start tracking events on any WooCommerce** website with just a few clicks (Purchase, ViewContent, AddToCart, InitiateCheckout)
60
 
61
+ * Out of the box **Facebook Dynamic Ads** pixel setup for your Woocommerce website (we also have a dedicated feed plugin for Facebook Dynamic Ads Product Catalog)
62
 
63
  * **Dynamic AddToCart** is fully supported (the AddToCart event will fire on add to cart button click)
64
 
65
  * **Track conversion value for WooCommerce** ([Pro Version](http://www.pixelyoursite.com))
66
 
67
+ * **WooCommerce Conversion Value Optimization:** You can include or exclude TAX for all the WooCommere events and Shipping cost for the Purchase event. You can use the full product price or just a percent of the price for each event Value. You can also set a general value for each event. ([Pro Version](http://www.pixelyoursite.com))
68
 
69
  * You can turn ON/OFF each WooCommerce event.
70
 
71
  * You can turn ON/OFF value for each WooCommerce event.
72
 
73
+ * **Super-Powerful Custom Audiences for WooCommerce:** we automatically track product name and product category (you can create audiences based on them), together with customer's city, state, and country. Additionally, we track payment and shipping methods. Use of coupons and coupon names are also automatically extracted. With this data, you can unleash some fantastic retargeting campaigns based on highly granulated audiences. ([Pro Version](http://www.pixelyoursite.com))
74
 
75
+ * **Advance Matching** is supported for all the events - this is a useful feature from Facebook that increases the chances to correctly identify users visiting your website without being logged to their Facebook accounts. Not sure what "Advanced Matching" does? We have not one, but two articles with more details on our site. ([Pro Version](http://www.pixelyoursite.com))
76
+
77
+ * **Track product tags** for all the events and use them to built Custom Audiences ([Pro Version](http://www.pixelyoursite.com))
78
 
79
  * **WooCommerce Affiliate Products Events:** you can add a dynamic event that will trigger on affiliate button clicks ([Pro Version](http://www.pixelyoursite.com))
80
 
81
  * **WooCommerce PayPal Standard Events:** you can add a dynamic AddPaymentInfo event that will trigger on WooCommerce PayPal button clicks ([Pro Version](http://www.pixelyoursite.com))
82
 
83
+ * Fully tested with the latest version of WooCommerce
 
84
 
85
  <strong>What's next<strong>
86
 
87
  We are working on some new handy features for the plugin and we will release them soon.
88
 
89
+ <strong>Pixel Helper Errors</strong>
 
 
 
 
90
 
91
+ If you are testing your pixel with Pixel Helper Chrome Extension, it is possible that you will see some errors:
92
 
93
+ **Facebook Pixel can't match products**
94
 
95
+ It means that the product ID is not found in a Dynamic Ads Product Catalog. If you are not doing Dynamic Ads, or if that event is not Dynamic Ads related, then you are fine. Otherwise, check your product catalog feed and make sure that that id is present in there.
96
 
97
+ For more details on how to use Facebook Pixel Helper and how to interpret its reported errors [read this special Pixel Helper article](http://www.pixelyoursite.com/facebook-pixel-helper-errors)
98
 
99
+ **Let’s start now!** Join other thousands of users and install the plugin, because it is easy to use, and will help you with your Facebook campaigns for real
 
 
 
100
 
101
 
102
  == Installation ==
130
 
131
  **Do I need to copy/paste the Facebook Pixel code somewhere?**
132
 
133
+ No, you just have to enter your pixel ID in the dedicated field. The plugin will do the rest for you.
134
 
135
  **Where can I find the Facebook Pixel ID?**
136
 
143
 
144
  a. The pixel code will be added on every page of your site
145
 
146
+ b. A "Search" standard event will be added to the search page of your site
147
 
148
  c. A GeneralEvent will be added on every page, pulling content_name, content_ids and content_type. It can be used for Custom Audiences.
149
 
157
 
158
  **Can I define new standard events?**
159
 
160
+ Yes, you can! There is a simple menu where you can do that. You'll need to add a URL and select the event type you want to add. If necessary, you can give each event a monetary value and its own currency.
161
 
162
  **Can I have more than just one event on a page?**
163
 
165
 
166
  **Can I use your plugin for Facebook Dynamic Ads?**
167
 
168
+ Yes, you can! Facebook Dynamic Product Ads are fully supported for WooCommerce. We plan to add a similar integration for Easy Digital Downloads soon.
169
 
170
  **Are there any known incompatibilities with other themes or plugins?**
171
 
172
  Any program, service, code or plugin that adds the Pixel Code, since you can't have to similar pixels on a page.
173
 
174
  * We had a problem with Mamaya, a retargeting service
175
+ * It won't work with LeadPages or any similar system because those pages are generated outside WordPress
176
 
177
  If any incompatibilities will arise we will add them here and, of course, will try to fix them as soon is possible.
178
 
187
  2. You don’t have to copy/paste all the pixel code, but just the pixel ID. You can find it in your Ads Manager, under Pixels
188
  3. The Search Event will pull each search on your site as a parameter. You can use it to create Custom Audiences
189
  4. The GeneralEvent is triggered on every page and can be used for Custom Audiences. We have a free guide on how to use it, liked from the plugin itself
190
+ 5. Adding events to any URL of any page of your website is easy: just add the URL, select event type and fill the desired parameters values
191
  6. If you want you can insert a custom event code
192
  7. Or you can select a standard event and use the default parameters
193
  8. WooCommerce integration comes with out of the box Facebook Dynamic Ads setup
195
 
196
  == Changelog ==
197
 
198
+ = PixelYourSite 3.1.0 =
199
+
200
+ * Changing GeneralEvent parameters names to avoid Pixel Helper warning (post_id and post_type are now being used)
201
+
202
+ * Updating new pro features (tracking tags, advanced matching)
203
+
204
+ * Minor fixes and code changes
205
+
206
+ = PixelYourSite 3.0.3 =
207
 
208
  * Fixing PHP warnings and errors
209
 
213
 
214
  = PixelYourSite 3.0.2 =
215
 
216
+ * Small fixes related to some possible HTML errors
217
 
218
+ * Admin Notice modifications
219
 
220
  = PixelYourSite 3.0.1 =
221
 
239
 
240
  = PixelYourSite 2.2.4 =
241
 
242
+ * Fixed a few back*end errors and conflicts
243
 
244
  * Adding new currencies
245
 
303
 
304
  = PixelYourSite 1.0 =
305
 
306
+ * A new plugin is born: It will let you manage the Facebook Pixel with just a few clicks
307
 
308
 
309
  == Upgrade Notice ==
311
  = 3.0 =
312
 
313
  3.0 is a complete rewrite, with a new design and improve functionality. You have a new GeneralEvent that can be used to create Custom Audiences (plus a FREE guide on how to do it!) and Facebook Dynamic Ads are fully supported for WooCommerce. Update, then open the plugin menu for details