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

Version Description

Download this release

Release Info

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

Code changes from version 3.0 to 3.0.1

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
9
  License: GPLv3
10
  */
11
 
@@ -16,7 +16,7 @@ if( defined( 'WP_DEBUG' ) && WP_DEBUG == true ) {
16
  error_reporting( E_ALL );
17
  }
18
 
19
- define( 'PYS_FREE_VERSION', '3.0');
20
 
21
  require_once( 'inc/common.php' );
22
  require_once( 'inc/admin_notices.php' );
@@ -39,6 +39,13 @@ function pys_free_init() {
39
  }
40
 
41
  }
 
 
 
 
 
 
 
42
 
43
  }
44
 
@@ -127,19 +134,9 @@ if( !function_exists( 'pys_free_plugin_activated' ) ) {
127
  }
128
 
129
  $options = get_option( 'pixel_your_site' );
130
- if ( ! $options ) {
131
-
132
- // set default options values
133
- $defaults = pys_get_default_options();
134
- update_option( 'pixel_your_site', $defaults );
135
 
136
- // migrate settings from old versions
137
- if( get_option( 'woofp_admin_settings' ) ) {
138
-
139
- require_once( 'inc/migrate.php' );
140
- pys_migrate_from_22x();
141
-
142
- }
143
 
144
  }
145
 
@@ -157,4 +154,24 @@ if( !function_exists( 'pys_free_plugin_activated' ) ) {
157
 
158
  }
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
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.1
9
  License: GPLv3
10
  */
11
 
16
  error_reporting( E_ALL );
17
  }
18
 
19
+ define( 'PYS_FREE_VERSION', '3.0.1');
20
 
21
  require_once( 'inc/common.php' );
22
  require_once( 'inc/admin_notices.php' );
39
  }
40
 
41
  }
42
+
43
+ $options = get_option( 'pixel_your_site' );
44
+ if ( ! $options || ! isset( $options['general']['pixel_id'] ) || empty( $options['general']['pixel_id'] ) ) {
45
+
46
+ pys_initialize_settings();
47
+
48
+ }
49
 
50
  }
51
 
134
  }
135
 
136
  $options = get_option( 'pixel_your_site' );
137
+ if ( ! $options || ! isset( $options['general']['pixel_id'] ) || empty( $options['general']['pixel_id'] ) ) {
 
 
 
 
138
 
139
+ pys_initialize_settings();
 
 
 
 
 
 
140
 
141
  }
142
 
154
 
155
  }
156
 
157
+ }
158
+
159
+ if( !function_exists( 'pys_initialize_settings' ) ) {
160
+
161
+ function pys_initialize_settings() {
162
+
163
+ // set default options values
164
+ $defaults = pys_get_default_options();
165
+ update_option( 'pixel_your_site', $defaults );
166
+
167
+ // migrate settings from old versions
168
+ if( get_option( 'woofp_admin_settings' ) ) {
169
+
170
+ require_once( 'inc/migrate.php' );
171
+ pys_migrate_from_22x();
172
+
173
+ }
174
+
175
+ }
176
+
177
  }
inc/admin.php DELETED
@@ -1,623 +0,0 @@
1
- <div class="wrap">
2
- <h2>PixelYourSite: Manage your Facebook Pixel</h2>
3
-
4
- <div class="facebook-pixel-wrap" id="facebook-pixel-wrap">
5
- <div class="facebook-pixel-body">
6
- <ul class="facebook-pixel-menu nav-tab-wrapper">
7
- <li id="facebook-pixel-menu-1" class="nav-tab nav-tab-active selected">Facebook Pixel</li>
8
- <li id="facebook-pixel-menu-2" class="nav-tab">On Post/Page Events</li>
9
- <li id="facebook-pixel-menu-3" class="nav-tab">Dynamic Events</li>
10
- <li id="facebook-pixel-menu-4" class="nav-tab">WooCommerce Setup</li>
11
- <li id="facebook-pixel-menu-5" class="nav-tab">PayPal Setup</li>
12
- </ul>
13
-
14
-
15
- <div class="facebook-pixel-content">
16
- <form action="" method="post" name="facebook-pixel-form" id="facebook-pixel-form">
17
-
18
- <?php wp_nonce_field( 'woofp-nonce-action', 'woofpnonce' );?>
19
-
20
- <div id="facebook-pixel-panel-1" class="facebook-pixel-panel">
21
-
22
- <table class="form-table">
23
- <tbody>
24
- <tr>
25
- <td colspan="2"><?php echo woofp_admin_notices(true); ?></td>
26
- </tr>
27
- <tr>
28
- <th scope="row">&nbsp;</th>
29
- <td><p><b class="woofpimportant">Important:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Read this before starting.</a></p></td>
30
- </tr>
31
-
32
-
33
- <tr>
34
- <th scope="row">Your Pixel ID:</th>
35
- <td>
36
- <input type="text" name="facebookpixel[ID]" value="<?php echo woofp_get_option('facebookpixel', 'ID'); ?>">
37
- <p class="description">Enter your Facebook Pixel ID here.</p>
38
- </td>
39
- </tr>
40
- <tr>
41
- <th scope="row">&nbsp;</th>
42
- <td>
43
- <input type="checkbox" value="1" id="facebookpixel-activate" name="facebookpixel[activate]" <?php checked( '1', woofp_get_option('facebookpixel', 'activate'), true ); ?> />Activate Plugin General Settings.
44
- <p class="description">Check this to enable Facebook Pixel.</p>
45
- </td>
46
- </tr>
47
-
48
- <tr>
49
- <th scope="row">&nbsp;</th>
50
- <td><input type="button" class="button button-primary woofp-savesettings" value="Save Settings" /></td>
51
- </tr>
52
-
53
- <tr>
54
- <th scope="row">&nbsp;</th>
55
- <td style="color:#333;">
56
- <h2 style="font-weight: 400;color:#333;">Key Readings</h2>
57
-
58
- <p style="font-weight: 400; font-size:12px; color:#333;">
59
- PixelYourSite is not just a simple plugin, we try to connect with our users and offer them the best possible information.
60
- <br><b>Here are some of the most appreciated articles from our Learning Section:</b></p>
61
- <br>
62
- <a href="http://www.pixelyoursite.com/facebook-pixel-helper-errors" target="_blank">How to check your FB Pixel for errors</a>
63
- <br><br>
64
- <a href="http://www.pixelyoursite.com/facebook-ads-reports-optimisation" target="_blank">How to create Custom Reports to better understand conversion</a>
65
- <br><br>
66
- [Important]: <a href="http://www.pixelyoursite.com/custom-audiences-from-events" target="_blank">How to Create Custom Audiences based on Events on your website</a>
67
-
68
-
69
- </td>
70
- </tr>
71
-
72
- </tbody>
73
- </table>
74
-
75
- </div><!-- panel 1 -->
76
-
77
-
78
- <?php
79
- //if not active hide standard event url option
80
- $hide_standardevent = 'show-standardevent ';
81
- if( woofp_get_option('standardevent', 'activate') != 1 ) { $hide_standardevent .= ' hide-standardevent'; }
82
- ?>
83
-
84
- <div id="facebook-pixel-panel-2" class="facebook-pixel-panel ">
85
- <table class="form-table">
86
- <tbody>
87
-
88
- <tr>
89
- <td colspan="2"><?php echo woofp_admin_notices(true); ?></td>
90
- </tr>
91
-
92
- <tr>
93
- <th scope="row">&nbsp;</th>
94
- <td><p><b class="woofpimportant">Important:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Read this before starting.</a></p></td>
95
- </tr>
96
-
97
-
98
- <tr class=" <?php echo $hide_standardevent; ?>">
99
- <th scope="row">&nbsp;</th>
100
- <td><h3 style="float:left;" class="woofpimportant">Add Standard or Custom Events on Page/Post <span class="woofp-events-help"><b class="woofp-help-icon">?</b><?php woofp_event_help(); ?></span></h3></td>
101
- </tr>
102
-
103
- <?php
104
- $code = '';
105
- if( !empty( $standardevent['pageurl'] ) ) {
106
-
107
-
108
- foreach ( $standardevent['pageurl'] as $key => $link) {
109
-
110
- $pageurl = isset( $standardevent['pageurl'][$key] ) ? $standardevent['pageurl'][$key] : '';
111
- $cartvalue = isset( $standardevent['value'][$key] ) ? $standardevent['value'][$key] : '';
112
- $currency = isset( $standardevent['currency'][$key] ) ? $standardevent['currency'][$key] : '';
113
- $eventtype = isset( $standardevent['eventtype'][$key] ) ? $standardevent['eventtype'][$key] : '';
114
- $code = isset( $standardevent['code'][$key] ) ? $standardevent['code'][$key] : '';
115
-
116
- ?>
117
-
118
- <tr class="woofp-pageurl-tr <?php echo $hide_standardevent; ?>">
119
- <th scope="row">Page( Full or Partial URL)</th>
120
- <td>
121
- <p>
122
- <input type="text" name="standardevent[pageurl][]" value="<?php echo $pageurl; ?>" class="woofp-input-pageurl" />
123
- </p>
124
- <p class="description">This Event will trigger on any URL that contains this string..<br>
125
- If you add * at the end of the URL string it will match all URLs starting with the URL string.
126
- </p>
127
-
128
- <p>
129
- <b class="event_param">Event Type: </b>
130
- <select name="standardevent[eventtype][]" class="woofp-input-event">
131
- <option value="">- Select Event -</option>
132
- <?php echo woofp_event_types($eventtype); ?>
133
- </select>
134
- </p>
135
-
136
- <p class="standarevent-value">
137
- <b class="event_param">Value: </b><input type="text" name="standardevent[value][]" value="<?php echo $cartvalue; ?>" class=" woofp-input-value" />
138
- <span class="woofp-input-desc">&nbsp;&nbsp;*Mandatory for purchase event only.</span>
139
- </p>
140
-
141
- <p class="standarevent-currency">
142
- <b class="event_param">Currency: </b><select name="standardevent[currency][]" class=" woofp-input-currency">
143
- <option value="">Select Currency</option>
144
- <?php echo woofp_currency_options($currency); ?>
145
- </select>
146
- <span class="woofp-input-desc">&nbsp;&nbsp;*Mandatory for purchase event only.</span>
147
-
148
- </p>
149
-
150
- <div class="standardevent-params">
151
- <?php
152
- $woofp_vars = woofp_vars();
153
- $standardevent_params = woofp_standardevent_extented($eventtype);
154
- foreach ($standardevent_params as $k => $param) {
155
- $parame_name = $param['name'];
156
-
157
- unset($woofp_vars[$parame_name]);
158
-
159
- $param_value = ( isset( $standardevent[$parame_name][$key] ) ? $standardevent[$parame_name][$key] : '' );
160
-
161
- ?>
162
- <div class="event_param_wrap">
163
- <?php if( $parame_name == 'content_type') { ?>
164
- <b class="event_param"><?php echo $parame_name; ?>: </b><select name="standardevent[<?php echo $parame_name; ?>][]" >
165
- <option <?php selected( 'product', $param_value, true ); ?>value="product">product</option>
166
- <option <?php selected( 'product_group', $param_value, true ); ?>value="product_group">product_group</option>
167
- </select>
168
- <?php } else {?>
169
- <b class="event_param"><?php echo $parame_name; ?>: </b><input type="text" name="standardevent[<?php echo $parame_name; ?>][]" value="<?php echo stripslashes($param_value); ?>" />
170
- <?php } ?>
171
- <p class="description"><?php echo $param['info'] . ' i.e ' . $param['example'] ?></p>
172
- </div>
173
-
174
- <?php
175
- }
176
- ?>
177
- <?php foreach ($woofp_vars as $woofp_vars_key => $woofp_vars_value) {?>
178
- <input type="hidden" name="standardevent[<?php echo $woofp_vars_value; ?>][]" value="" style="display:none;" />
179
- <?php } ?>
180
- </div>
181
- <h4>OR add event code here (Advance users only):</h4>
182
- <textarea style="width:35em;height:180px;" name="standardevent[code][]"><?php echo stripslashes($code); ?></textarea>
183
- <div class="code_important">
184
- <p class="description"><span class="woofp-asterik">*</span>The code inside the event field will overwrite and will have priority over any other data for that event.</p>
185
- <p class="description"><span class="woofp-asterik">*</span>The code inserted in the field MUST be complete, including fbq('track', 'AddToCart', { …… });</p>
186
- </div>
187
-
188
- </td>
189
- </tr>
190
-
191
- <?php
192
-
193
- }
194
- } else {
195
-
196
- ?>
197
-
198
- <tr class="woofp-pageurl-tr <?php echo $hide_standardevent; ?>">
199
- <th scope="row">Page(URL or Partial URL)</th>
200
- <td>
201
-
202
- <p><input type="text" name="standardevent[pageurl][]" value="" class="woofp-input-pageurl" /></p>
203
- <p class="description">
204
- This Event will trigger on any URL that contains this string.<br>
205
- If you add * at the end of the URL string it will match all URLs starting with the URL string.
206
- </p>
207
-
208
- <p>
209
- <select name="standardevent[eventtype][]" class="woofp-input-event">
210
- <option value="">- Select Event -</option>
211
- <?php echo woofp_event_types(''); ?>
212
- </select>
213
- </p>
214
-
215
- <p class="standarevent-value">
216
- <b class="event_param">Value: </b><input type="text" name="standardevent[value][]" value="" class=" woofp-input-value" />
217
- </p>
218
- <p class="standarevent-currency">
219
- <b class="event_param">Currency: </b><select name="standardevent[currency][]" class=" woofp-input-currency">
220
- <option value="">Select Currency</option>
221
- <?php echo woofp_currency_options(''); ?>
222
- </select>
223
- <span class="woofp-input-desc">*Mandatory for purchase event only.</span>
224
- </p>
225
- <div class="standardevent-params"></div>
226
- <h4>OR add event code here (Advance users only):</h4>
227
- <textarea style="width:35em;height:180px;" name="standardevent[code][]"></textarea>
228
- <div class="code_important">
229
- <p class="description"><span class="woofp-asterik">*</span>The code inside the event field will overwrite and will have priority over any other data for that event.</p>
230
- <p class="description"><span class="woofp-asterik">*</span>The code inserted in the field MUST be complete, including fbq('track', 'EventName', { …… });</p>
231
- </div>
232
-
233
- </td>
234
- </tr>
235
-
236
- <?php
237
- }
238
- ?>
239
- <tr class="<?php echo $hide_standardevent; ?>">
240
- <th scope="row">&nbsp;</th>
241
- <td><input type="button" class="button button-secondary woofp-addevent" value="Add More Events" /></td>
242
- </tr>
243
-
244
- <tr>
245
- <th scope="row">&nbsp;</th>
246
- <td>
247
- <input type="checkbox" value="1" id="standardevent-activate" name="standardevent[activate]" <?php checked( '1', woofp_get_option('standardevent', 'activate'), true ); ?> />Activate Standard Event Setup.
248
- <p class="description">Check this to enable Standard Event Setup.</p>
249
- </td>
250
- </tr>
251
-
252
- <tr>
253
- <th scope="row">&nbsp;</th>
254
- <td><input type="button" class="button button-primary woofp-savesettings" value="Save Standard Event Setup Settings" /></td>
255
- </tr>
256
-
257
- </tbody>
258
- </table>
259
- </div><!-- panel 2 -->
260
-
261
-
262
- <div id="facebook-pixel-panel-3" class="facebook-pixel-panel ">
263
- <table class="form-table">
264
- <tbody>
265
-
266
- <tr>
267
- <td colspan="2"><?php echo woofp_admin_notices(true); ?></td>
268
- </tr>
269
-
270
- <tr>
271
- <th scope="row">&nbsp;</th>
272
- <td style="color:#333;">
273
- <h2 style="font-weight: 400;color:#333;">Start using Dynamic Events with the PRO version of the plugin</h2>
274
-
275
- <p style="font-weight: 400; font-size:12px; color:#333;">
276
- With Dynamic Events you can optimize your ads for actions on your website, like filing up forms (Contact Form 7 supported), newsletter sign ups, <br>or any other click on links and buttons. Better ad optimization, better custom audience targeting, better conversion tracking. <br><b>If you are not using Facebook Dynamic Events you are literally leaving money on the table</b>
277
- </p>
278
- <br>
279
- <b>Super Offer Ending Soon: </b><a href="http://www.pixelyoursite.com/super-offer?utm_source=woordpress-tab-fb-dynamic-events&utm_medium=tab-fb-dynamic-events&utm_campaign=tab-fb-dynamic-events" target="_blank">Update now and start to benefit from Dynamic Events</a>
280
- <br><br>
281
- Or Learn more about <a href="http://www.pixelyoursite.com/facebook-pixel-dynamic-events" target="_blank">How to use Dynamic Events - Complete guide</a>
282
-
283
-
284
- </td>
285
- </tr>
286
-
287
- <tr>
288
- <th scope="row">Process links</th>
289
- <td>
290
- <p><input type="checkbox" value="1" id="custom_event-content" name="custom_event[enable_post_contents]"
291
- disabled="disabled" />
292
- Process links in Post Content <code>( the_content(); hook )</code>
293
- </p>
294
-
295
-
296
- <p><input type="checkbox" value="1" id="custom_event-widget" name="custom_event[enable_widget_text]"
297
- disabled="disabled" />
298
- Process links in Widgets Text <code>( widget_text(); hook )</code>
299
- </p>
300
-
301
- </td>
302
-
303
- </tr>
304
-
305
-
306
- <tr class="woofp-hreflink-tr ">
307
- <th scope="row" style="padding-top: 60px;">Full or Partial URL</th>
308
- <td>
309
-
310
-
311
- <p>
312
- <b class="event_param">Trigger Event On:</b>
313
- <select name="custom_event[trigger_type]">
314
- <option value="url">URL</option>
315
- <option value="css_selector">CSS Selector</option>
316
- </select>
317
- </p>
318
-
319
- <p class="woofp-custom-event-inputvalue">
320
- <input type="text" name="custom_event[hreflink][]" value="" class="woofp-input-hreflink" disabled="disabled" />
321
- <input type="text" name="custom_event[selector][]" value="" class="woofp-customevent-selector woofp-input-hreflink" style="display:none;"/>
322
- </p>
323
- <p class="description woofp-custom-event-valuedesc">
324
- <span class="woofp-custom-event-urldesc">
325
- This Event will trigger on any URL that contains the partial string.<br>
326
- If you add <b class="woofp-wildcard">*</b> at the end of the Full URL it will match all URLs starting with the URL.
327
- </span>
328
- <span class="woofp-custom-event-selectordesc" style="display:none;">
329
- This Event will trigger on the entered CSS Selector.<br>
330
- Please read about CSS Selector <a href="#">here</a>.
331
- </span>
332
- </p>
333
-
334
-
335
- <p>
336
- <b class="event_param">Event Type: </b>
337
- <select name="custom_event[eventtype][]" class="woofp-input-customevent" disabled="disabled">
338
- <option value="">- Select Event -</option>
339
-
340
- </select>
341
- </p>
342
-
343
- <p class="standarevent-value">
344
- <b class="event_param">Value: </b><input type="text" name="custom_event[value][]" value="" disabled="disabled" class=" woofp-input-value" />
345
- </p>
346
-
347
- <p class="standarevent-currency">
348
- <b class="event_param">Currency: </b><select name="custom_event[currency][]" class=" woofp-input-currency" disabled="disabled">
349
- <option value="">Select Currency</option>
350
- </select>
351
-
352
- <span class="woofp-input-desc">*Mandatory for purchase event only.</span>
353
- </p>
354
- <div class="custom_event-params"></div>
355
- <h4>OR add event code here (Advance users only):</h4>
356
- <textarea style="width:35em;height:180px;" name="custom_event[code][]" disabled="disabled"></textarea>
357
-
358
- </td>
359
- </tr>
360
-
361
-
362
-
363
- <tr>
364
- <th scope="row">&nbsp;</th>
365
- <td>
366
- <input type="checkbox" value="1" id="custom_event-activate" name="custom_event[activate]" disabled="disabled" />Activate Custom Event Setup.
367
- <p class="description">Check this to enable Custom Event Setup.</p>
368
- </td>
369
- </tr>
370
-
371
- <tr>
372
- <th scope="row">&nbsp;</th>
373
- <td><input type="button" class="button button-primary woofp-savesettings woopf-custom-event-setup" value="Save Custom Event Setup Settings" disabled="disabled" /></td>
374
- </tr>
375
-
376
- </tbody>
377
- </table>
378
- </div><!-- panel 3 -->
379
-
380
-
381
-
382
- <div id="facebook-pixel-panel-4" class="facebook-pixel-panel">
383
- <?php if( woofp_is_woocommerce() ){ ?>
384
- <table class="form-table">
385
- <tbody>
386
-
387
- <tr>
388
- <td colspan="2"><?php echo woofp_admin_notices(true); ?></td>
389
- </tr>
390
-
391
- <tr>
392
- <th scope="row">&nbsp;</th>
393
- <td><p><b class="woofpimportant">Important:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Read this before starting.</a></p></td>
394
- </tr>
395
-
396
- <tr>
397
- <th scope="row">&nbsp;</th>
398
- <td><p><b class="woofpimportant">WooCommerce Help:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-woocommerce" target="_blank">Read this before activating WooCommerce Setup.</a></p></td>
399
- </tr>
400
-
401
- <tr>
402
- <th scope="row">&nbsp;</th>
403
- <td><h3 style="float:left;">Activate WooCommerce events</h3>
404
- </td>
405
- </tr>
406
- <?php foreach ( woofp_woocommerce_events() as $key => $woocommerce_event) { ?>
407
-
408
-
409
- <tr>
410
- <th scope="row"><?php echo $woocommerce_event['title']; ?></th>
411
- <td><input type="checkbox" name="woocommerce[events][<?php echo $woocommerce_event['event']; ?>]" value="1" <?php woofp_is_woocommerce_event($woocommerce_event['event'], $woocommerce_settings); ?> /> <?php echo $woocommerce_event['label']; ?></td>
412
- </tr>
413
-
414
- <?php } ?>
415
-
416
-
417
- <tr>
418
- <th scope="row">&nbsp;</th>
419
- <td style="color:#333;">
420
- <h2 style="font-weight: 400;color:#333;">Update to the PRO to start tracking conversion value and enable Facebook Dynamic Ads for WooCommerce</h2>
421
-
422
- <p style="font-weight: 400; font-size:12px; color:#333;">
423
- The PRO version will pull all the parameters for your WooCommerce events and will enable you to use<br> Facebook Dynamic Ads
424
- </p>
425
- <br>
426
- <b style="font-weight: 400;color:#333;">Track conversion value & Facebook Dynamic Ads for WooCommerce</b>
427
- </td>
428
- </tr>
429
-
430
- <tr>
431
- <th scope="row">&nbsp;</th>
432
- <td>
433
- <input type="checkbox" value="1" name="woocommerce_dynamic[ViewContent]" disabled="disabled" /><span class="disabled">Activate ViewContent event for Facebook Dynamic Ads.</span>
434
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo?utm_source=woordpress-tab3-fb-dynamic&utm_medium=tab3-fb-dynamic&utm_campaign=tab3-fb-dynamic" target="_blank">Update to the Pro Version</a>
435
- <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(any WooCommerce Page)</i></p>
436
-
437
- </td>
438
- </tr>
439
-
440
- <tr>
441
- <th scope="row">&nbsp;</th>
442
- <td>
443
- <input type="checkbox" value="1" name="woocommerce_dynamic[AddToCart]" disabled="disabled" /><span class="disabled">Activate AddToCart event for Facebook Dynamic Ads.</span>
444
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo?utm_source=woordpress-tab3-fb-dynamic&utm_medium=tab3-fb-dynamic&utm_campaign=tab3-fb-dynamic" target="_blank">Update to the Pro Version</a>
445
- <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(Cart Page)</i></p>
446
- </td>
447
- </tr>
448
- <tr>
449
- <th scope="row">&nbsp;</th>
450
- <td>
451
- <input type="checkbox" value="1" name="woocommerce_dynamic[intiatecheckout]" disabled="disabled" <?php checked( '1', woofp_get_option('woocommerce', 'intiatecheckout'), true ); ?> /><span class="disabled">Activate InitiateCheckout for Facebook Dynamic Ads.</span>
452
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo?utm_source=woordpress-tab3-fb-dynamic&utm_medium=tab3-fb-dynamic&utm_campaign=tab3-fb-dynamic" target="_blank">Update to the Pro Version</a>
453
- <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. </i>(Checkout Page)</i></p>
454
- </td>
455
- </tr>
456
- <tr>
457
- <th scope="row">&nbsp;</th>
458
- <td>
459
- <input type="checkbox" value="1" name="woocommerce_dynamic[purchase]" disabled="disabled" /><span class="disabled">Activate Purchase event for Facebook Dynamic Ads.</span>
460
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo?utm_source=woordpress-tab3-fb-dynamic&utm_medium=tab3-fb-dynamic&utm_campaign=tab3-fb-dynamic" target="_blank">Update to the Pro Version</a>
461
- <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(Order Recieved/Thank You Page)</i></p>
462
- </td>
463
- </tr>
464
- <tr>
465
- <th scope="row">&nbsp;</th>
466
- <td>
467
- <input type="checkbox" value="1" name="woocommerce_dynamic[ProductAddToCart]" disabled="disabled" /><span class="disabled">Activate Product AddToCart event for Facebook Dynamic Ads.</span>
468
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo?utm_source=woordpress-tab3-fb-dynamic&utm_medium=tab3-fb-dynamic&utm_campaign=tab3-fb-dynamic" target="_blank">Update to the Pro Version</a>
469
- <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>((When Product is Added to Cart))</i></p>
470
- </td>
471
- </tr>
472
-
473
- <tr>
474
- <td colspan="2" style="padding:0;"><hr></td>
475
- </tr>
476
-
477
- <tr class="affiliate_row">
478
- <th scope="row">&nbsp;</th>
479
- <td>
480
-
481
- <h2 style="font-weight: 400;color:#333;">WooCommerce Affiliate Products Events</h2>
482
- <p style="font-weight: 400; font-size:12px; color:#333;">It will add a dynamic event on WooCommerce affiliate products buttons</p>
483
-
484
- <p>
485
- <label>Affiliate button event:</label>
486
- <select name="woocommerce_affiliate[affiliate_event]" class="woofp-input-event" disabled="disabled" >
487
- <?php echo woofp_event_types(''); ?>
488
- </select>
489
- </p>
490
- <span class="woofpbold woofp-or">OR</span>
491
- <p>
492
- <label>Name for custom event:</label>
493
- <input type="text" value="" name="woocommerce_affiliate[affiliate_custom]" disabled="disabled" />
494
- </p>
495
- <p>
496
- <p class="description">*In the PRO version this event will have all the parameters values specific for the selected event.</p>
497
- <p class="description">*In the PRO version the custom event will have <i>value, currency, content_name, content_type, content_ids</i>.</p>
498
- </p>
499
- <br>
500
- <p>
501
- <input type="checkbox" value="" name="woocommerce_affiliate[affiliate_value]" disabled="disabled" /><span class="woofpbold"> Event value = Product Price</span>
502
- If left unchecked the event will not pull product price as event value
503
- </p>
504
- <p>
505
- <label>Global value:</label><input type="text" value="" name="woocommerce_affiliate[affiliate_global]" disabled="disabled" />
506
- <p class="description"><span class="woofp-asterik">*</span>Set this if you want a unique global value every time the afiliate button is clicked</p>
507
- </p>
508
- <br>
509
-
510
- <br>
511
- <p>
512
- <input type="checkbox" value="1" name="woocommerce_affiliate[activate]" disabled="disabled" /><span class="disabled"><span class="woofpbold">Activate WooCommerce Affiliate Products Events.</span></span>
513
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo?utm_source=woordpress-affiliate&utm_medium=affiliate-button&utm_campaign=affiliate-button" target="_blank"><span class="woofpbold">Update to the Pro Version</span></a>
514
- </p>
515
- </td>
516
- </tr>
517
-
518
- <tr>
519
- <td colspan="2" style="padding:0;"><hr></td>
520
- </tr>
521
-
522
- <tr>
523
- <th scope="row">&nbsp;</th>
524
- <td>
525
- <h2>Special Offer - Will end soon:</h2><a href="http://www.pixelyoursite.com/super-offer?utm_source=woordpress-3tab&utm_medium=special-offer&utm_campaign=wp-3t-special-offer" target="_blank">Click Here to get your HUGE discount now</a>
526
- </td>
527
- </tr>
528
-
529
-
530
-
531
- <tr>
532
- <th scope="row">&nbsp;</th>
533
- <td>
534
- <input type="checkbox" value="1" id="woocommerce-activate" name="woocommerce[activate]" <?php checked( '1', woofp_get_option('woocommerce', 'activate'), true ); ?> /><b>Activate WooCommerce Setup.</b>
535
- <p class="description">Check this to enable WooCommerce Setup.</p>
536
- </td>
537
- </tr>
538
-
539
- <tr>
540
- <th scope="row">&nbsp;</th>
541
- <td><input type="button" class="button button-primary woofp-savesettings" value="Save WooCommerce Settings" /></td>
542
- </tr>
543
- </tbody>
544
- </table>
545
-
546
- <?php } else { ?>
547
- <div>
548
- <br>
549
- <p>Please install and activate <b>WooCommerce</b> to enable WooCommerce integration</p>
550
- </div>
551
- <?php } ?>
552
- </div><!-- panel 4 -->
553
-
554
-
555
- <div id="facebook-pixel-panel-5" class="facebook-pixel-panel">
556
- <?php if( woofp_is_woocommerce() ){ ?>
557
- <table class="form-table">
558
- <tbody>
559
- <tr>
560
- <td colspan="2"><?php echo woofp_admin_notices(true); ?></td>
561
- </tr>
562
- <tr class="paypal_row">
563
- <th scope="row">&nbsp;</th>
564
- <td>
565
-
566
- <h2 style="font-weight: 400;color:#333;">WooCommerce PayPal Standard Event</h2>
567
- <p style="font-weight: 400; font-size:12px; color:#333;">It will add a dynamic event on WooCommerce PayPal Standard button</p>
568
-
569
- <p>
570
- <label>PayPal button event:</label>
571
- <select name="woocommerce_paypal[event_name]" class="woofp-input-event" disabled="disabled" >
572
- <?php echo woofp_event_types('AddPaymentInfo'); ?>
573
- </select>
574
- </p>
575
- <span class="woofpbold woofp-or">OR</span>
576
- <p>
577
- <label>Name for custom event:</label>
578
- <input type="text" value="" name="woocommerce_paypal[event_custom]" disabled="disabled" />
579
- </p>
580
- <p>
581
- <p class="description">*In the PRO version this event will have all the parameters values specific for the selected event.</p>
582
- <p class="description">*In the PRO version the custom event will have <i>value, currency, content_name, content_type, content_ids</i>.</p>
583
- </p>
584
- <br>
585
- <p>
586
- <input type="checkbox" value="" name="woocommerce_paypal[event_value]" disabled="disabled" /><span class="woofpbold"> Event value = Product Price</span>
587
- If left unchecked the event will not pull product price as event value
588
- </p>
589
- <p>
590
- <label>Global value:</label><input type="text" value="" name="woocommerce_paypal[event_global]" disabled="disabled" />
591
- <p class="description"><span class="woofp-asterik">*</span>Set this if you want a unique global value every time the PayPal Payment button is clicked</p>
592
- </p>
593
- <br>
594
-
595
- <br>
596
- <p>
597
- <input type="checkbox" value="1" name="woocommerce_paypal[activate]" disabled="disabled" /><span class="disabled"><span class="woofpbold">Activate WooCommerce PayPal Payment Button.</span></span>
598
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo?utm_source=woordpress-tab4-pixel-paypal&utm_medium=tab4-pixel-paypal&utm_campaign=tab4-pixel-paypal" target="_blank"><span class="woofpbold">Update to the Pro Version</span></a>
599
- </p>
600
- </td>
601
- </tr>
602
-
603
- <tr>
604
- <th scope="row">&nbsp;</th>
605
- <td><input type="button" class="button button-primary woofp-savesettings" value="Save PayPal Settings" disabled="disabled" /></td>
606
- </tr>
607
- </tbody>
608
- </table>
609
-
610
- <?php } else { ?>
611
- <div>
612
- <br>
613
- <p>Please install and activate <b>WooCommerce</b> to enable WooCommerce integration</p>
614
- </div>
615
- <?php } ?>
616
- </div><!-- panel 5 -->
617
-
618
- </form>
619
- </div>
620
- </div>
621
- </div>
622
-
623
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin_notices.php CHANGED
@@ -41,11 +41,11 @@ $day_2_text = '<span class="pysf_note"><b>PixelYourSite General Event -</b></spa
41
  $day_2_text .= '<a href="http://www.pixelyoursite.com/general-event" target="_blank">CLICK TO DOWNLOAD THE FREE GUIDE</a>';
42
 
43
  //Message for day 3
44
- $day_3_text = '<span class="pysf_note"><b>PixelYourSite Free Guide -</b></span> Last chanche to download the FREE guide about how to use General Event Option to build powerful Custom Audiences: ';
45
  $day_3_text .= '<a href="http://www.pixelyoursite.com/general-event" target="_blank">CLICK TO DOWNLOAD THE FREE GUIDE</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
@@ -136,7 +136,7 @@ $woo_day_3_text .= '<a href="http://www.pixelyoursite.com/bundle-offer" target="
136
 
137
  //WooCommerce Message for day 4 to 7;
138
  $woo_day_4_to_7_text = 'WooCommerce Day 4 to 7 Message.';
139
- $woo_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';
140
 
141
 
142
  //WooCommerce Message for day 7 to 12
41
  $day_2_text .= '<a href="http://www.pixelyoursite.com/general-event" target="_blank">CLICK TO DOWNLOAD THE FREE GUIDE</a>';
42
 
43
  //Message for day 3
44
+ $day_3_text = '<span class="pysf_note"><b>PixelYourSite Free Guide -</b></span> Last chance to download the FREE guide about how to use General Event Option to build powerful Custom Audiences: ';
45
  $day_3_text .= '<a href="http://www.pixelyoursite.com/general-event" target="_blank">CLICK TO DOWNLOAD THE FREE GUIDE</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 maintaining 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
136
 
137
  //WooCommerce Message for day 4 to 7;
138
  $woo_day_4_to_7_text = 'WooCommerce Day 4 to 7 Message.';
139
+ $woo_day_4_to_7_text = '<span class="pysf_note"><b>Thank You for using PixelYourSite!</b></span> We put many hours into developing and maintaining 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';
140
 
141
 
142
  //WooCommerce Message for day 7 to 12
inc/helper-functions - Copy.php DELETED
@@ -1,901 +0,0 @@
1
- <?php
2
- /**
3
- * Get Admin Settings
4
- *
5
- * @return array
6
- * @author PixelYourSite
7
- **/
8
- function woofp_admin_settings($option_name='all'){
9
-
10
-
11
- $settings = get_option('woofp_admin_settings');
12
-
13
- if(empty($settings)) {
14
-
15
- $settings = array();
16
-
17
- } else {
18
-
19
- $options = array('facebookpixel', 'standardevent', 'woocommerce');
20
- foreach ( $options as $key => $name ) {
21
-
22
- if( !isset( $settings[$name]) || empty( $settings[$name] ) ){
23
-
24
- $settings[$name] = array();
25
- }
26
- }
27
- }
28
-
29
-
30
- switch ($option_name) {
31
- case 'all':
32
-
33
- return $settings;
34
-
35
- break;
36
-
37
- case 'facebookpixel':
38
-
39
- return ( isset($settings['facebookpixel']) ? $settings['facebookpixel'] : '' );
40
-
41
- break;
42
-
43
- case 'standardevent':
44
-
45
- return ( isset($settings['standardevent']) ? $settings['standardevent'] : '' );
46
-
47
-
48
- break;
49
-
50
- case 'woocommerce':
51
-
52
- return ( isset($settings['woocommerce']) ? $settings['woocommerce'] : '' );
53
-
54
-
55
- break;
56
-
57
- default:
58
-
59
- return $settings;
60
-
61
- break;
62
- }
63
- }
64
-
65
- /**
66
- * Get Saved Option Value
67
- *
68
- * @return array|string
69
- * @author PixelYourSite
70
- **/
71
- function woofp_get_option($name='', $option=''){
72
-
73
- if(empty($name) || empty($option))
74
- return '';
75
-
76
- $settings = woofp_admin_settings();
77
-
78
- if( isset( $settings[$name][$option] ) )
79
- return $settings[$name][$option];
80
- else
81
- return '';
82
- }
83
-
84
- /**
85
- * Current Page Full URL
86
- *
87
- * @return string
88
- * @author PixelYourSite
89
- **/
90
- function woofp_current_url(){
91
-
92
- $current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
93
- $current_url = rtrim($current_url, '/');
94
-
95
- return $current_url;
96
- }
97
-
98
- /**
99
- * Return Javascript Code for facebook standard event
100
- * ( With fallback for No Javascript )
101
- *
102
- * @return array
103
- * @author PixelYourSite
104
- **/
105
- function woofp_page_event(){
106
-
107
- $facebookpixel = woofp_admin_settings('facebookpixel');
108
- $standardevent = woofp_admin_settings('standardevent');
109
- $woocommerce_settings = woofp_admin_settings('woocommerce');
110
-
111
-
112
- $pixelcode = "";
113
-
114
- /* whether facebook pixel is activated */
115
- if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 ){
116
-
117
- $pixel_id = isset($facebookpixel['ID']) ? $facebookpixel['ID'] : '';
118
- $current_url = woofp_current_url();
119
- $event_added = array();
120
-
121
-
122
- $nojs_pixelcode = "";
123
-
124
- $pixelcode .= "\n";
125
- $nojs_pixelcode .= "\n";
126
-
127
-
128
- $pixelcode .= "// Insert Your Facebook Pixel ID below. \n fbq('init', '".$pixel_id."'); \n\n";
129
-
130
- $eventtype = 'PageView';
131
-
132
- $pixelcode .= "//Default Event \n" . woofp_get_event( $eventtype ) . " \n\n";
133
- $nojs_pixelcode .= "<!-- Default Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype ) . " \n\n";
134
- $event_added[] = array( $current_url, $eventtype );
135
-
136
-
137
- /* whether standerd events is activated */
138
- if( isset($standardevent['activate']) && $standardevent['activate'] == 1 ){
139
-
140
-
141
-
142
-
143
- if( isset($standardevent['pageurl']) && !empty( $standardevent['pageurl'] ) ) {
144
-
145
- foreach ( $standardevent['pageurl'] as $key => $link) {
146
-
147
- //if url or event is empty don't go further
148
- if( empty($standardevent['pageurl'][$key]) || empty($standardevent['eventtype'][$key]) )
149
- continue;
150
-
151
- $pageurl = rtrim($standardevent['pageurl'][$key], '/');
152
- $cartvalue = $standardevent['value'][$key];
153
- $currency = $standardevent['currency'][$key];
154
- $eventtype = $standardevent['eventtype'][$key];
155
-
156
-
157
-
158
-
159
-
160
-
161
- //Add pixel event for added url
162
- if( !woofp_is_eventadded( $event_added, $eventtype ) && woofp_match_url($current_url, $pageurl, $eventtype) == 'true' ){
163
- $event_added[] = array($current_url, $eventtype );
164
-
165
-
166
- $pixelcode .= "//Standard Event\n" . woofp_get_event( $eventtype, $cartvalue, $currency, 'standardevent') . " \n\n";
167
- $nojs_pixelcode .= "<!-- Standard Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'standardevent') . " \n\n";
168
-
169
- }
170
-
171
- } /* foreach standardevent['pageurl'] */
172
-
173
- } /* not empty $standardevent['pageurl'] */
174
-
175
-
176
- } /* standerd event activated */
177
-
178
- /* Woocommerce settings */
179
- if( isset($woocommerce_settings['activate']) && $woocommerce_settings['activate'] == 1 && woofp_is_woocommerce() ){
180
-
181
- global $woocommerce;
182
-
183
- $cartvalue = $woocommerce->cart->get_cart_total();
184
- $currency = get_woocommerce_currency();
185
-
186
- $symbol = get_woocommerce_currency_symbol();
187
- $cartvalue = str_replace($symbol, '', $cartvalue);
188
-
189
-
190
- $cartvalue = strip_tags($cartvalue);
191
- $cartvalue = preg_replace("/[^0-9\.]/", "", $cartvalue);
192
-
193
- //Add pixel event for woocommerce pages
194
- foreach (woofp_woocommerce_events() as $key => $woocommerc_event) {
195
-
196
- $eventtype = $woocommerc_event['event'];
197
-
198
- if(
199
- woofp_is_woocommerce_page($woocommerc_event['page'])
200
- && !woofp_is_eventadded( $event_added, $woocommerc_event['event'] )
201
- && woofp_is_woocommerce_event($woocommerc_event['event'], $woocommerce_settings, false)
202
- )
203
- {
204
-
205
-
206
- $event_added[] = array( $current_url, $eventtype );
207
-
208
- $pixelcode .= "//WooCommerce Event\n" . woofp_get_event( $eventtype, $cartvalue, $currency, 'woocommerce') . " \n\n";
209
- $nojs_pixelcode .= "<!-- WooCommerce Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'woocommerce') . " \n\n";
210
-
211
- }
212
-
213
-
214
- } /* foreach woofp_woocommerce_events*/
215
-
216
- } /* Woocommerce Settings */
217
-
218
-
219
-
220
- //Search Page
221
- if( isset($_GET['s']) && $_GET['s'] !='' ){
222
-
223
- $eventtype = 'Search';
224
-
225
- if( !woofp_is_eventadded( $event_added, $eventtype ) ) {
226
- $pixelcode .= "//Default Event \n" . woofp_get_event( $eventtype, 'default') . " \n";
227
- $nojs_pixelcode .= "<!-- Default Event--> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'default') . " \n\n";
228
- $event_added[] = array( $current_url, $eventtype );
229
- }
230
- }
231
-
232
- //registered page
233
- if( isset($_GET['checkemail']) && $_GET['checkemail'] =='registered' ){
234
-
235
- $eventtype = 'CompleteRegistration';
236
- if( !woofp_is_eventadded( $event_added, $eventtype ) ) {
237
- $pixelcode .= "//Default Event \n" . woofp_get_event( $eventtype, 'default') . " \n\n";
238
- $nojs_pixelcode .= "<!-- Default Event--> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'default') . " \n\n";
239
- $event_added[] = array( $current_url, $eventtype );
240
- }
241
- }
242
-
243
-
244
- }/* facebook pixel activated */
245
-
246
- $pixelcode .= "\n";
247
- $nojs_pixelcode .= "\n";
248
-
249
- return array($pixelcode, $nojs_pixelcode);
250
- }
251
-
252
-
253
-
254
- /* Todo Prevent Duplicate Event*/
255
- function woofp_is_eventadded($addedevents, $event){
256
-
257
- return false;
258
-
259
- if(!empty($addedevents)){
260
-
261
- $result = false;
262
- $current_url = woofp_current_url();
263
-
264
-
265
- foreach ($addedevents as $key => $addedevent) {
266
-
267
- if( woofp_match_url($current_url, $addedevent[0]) == 'true' && $event == $addedevent[1] ){
268
-
269
- $result = true;
270
- }
271
- }
272
-
273
- } else {
274
-
275
- $result = false;
276
- }
277
-
278
- return $result;
279
- }
280
-
281
- function woofp_get_event($event='', $value=false, $currency='USD', $type=''){
282
-
283
- if( 'ProductAddToCart' == $event )
284
- $event = 'AddToCart';
285
-
286
- if( 'Purchase' == $event ){
287
-
288
- if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
289
- return "fbq('track', '".$event."', {currency:'".$currency."', value:".$value."});";
290
- else
291
- return "fbq('track', '".$event."', {currency:'USD', value:0.00});";
292
-
293
- } else {
294
-
295
- if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
296
- return "fbq('track', '".$event."', {currency:'".$currency."', value:".$value."});";
297
- else
298
- return "fbq('track', '".$event."');";
299
-
300
- }
301
- }
302
-
303
- function woofp_get_event_noscript($pixel_id, $event, $type=''){
304
-
305
- return "<noscript><img height='1' width='1' style='display:none'
306
- src='https://www.facebook.com/tr?id=".$pixel_id."&ev=".$event."&noscript=1'
307
- /></noscript>";
308
-
309
- }
310
-
311
- function woofp_event_types($current=''){
312
- ?>
313
-
314
- <option <?php echo selected( 'ViewContent', $current, true ); ?> value="ViewContent">ViewContent</option>
315
- <option <?php echo selected( 'Search', $current, true ); ?> value="Search">Search</option>
316
- <option <?php echo selected( 'AddToCart', $current, true ); ?> value="AddToCart">AddToCart</option>
317
- <option <?php echo selected( 'AddToWishlist', $current, true ); ?> value="AddToWishlist">AddToWishlist</option>
318
- <option <?php echo selected( 'InitiateCheckout', $current, true ); ?> value="InitiateCheckout">InitiateCheckout</option>
319
- <option <?php echo selected( 'AddPaymentInfo', $current, true ); ?> value="AddPaymentInfo">AddPaymentInfo</option>
320
- <option <?php echo selected( 'Purchase', $current, true ); ?> value="Purchase">Purchase</option>
321
- <option <?php echo selected( 'Lead', $current, true ); ?> value="Lead">Lead</option>
322
- <option <?php echo selected( 'CompleteRegistration', $current, true ); ?> value="CompleteRegistration">CompleteRegistration</option>
323
-
324
- <?php
325
- }
326
-
327
- function woofp_event_help(){
328
- ?>
329
- <ul class="woofp-event-help">
330
- <li><b>ViewContent:</b> Track key page views (ex: product page, landing page or article)</li>
331
- <li><b>Search:</b> Track searches on your website (ex. product searches)</li>
332
- <li><b>AddToCart:</b> Track when items are added to a shopping cart (ex. click/landing page on Add to Cart button)</li>
333
- <li><b>AddToWishlist:</b> Track when items are added to a wishlist (ex. click/landing page on Add to Wishlist button)</li>
334
- <li><b>InitiateCheckout:</b> Track when people enter the checkout flow (ex. click/landing page on checkout button)</li>
335
- <li><b>AddPaymentInfo:</b> Track when payment information is added in the checkout flow (ex. click/landing page on billing info)</li>
336
- <li><b>Purchase:</b> Track purchases or checkout flow completions (ex. landing on "Thank You" or confirmation page)</li>
337
- <li><b>Lead:</b> Track when a user expresses interest in your offering (ex. form submission, sign up for trial, landing on pricing page)</li>
338
- <li><b>CompleteRegistration:</b> Track when a registration form is completed (ex. complete subscription, sign up for a service)</li>
339
- </ul>
340
- <?php
341
- }
342
-
343
-
344
-
345
- function woofp_currency_options( $current='USD' ){
346
- ?>
347
- <option <?php echo selected( 'AUD', $current, true ); ?> value="AUD">Australian Dollar</option>
348
- <option <?php echo selected( 'BRL', $current, true ); ?> value="BRL">Brazilian Real </option>
349
- <option <?php echo selected( 'CAD', $current, true ); ?> value="CAD">Canadian Dollar</option>
350
- <option <?php echo selected( 'CZK', $current, true ); ?> value="CZK">Czech Koruna</option>
351
- <option <?php echo selected( 'DKK', $current, true ); ?> value="DKK">Danish Krone</option>
352
- <option <?php echo selected( 'EUR', $current, true ); ?> value="EUR">Euro</option>
353
- <option <?php echo selected( 'HKD', $current, true ); ?> value="HKD">Hong Kong Dollar</option>
354
- <option <?php echo selected( 'HUF', $current, true ); ?> value="HUF">Hungarian Forint </option>
355
- <option <?php echo selected( 'ILS', $current, true ); ?> value="ILS">Israeli New Sheqel</option>
356
- <option <?php echo selected( 'JPY', $current, true ); ?> value="JPY">Japanese Yen</option>
357
- <option <?php echo selected( 'MYR', $current, true ); ?> value="MYR">Malaysian Ringgit</option>
358
- <option <?php echo selected( 'MXN', $current, true ); ?> value="MXN">Mexican Peso</option>
359
- <option <?php echo selected( 'NOK', $current, true ); ?> value="NOK">Norwegian Krone</option>
360
- <option <?php echo selected( 'NZD', $current, true ); ?> value="NZD">New Zealand Dollar</option>
361
- <option <?php echo selected( 'PHP', $current, true ); ?> value="PHP">Philippine Peso</option>
362
- <option <?php echo selected( 'PLN', $current, true ); ?> value="PLN">Polish Zloty</option>
363
- <option <?php echo selected( 'GBP', $current, true ); ?> value="GBP">Pound Sterling</option>
364
- <option <?php echo selected( 'SGD', $current, true ); ?> value="SGD">Singapore Dollar</option>
365
- <option <?php echo selected( 'SEK', $current, true ); ?> value="SEK">Swedish Krona</option>
366
- <option <?php echo selected( 'CHF', $current, true ); ?> value="CHF">Swiss Franc</option>
367
- <option <?php echo selected( 'TWD', $current, true ); ?> value="TWD">Taiwan New Dollar</option>
368
- <option <?php echo selected( 'THB', $current, true ); ?> value="THB">Thai Baht</option>
369
- <option <?php echo selected( 'TRY', $current, true ); ?> value="TRY">Turkish Lira</option>
370
- <option <?php echo selected( 'USD', $current, true ); ?> value="USD">U.S. Dollar</option>
371
-
372
- <?php
373
- }
374
-
375
-
376
- function woofp_pixelcode(){
377
-
378
- //load facebook pixel on front only
379
- if( !is_admin() ){
380
-
381
- $facebookpixel = woofp_admin_settings('facebookpixel');
382
-
383
- if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 ) {
384
- ?>
385
-
386
-
387
- <!-- Facebook Pixel Code -->
388
- <script>
389
- var PYS_DOMReady = function(a,b,c){b=document,c='addEventListener';b[c]?b[c]('DOMContentLoaded',a):window.attachEvent('onload',a)}
390
- !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
391
- n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
392
- n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
393
- t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
394
- document,'script','//connect.facebook.net/en_US/fbevents.js');
395
-
396
- /* pixel plugin code */
397
- PYS_DOMReady(function(){
398
-
399
- <?php
400
- $facebookpixel_code = woofp_page_event();
401
- echo $facebookpixel_code[0];
402
- ?>
403
-
404
- });
405
- /* pixel plugin code */
406
-
407
- </script>
408
-
409
- <!-- End Facebook Pixel Code -->
410
-
411
- <?php
412
- }
413
-
414
- } else {
415
- ?>
416
- <img src="<?php echo admin_url('admin-ajax.php'); ?>" style="display:none;">
417
-
418
- <?php
419
- }
420
-
421
-
422
-
423
- }
424
-
425
-
426
- /*
427
- Woocommerce Related Functions
428
- Check if woocommerce is install and activated.
429
- */
430
-
431
- function woofp_addtocart_urls($woofp_options=''){
432
-
433
-
434
- $facebookpixel = $woofp_options['facebookpixel'];
435
- $standardevent = $woofp_options['standardevent'];
436
- $woocommerce_settings = $woofp_options['woocommerce'];
437
-
438
-
439
-
440
- /* whether facebook pixel is activated */
441
- if( woofp_get_option('facebookpixel', 'activate') == 1 ){
442
-
443
- /* whether standerd events is activated */
444
- if( woofp_get_option('standardevent', 'activate') == 1 ){
445
-
446
-
447
-
448
- $results = array();
449
- if( isset( $standardevent['pageurl'] ) && !empty($standardevent['pageurl']) ){
450
-
451
- foreach ( $standardevent['pageurl'] as $key => $link) {
452
-
453
- $pageurl = rtrim($standardevent['pageurl'][$key], '/');
454
- $cartvalue = $standardevent['value'][$key];
455
- $currency = $standardevent['currency'][$key];
456
- $eventtype = $standardevent['eventtype'][$key];
457
-
458
- if( !in_array($pageurl, $results) && $eventtype == 'AddToCart' )
459
- $results[] = $pageurl;
460
-
461
-
462
- }
463
-
464
- }
465
-
466
- if( woofp_get_option('woocommerce', 'activate') == 1 ){
467
-
468
- //Add pixel event for woocommerce pages
469
- foreach (woofp_woocommerce_events() as $key => $woocommerc_event) {
470
-
471
- $eventtype = $woocommerc_event['event'];
472
- if( !in_array( '***', $results) && woofp_is_woocommerce_event($eventtype, $woocommerce_settings, false) && $eventtype == 'AddToCart' )
473
- $results[] = '***';
474
- }
475
-
476
- }
477
-
478
- }
479
-
480
- }
481
-
482
-
483
- return $results;
484
-
485
- }
486
-
487
-
488
- function woofp_addtocart_pixel(){
489
-
490
-
491
- //
492
-
493
- ?>
494
-
495
- <!-- noscript facebook pixel -->
496
-
497
- <?php
498
- $facebookpixel_code = woofp_page_event();
499
- echo $facebookpixel_code[1];
500
- ?>
501
-
502
- <!-- end noscript facebook pixel -->
503
-
504
- <?php
505
- //Run AddToCart Event when product are added using ajax
506
- //todo: woocommerce_cart_redirect_after_add
507
-
508
- $woofp_options = get_option('woofp_admin_settings');
509
- $facebookpixel = $woofp_options['facebookpixel'];
510
- $standardevent = $woofp_options['standardevent'];
511
- $woocommerce_settings = $woofp_options['woocommerce'];
512
-
513
-
514
-
515
- ?>
516
- <!-- Dynamic AddToCart when Ajax enabled on Woocommerce -->
517
- <?php
518
-
519
- if ( get_option( 'woocommerce_enable_ajax_add_to_cart' ) == 'yes' && ( is_woocommerce() || is_page() || is_single() ) ) {
520
-
521
- $php_array = woofp_addtocart_urls($woofp_options);
522
- $js_array = json_encode($php_array);
523
- ?>
524
-
525
-
526
- <script type="text/javascript">
527
- var fbpmpaddtocart_eventcode = '';
528
-
529
- jQuery(function($){
530
-
531
- /*$.ajax({
532
- url: '<?php echo admin_url("admin-ajax.php"); ?>',
533
- type: 'POST',
534
- dataType: 'json',
535
- data: {action: 'fbpmpaddtocart', nonce:'<?php echo wp_create_nonce("fbpmp_nonce_ajaxaddtocart"); ?>'},
536
- })
537
- .done(function(result){
538
-
539
- if( 1 == result.status ){
540
- fbpmpaddtocart_eventcode = result.event_code;
541
- }
542
- console.log(result);
543
- console.log(fbpmpaddtocart_eventcode);
544
-
545
- });*/
546
-
547
- //Run AddToCart Event when product are added using ajax
548
- jQuery(document).on( 'click', '.add_to_cart_button', function(e) {
549
-
550
- e.preventDefault();
551
-
552
- var current_url = jQuery(this).attr('href') || '';
553
- var product_id = jQuery(this).attr('data-product_id') || 0;
554
-
555
- <?php echo "var url_array = ". $js_array . ";\n"; ?>
556
- <?php echo "var homeurl = '". home_url() . "';\n"; ?>
557
-
558
- if (current_url.indexOf('http://') < 0 || current_url.indexOf('https://') < 0){
559
- current_url = homeurl + current_url;
560
- }
561
-
562
-
563
-
564
- for (i = 0; i < url_array.length; i++) {
565
-
566
- if( url_array[i] == '***' ){
567
-
568
-
569
- fbq('track', 'AddToCart');
570
-
571
- } else if( current_url.search(url_array[i]) !== -1 ){
572
-
573
-
574
- fbq('track', 'AddToCart');
575
-
576
- }
577
-
578
- }
579
-
580
-
581
- });
582
-
583
- });
584
- </script>
585
- <?php }
586
- }
587
-
588
-
589
-
590
- function woofp_is_woocommerce_page ($page) {
591
-
592
- switch ($page) {
593
-
594
- case 'woocommerce_view_content':
595
-
596
- return is_product();
597
-
598
- case 'woocommerce_added_to_cart':
599
-
600
- if ( isset($_REQUEST['add-to-cart']) && is_numeric($_REQUEST['add-to-cart']) )
601
- return true;
602
- else
603
- return false;
604
-
605
-
606
- break;
607
-
608
-
609
- case 'woocommerce_cart_page_id':
610
-
611
- return is_cart();
612
-
613
- break;
614
-
615
- case 'woocommerce_checkout_page_id':
616
-
617
- if( is_checkout() && !is_wc_endpoint_url() )
618
- return true;
619
- else
620
- return false;
621
-
622
- break;
623
-
624
- case 'woocommerce_thanks_page_id':
625
-
626
- if( is_wc_endpoint_url( 'order-received' ) )
627
- return true;
628
- else
629
- return false;
630
-
631
-
632
- break;
633
-
634
- case 'woocommerce_search_product':
635
-
636
- if ( isset($_GET['s']) && ( isset($_GET['post_type']) && $_GET['post_type'] == 'product' ) ) {
637
-
638
- return true ;
639
-
640
- } else {
641
-
642
- return false;
643
- }
644
-
645
- break;
646
-
647
- default:
648
- return false;
649
- break;
650
- }
651
-
652
- }
653
-
654
-
655
- /**
656
- * Return appropriate pixel events for woocommerce pages
657
- *
658
- * @return array
659
- * @author PixelYourSite
660
- **/
661
- function woofp_woocommerce_events(){
662
-
663
- $woocommerce_events = array(
664
-
665
- array(
666
- 'event' => 'ViewContent',
667
- 'page' => 'woocommerce_view_content',
668
- 'title' => 'Any WooCommerce Page',
669
- 'label' => 'ViewContent Event'
670
- ),
671
-
672
- array(
673
- 'event' => 'ProductAddToCart',
674
- 'page' => 'woocommerce_added_to_cart',
675
- 'title' => 'Product Added to Cart',
676
- 'label' => 'AddToCart Event'
677
- ),
678
-
679
- array(
680
- 'event' => 'AddToCart',
681
- 'page' => 'woocommerce_cart_page_id',
682
- 'title' => 'AddToCart Page',
683
- 'label' => 'AddToCart Event'
684
- ),
685
- array(
686
- 'event' => 'InitiateCheckout',
687
- 'page' => 'woocommerce_checkout_page_id',
688
- 'title' => 'CheckOut Page',
689
- 'label' => 'InitiateCheckout Event'
690
- ),
691
- /*array(
692
- 'event' => 'AddPaymentInfo',
693
- 'page' => 'woocommerce_checkout_page_id',
694
- 'title' => 'Checkout Page',
695
- 'label' => 'AddPaymentInfo Event'
696
- ),*/
697
- array(
698
- 'event' => 'Purchase',
699
- 'page' => 'woocommerce_thanks_page_id',
700
- 'title' => 'Thankyou Page',
701
- 'label' => 'Purchase Event'
702
- ),
703
- /*array(
704
- 'event' => 'Search',
705
- 'page' => 'woocommerce_search_product',
706
- 'title' => 'Product Search',
707
- 'label' => ' Search Event'
708
- ),*/
709
-
710
- );
711
-
712
- return $woocommerce_events;
713
- }
714
-
715
- /**
716
- * Check if woocommerce event is activated in settings
717
- * @return string | true/false
718
- * @author PixelYourSite
719
- **/
720
- function woofp_is_woocommerce_event($event, $settings, $echo=true){
721
-
722
-
723
- if( isset( $settings['events'] ) && !empty($settings['events']) && isset($settings['events'][$event]) && $settings['events'][$event] == 1 ){
724
- $checked = 'checked="checked"';
725
- $return = true;
726
- } else {
727
-
728
- $checked = '';
729
- $return = false;
730
- }
731
-
732
- if($echo){
733
- echo $checked;
734
- } else {
735
-
736
- return $return;
737
- }
738
- }
739
-
740
- function woofp_startsWith($haystack, $needle) {
741
- // search backwards starting from haystack length characters from the end
742
- return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
743
- }
744
-
745
- function woofp_endsWith($haystack, $needle) {
746
- // search forward starting from end minus needle length characters
747
- return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
748
- }
749
-
750
-
751
- function woofp_valid_url($value){
752
- $pattern = "@^(?:https?://)?(?:[a-z0-9-]+\.)*((?:[a-z0-9-]+\.)[a-z]+)@";
753
-
754
- if (!preg_match($pattern, $value)){
755
- return false;
756
- }
757
-
758
- return true;
759
- }
760
-
761
- /**
762
- * add http:// to url if missing
763
- *
764
- * @return string
765
- * @author PixelYourSite
766
- **/
767
- function woofp_addhttp($url=''){
768
-
769
- if (preg_match("#https?://#", $url) === 0) {
770
- $url = 'http://'.$url;
771
- }
772
-
773
- return $url;
774
- }
775
-
776
-
777
- /**
778
- * Remove http(s)/www. from url
779
- *
780
- * @return string
781
- * @author PixelYourSite
782
- **/
783
- function woofp_remove_protocol($url=''){
784
-
785
- if(empty($url) && !woofp_valid_url($url))
786
- return $url;
787
-
788
- $url = str_replace(array('http://', 'https://', 'http://www.', 'https://www.'), '', $url);
789
-
790
- $url = trim($url);
791
- $url = trim($url, '//');
792
- $url = rtrim($url, '/');
793
-
794
- return $url;
795
- }
796
-
797
-
798
- function woofp_match_url($current_url, $match_url, $eventtype='' ){
799
-
800
- $current_url = woofp_remove_protocol($current_url);
801
- $match_url = woofp_remove_protocol($match_url);
802
-
803
- if(strpos($match_url, '*') !== false && woofp_endsWith($match_url, '*') ){
804
-
805
- $temp_url = $match_url;
806
- $temp_url = rtrim($temp_url, '*');
807
-
808
- $temp_url = trim($temp_url);
809
- $temp_url = trim($temp_url, '//');
810
- $temp_url = rtrim($temp_url, '/');
811
-
812
-
813
-
814
- if ( woofp_valid_url($temp_url) === true) {
815
-
816
- $current_postid = url_to_postid( woofp_addhttp($current_url) );
817
- $match_postid = url_to_postid( woofp_addhttp($temp_url) );
818
- $current_length = strlen($current_url);
819
- $match_length = strlen($temp_url);
820
-
821
- $postmatch = false;
822
-
823
- if( $current_postid && $match_postid && $current_postid == $match_postid ){
824
- $postmatch = true;
825
- }
826
-
827
-
828
- $strcmp1 = strcmp($temp_url, $current_url);
829
- $strcmp2 = strcmp($current_url, $temp_url);
830
-
831
- $found1 = ( (strpos($temp_url, $current_url) !== false ) ? 'true' : 'false' );
832
- $found2 = ( (strpos($current_url, $temp_url) !== false ) ? 'true' : 'false' );
833
-
834
- if( $match_length > $current_length && $found1 == 'true' ){
835
-
836
- $ret = ( ( $strcmp1 < 0 || $postmatch ) ? 'true' : 'false' );
837
-
838
- } else if( $match_length < $current_length && $found2 == 'true' ){
839
-
840
- $ret = ( ( $strcmp2 > 0 || $postmatch ) ? 'true' : 'false' );
841
-
842
- } else {
843
-
844
- $ret = ( ( $strcmp1 == 0 || $postmatch ) ? 'true' : 'false' );
845
-
846
- }
847
-
848
-
849
- return $ret;
850
-
851
- } else {
852
-
853
-
854
- return 'false';
855
- }
856
-
857
- } else {
858
-
859
-
860
- if ( woofp_valid_url($match_url) === true ) {
861
-
862
- $current_postid = url_to_postid( woofp_addhttp($current_url) );
863
- $match_postid = url_to_postid( woofp_addhttp($match_url) );
864
-
865
- $postmatch = false;
866
- if( $current_postid && $match_postid && $current_postid == $match_postid ){
867
- $postmatch = true;
868
- }
869
-
870
- $strcmp = strcmp( $current_url, $match_url );
871
- $ret = ( ( $strcmp == 0 || $postmatch ) ? 'true' : 'false' );
872
-
873
-
874
- return $ret;
875
-
876
- } else {
877
-
878
- $strpos = strpos($current_url, $match_url);
879
- $ret = ( $strpos !== false ? 'true' : 'false' );
880
-
881
-
882
- return $ret;
883
-
884
- }
885
-
886
- }
887
- }
888
-
889
- function woofp_is_woocommerce(){
890
-
891
- if ( !class_exists( 'WooCommerce' ) ) {
892
-
893
- return false;
894
-
895
- } else {
896
-
897
-
898
- return true;
899
- }
900
-
901
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/helper-functions.php DELETED
@@ -1,1232 +0,0 @@
1
- <?php
2
- /**
3
- * Get Admin Settings
4
- *
5
- * @return array
6
- * @author PixelYourSite
7
- **/
8
- function woofp_admin_settings($option_name='all'){
9
-
10
-
11
- $settings = get_option('woofp_admin_settings');
12
-
13
- if(empty($settings)) {
14
-
15
- $settings = array();
16
-
17
- } else {
18
-
19
- $options = array('facebookpixel', 'standardevent', 'woocommerce');
20
- foreach ( $options as $key => $name ) {
21
-
22
- if( !isset( $settings[$name]) || empty( $settings[$name] ) ){
23
-
24
- $settings[$name] = array();
25
- }
26
- }
27
- }
28
-
29
-
30
- switch ($option_name) {
31
- case 'all':
32
-
33
- return $settings;
34
-
35
- break;
36
-
37
- case 'facebookpixel':
38
-
39
- return ( isset($settings['facebookpixel']) ? $settings['facebookpixel'] : '' );
40
-
41
- break;
42
-
43
- case 'standardevent':
44
-
45
- return ( isset($settings['standardevent']) ? $settings['standardevent'] : '' );
46
-
47
-
48
- break;
49
-
50
- case 'woocommerce':
51
-
52
- return ( isset($settings['woocommerce']) ? $settings['woocommerce'] : '' );
53
-
54
-
55
- break;
56
-
57
- default:
58
-
59
- return $settings;
60
-
61
- break;
62
- }
63
- }
64
-
65
- /**
66
- * Get Saved Option Value
67
- *
68
- * @return array|string
69
- * @author PixelYourSite
70
- **/
71
- function woofp_get_option($name='', $option=''){
72
-
73
- if(empty($name) || empty($option))
74
- return '';
75
-
76
- $settings = woofp_admin_settings();
77
-
78
- if( isset( $settings[$name][$option] ) )
79
- return $settings[$name][$option];
80
- else
81
- return '';
82
- }
83
-
84
- /**
85
- * Current Page Full URL
86
- *
87
- * @return string
88
- * @author PixelYourSite
89
- **/
90
- function woofp_current_url(){
91
-
92
- $current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
93
- $current_url = rtrim($current_url, '/');
94
-
95
- return $current_url;
96
- }
97
-
98
-
99
- /**
100
- * Clean string to be UTF-8
101
- *
102
- * @return string
103
- * @author PixelYourSite
104
- **/
105
-
106
- function woofp_clean_param_value($value){
107
-
108
-
109
- $replace = array(
110
- '&lt;' => '', '&gt;' => '', '&#039;' => '', '&amp;' => '',
111
- '&quot;' => '', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'Ae',
112
- '&Auml;' => 'A', 'Å' => 'A', 'Ā' => 'A', 'Ą' => 'A', 'Ă' => 'A', 'Æ' => 'Ae',
113
- 'Ç' => 'C', 'Ć' => 'C', 'Č' => 'C', 'Ĉ' => 'C', 'Ċ' => 'C', 'Ď' => 'D', 'Đ' => 'D',
114
- 'Ð' => 'D', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ē' => 'E',
115
- 'Ę' => 'E', 'Ě' => 'E', 'Ĕ' => 'E', 'Ė' => 'E', 'Ĝ' => 'G', 'Ğ' => 'G',
116
- 'Ġ' => 'G', 'Ģ' => 'G', 'Ĥ' => 'H', 'Ħ' => 'H', 'Ì' => 'I', 'Í' => 'I',
117
- 'Î' => 'I', 'Ï' => 'I', 'Ī' => 'I', 'Ĩ' => 'I', 'Ĭ' => 'I', 'Į' => 'I',
118
- 'İ' => 'I', 'IJ' => 'IJ', 'Ĵ' => 'J', 'Ķ' => 'K', 'Ł' => 'K', 'Ľ' => 'K',
119
- 'Ĺ' => 'K', 'Ļ' => 'K', 'Ŀ' => 'K', 'Ñ' => 'N', 'Ń' => 'N', 'Ň' => 'N',
120
- 'Ņ' => 'N', 'Ŋ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O',
121
- 'Ö' => 'Oe', '&Ouml;' => 'Oe', 'Ø' => 'O', 'Ō' => 'O', 'Ő' => 'O', 'Ŏ' => 'O',
122
- 'Œ' => 'OE', 'Ŕ' => 'R', 'Ř' => 'R', 'Ŗ' => 'R', 'Ś' => 'S', 'Š' => 'S',
123
- 'Ş' => 'S', 'Ŝ' => 'S', 'Ș' => 'S', 'Ť' => 'T', 'Ţ' => 'T', 'Ŧ' => 'T',
124
- 'Ț' => 'T', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'Ue', 'Ū' => 'U',
125
- '&Uuml;' => 'Ue', 'Ů' => 'U', 'Ű' => 'U', 'Ŭ' => 'U', 'Ũ' => 'U', 'Ų' => 'U',
126
- 'Ŵ' => 'W', 'Ý' => 'Y', 'Ŷ' => 'Y', 'Ÿ' => 'Y', 'Ź' => 'Z', 'Ž' => 'Z',
127
- 'Ż' => 'Z', 'Þ' => 'T', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a',
128
- 'ä' => 'ae', '&auml;' => 'ae', 'å' => 'a', 'ā' => 'a', 'ą' => 'a', 'ă' => 'a',
129
- 'æ' => 'ae', 'ç' => 'c', 'ć' => 'c', 'č' => 'c', 'ĉ' => 'c', 'ċ' => 'c',
130
- 'ď' => 'd', 'đ' => 'd', 'ð' => 'd', 'è' => 'e', 'é' => 'e', 'ê' => 'e',
131
- 'ë' => 'e', 'ē' => 'e', 'ę' => 'e', 'ě' => 'e', 'ĕ' => 'e', 'ė' => 'e',
132
- 'ƒ' => 'f', 'ĝ' => 'g', 'ğ' => 'g', 'ġ' => 'g', 'ģ' => 'g', 'ĥ' => 'h',
133
- 'ħ' => 'h', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ī' => 'i',
134
- 'ĩ' => 'i', 'ĭ' => 'i', 'į' => 'i', 'ı' => 'i', 'ij' => 'ij', 'ĵ' => 'j',
135
- 'ķ' => 'k', 'ĸ' => 'k', 'ł' => 'l', 'ľ' => 'l', 'ĺ' => 'l', 'ļ' => 'l',
136
- 'ŀ' => 'l', 'ñ' => 'n', 'ń' => 'n', 'ň' => 'n', 'ņ' => 'n', 'ʼn' => 'n',
137
- 'ŋ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'oe',
138
- '&ouml;' => 'oe', 'ø' => 'o', 'ō' => 'o', 'ő' => 'o', 'ŏ' => 'o', 'œ' => 'oe',
139
- 'ŕ' => 'r', 'ř' => 'r', 'ŗ' => 'r', 'š' => 's', 'ù' => 'u', 'ú' => 'u',
140
- 'û' => 'u', 'ü' => 'ue', 'ū' => 'u', '&uuml;' => 'ue', 'ů' => 'u', 'ű' => 'u',
141
- 'ŭ' => 'u', 'ũ' => 'u', 'ų' => 'u', 'ŵ' => 'w', 'ý' => 'y', 'ÿ' => 'y',
142
- 'ŷ' => 'y', 'ž' => 'z', 'ż' => 'z', 'ź' => 'z', 'þ' => 't', 'ß' => 'ss',
143
- 'ſ' => 'ss', 'ый' => 'iy', 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G',
144
- 'Д' => 'D', 'Е' => 'E', 'Ё' => 'YO', 'Ж' => 'ZH', 'З' => 'Z', 'И' => 'I',
145
- 'Й' => 'Y', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O',
146
- 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F',
147
- 'Х' => 'H', 'Ц' => 'C', 'Ч' => 'CH', 'Ш' => 'SH', 'Щ' => 'SCH', 'Ъ' => '',
148
- 'Ы' => 'Y', 'Ь' => '', 'Э' => 'E', 'Ю' => 'YU', 'Я' => 'YA', 'а' => 'a',
149
- 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'yo',
150
- 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'y', 'к' => 'k', 'л' => 'l',
151
- 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's',
152
- 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch',
153
- 'ш' => 'sh', 'щ' => 'sch', 'ъ' => '', 'ы' => 'y', 'ь' => '', 'э' => 'e',
154
- 'ю' => 'yu', 'я' => 'ya'
155
- );
156
- $value = str_replace(array_keys($replace), $replace, $value);
157
-
158
- $value = preg_replace("/[^a-zA-Z0-9\s>]/", ' ', $value);
159
- $value = preg_replace("/ {2,}/", " ", $value);
160
-
161
- return $value;
162
-
163
-
164
- }
165
-
166
- /**
167
- * Return Javascript Code for facebook standard event
168
- * ( With fallback for No Javascript )
169
- *
170
- * @return array
171
- * @author PixelYourSite
172
- **/
173
- function woofp_page_event(){
174
-
175
- $facebookpixel = woofp_admin_settings('facebookpixel');
176
- $standardevent = woofp_admin_settings('standardevent');
177
- $woocommerce_settings = woofp_admin_settings('woocommerce');
178
- $pixel_id = isset($facebookpixel['ID']) ? $facebookpixel['ID'] : '';
179
-
180
- $pixelcode = "";
181
- $nojs_pixelcode = "";
182
-
183
- /* whether facebook pixel is activated */
184
- if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 && '' != $pixel_id ){
185
-
186
-
187
- $current_url = woofp_current_url();
188
- $event_added = array();
189
-
190
-
191
-
192
-
193
- $pixelcode .= "\n";
194
- $nojs_pixelcode .= "\n";
195
-
196
-
197
- $pixelcode .= "// Insert Your Facebook Pixel ID below. \n fbq('init', '".$pixel_id."'); \n\n";
198
-
199
- $eventtype = 'PageView';
200
-
201
- $pixelcode .= "//Default Event \n" . woofp_get_event( $eventtype ) . " \n\n";
202
- $nojs_pixelcode .= "<!-- Default Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype ) . " \n\n";
203
- $event_added[] = array( $current_url, $eventtype );
204
-
205
-
206
- /* whether standerd events is activated */
207
- if( isset($standardevent['activate']) && $standardevent['activate'] == 1 ){
208
-
209
-
210
-
211
-
212
- if( isset($standardevent['pageurl']) && !empty( $standardevent['pageurl'] ) ) {
213
-
214
- foreach ( $standardevent['pageurl'] as $key => $link) {
215
-
216
- $textarea_code = isset( $standardevent['code'][$key] ) ? $standardevent['code'][$key] : '';
217
- $textarea_code = stripslashes($textarea_code);
218
- $textarea_code = trim($textarea_code);
219
-
220
-
221
- $check_event_type = false;
222
- if( empty($textarea_code) && empty($standardevent['eventtype'][$key]) ){
223
- $check_event_type = true;
224
- }
225
-
226
-
227
- $pageurl = isset( $standardevent['pageurl'][$key] ) ? $standardevent['pageurl'][$key] : '';
228
- $pageurl = rtrim($pageurl, '/');
229
- $pageurl = trim($pageurl);
230
-
231
-
232
- //if url or event is empty don't go further
233
- if( empty($pageurl) || $check_event_type )
234
- continue;
235
-
236
-
237
- $cartvalue = isset( $standardevent['value'][$key] ) ? $standardevent['value'][$key] : '';
238
- $currency = isset( $standardevent['currency'][$key] ) ? $standardevent['currency'][$key] : '';
239
- $eventtype = isset( $standardevent['eventtype'][$key] ) ? $standardevent['eventtype'][$key] : '';
240
-
241
-
242
- $events_params['value'] = $cartvalue;
243
- $events_params['currency'] = $currency;
244
-
245
- $standardevent_params = woofp_standardevent_extented($eventtype);
246
- foreach ($standardevent_params as $k => $param) {
247
- $parame_name = $param['name'];
248
- $events_params[$parame_name] = ( isset( $standardevent[$parame_name][$key] ) ? $standardevent[$parame_name][$key] : '' );
249
- $events_params[$parame_name] = stripslashes($events_params[$parame_name]);
250
- }
251
-
252
-
253
- //Add pixel event for added url
254
- if( !woofp_is_eventadded( $event_added, $eventtype ) && woofp_match_url($current_url, $pageurl, $eventtype) == 'true' ){
255
-
256
- $event_added[] = array($current_url, $eventtype );
257
-
258
- if( !empty( $textarea_code ) ){
259
-
260
- $pixelcode .= "//Standard Event\n" . $textarea_code . " \n\n";
261
-
262
- } else {
263
-
264
- $pixelcode .= "//Standard Event\n" . woofp_get_event( $eventtype, $cartvalue, $currency, 'standardevent', $events_params) . " \n\n";
265
-
266
- }
267
-
268
- $nojs_pixelcode .= "<!-- Standard Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'standardevent') . " \n\n";
269
-
270
- }
271
-
272
- } /* foreach standardevent['pageurl'] */
273
-
274
- } /* not empty $standardevent['pageurl'] */
275
-
276
-
277
- } /* standerd event activated */
278
-
279
- /* Woocommerce settings */
280
- if( isset($woocommerce_settings['activate']) && $woocommerce_settings['activate'] == 1 && woofp_is_woocommerce() ){
281
-
282
- global $woocommerce;
283
-
284
- $cartvalue = $woocommerce->cart->get_cart_total();
285
- $currency = get_woocommerce_currency();
286
-
287
- $symbol = get_woocommerce_currency_symbol();
288
- $cartvalue = str_replace($symbol, '', $cartvalue);
289
-
290
-
291
- $cartvalue = strip_tags($cartvalue);
292
- $cartvalue = preg_replace("/[^0-9\.]/", "", $cartvalue);
293
-
294
- //Add pixel event for woocommerce pages
295
- foreach (woofp_woocommerce_events() as $key => $woocommerc_event) {
296
-
297
- $eventtype = $woocommerc_event['event'];
298
-
299
- if(
300
- woofp_is_woocommerce_page($woocommerc_event['page'])
301
- && !woofp_is_eventadded( $event_added, $woocommerc_event['event'] )
302
- && woofp_is_woocommerce_event($woocommerc_event['event'], $woocommerce_settings, false)
303
- )
304
- {
305
-
306
-
307
- $event_added[] = array( $current_url, $eventtype );
308
-
309
- $pixelcode .= "//WooCommerce Event\n" . woofp_get_event( $eventtype, $cartvalue, $currency, 'woocommerce') . " \n\n";
310
- $nojs_pixelcode .= "<!-- WooCommerce Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'woocommerce') . " \n\n";
311
-
312
- }
313
-
314
-
315
- } /* foreach woofp_woocommerce_events*/
316
-
317
- } /* Woocommerce Settings */
318
-
319
-
320
-
321
- //Search Page
322
- if( isset($_GET['s']) && $_GET['s'] !='' ){
323
-
324
- $eventtype = 'Search';
325
-
326
- if( !woofp_is_eventadded( $event_added, $eventtype ) ) {
327
- $pixelcode .= "//Default Event \n" . woofp_get_event( $eventtype, 'default') . " \n";
328
- $nojs_pixelcode .= "<!-- Default Event--> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'default') . " \n\n";
329
- $event_added[] = array( $current_url, $eventtype );
330
- }
331
- }
332
-
333
- //registered page
334
- if( isset($_GET['checkemail']) && $_GET['checkemail'] =='registered' ){
335
-
336
- $eventtype = 'CompleteRegistration';
337
- if( !woofp_is_eventadded( $event_added, $eventtype ) ) {
338
- $pixelcode .= "//Default Event \n" . woofp_get_event( $eventtype, 'default') . " \n\n";
339
- $nojs_pixelcode .= "<!-- Default Event--> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'default') . " \n\n";
340
- $event_added[] = array( $current_url, $eventtype );
341
- }
342
- }
343
-
344
-
345
- }/* facebook pixel activated */
346
-
347
-
348
- return array($pixelcode, $nojs_pixelcode);
349
- }
350
-
351
-
352
-
353
- /* Todo Prevent Duplicate Event*/
354
- function woofp_is_eventadded($addedevents, $event){
355
-
356
- return false;
357
-
358
- if(!empty($addedevents)){
359
-
360
- $result = false;
361
- $current_url = woofp_current_url();
362
-
363
-
364
- foreach ($addedevents as $key => $addedevent) {
365
-
366
- if( woofp_match_url($current_url, $addedevent[0]) == 'true' && $event == $addedevent[1] ){
367
-
368
- $result = true;
369
- }
370
- }
371
-
372
- } else {
373
-
374
- $result = false;
375
- }
376
-
377
- return $result;
378
- }
379
-
380
- function woofp_get_event($event='', $value=false, $currency='USD', $type='', $events_params=''){
381
-
382
- if( 'ProductAddToCart' == $event )
383
- $event = 'AddToCart';
384
-
385
- if( $event == 'AddToCart' && woofp_get_option('woocommerce', 'activate') != 1 ){
386
-
387
- return "/* Please activate WooCommerce to use AddToCart event. */";
388
- }
389
-
390
- if( 'Purchase' == $event ){
391
-
392
- if( $type == 'standardevent' )
393
- return woofp_standardevent_code($event, $events_params);
394
- else
395
- return "fbq('track', '".$event."', {currency:'USD', value:0.00});";
396
-
397
- } if( 'Search' == $event && 'default' == $type ){
398
-
399
- return "fbq('track', '".$event."', {search_string:'".woofp_clean_param_value($_REQUEST['s'])."'});";
400
-
401
- } else {
402
-
403
- if( $type == 'standardevent' ){
404
-
405
- return woofp_standardevent_code($event, $events_params);
406
- } else{
407
- return "fbq('track', '".$event."');";
408
- }
409
-
410
- }
411
- }
412
-
413
-
414
- function woofp_standardevent_code($event, $args){
415
-
416
- $event_code = '';
417
-
418
-
419
- $args = woofp_filter_standardevent_args($event, $args);
420
-
421
- if( is_array($args) && !empty($args) ){
422
-
423
- $event_code = '';
424
- $event_code .= "fbq('track', '".$event."'";
425
- $event_code .= ", { ";
426
-
427
-
428
- if( isset($args['content_name']) && '' != $args['content_name'] ){
429
- $event_code .= "content_name: '".woofp_clean_param_value($args['content_name'])."'";
430
- $event_code .= ", ";
431
- }
432
-
433
- if( isset($args['content_category']) && '' != $args['content_category'] ){
434
- $event_code .="content_category: '".woofp_clean_param_value($args['content_category'])."'";
435
- $event_code .=", ";
436
- }
437
-
438
- if( isset($args['content_ids']) && '' != $args['content_ids'] ){
439
-
440
-
441
- if( strpos($args['content_ids'], '[') !== false ){
442
- $event_code .="content_ids: ".$args['content_ids']."";
443
- } else {
444
- $event_code .="content_ids: '".$args['content_ids']."'";
445
- }
446
-
447
- $event_code .=", ";
448
- }
449
-
450
- if( isset($args['content_type']) && '' != $args['content_type'] ){
451
- $event_code .="content_type: '".$args['content_type']."'";
452
- $event_code .=", ";
453
- }
454
-
455
- if( isset($args['num_items']) && '' != $args['num_items'] ){
456
- $event_code .="num_items: ".$args['num_items']."";
457
- $event_code .=", ";
458
- }
459
-
460
- if( isset($args['order_id']) && '' != $args['order_id'] ){
461
- $event_code .="order_id: ".$args['order_id']."";
462
- $event_code .=", ";
463
- }
464
-
465
- if( isset($args['search_string']) && '' != $args['search_string'] ){
466
- $event_code .="search_string: '".woofp_clean_param_value($args['search_string'])."'";
467
- $event_code .=", ";
468
- }
469
-
470
- if( isset($args['status']) && '' != $args['status'] ){
471
- $event_code .="status: '".woofp_clean_param_value($args['status'])."'";
472
- $event_code .=", ";
473
- }
474
-
475
- if( isset($args['value']) && '' != $args['value'] ){
476
- $event_code .= "value: ".$args['value']."";
477
- $event_code .=", ";
478
- }
479
-
480
- if( isset($args['currency']) && '' != $args['currency'] ){
481
- $event_code .="currency: '".$args['currency']."' ";
482
- }
483
-
484
- $event_code .= " }";
485
- $event_code .= " );";
486
-
487
- }
488
-
489
- return $event_code;
490
-
491
-
492
- }
493
-
494
- function woofp_get_event_noscript($pixel_id, $event, $type=''){
495
-
496
- return "<noscript><img height='1' width='1' style='display:none'
497
- src='https://www.facebook.com/tr?id=".$pixel_id."&ev=".$event."&noscript=1'
498
- /></noscript>";
499
-
500
- }
501
-
502
- function woofp_event_types($current=''){
503
- ?>
504
-
505
- <option <?php echo selected( 'ViewContent', $current, true ); ?> value="ViewContent">ViewContent</option>
506
- <option <?php echo selected( 'Search', $current, true ); ?> value="Search">Search</option>
507
- <option <?php echo selected( 'AddToCart', $current, true ); ?> value="AddToCart">AddToCart</option>
508
- <option <?php echo selected( 'AddToWishlist', $current, true ); ?> value="AddToWishlist">AddToWishlist</option>
509
- <option <?php echo selected( 'InitiateCheckout', $current, true ); ?> value="InitiateCheckout">InitiateCheckout</option>
510
- <option <?php echo selected( 'AddPaymentInfo', $current, true ); ?> value="AddPaymentInfo">AddPaymentInfo</option>
511
- <option <?php echo selected( 'Purchase', $current, true ); ?> value="Purchase">Purchase</option>
512
- <option <?php echo selected( 'Lead', $current, true ); ?> value="Lead">Lead</option>
513
- <option <?php echo selected( 'CompleteRegistration', $current, true ); ?> value="CompleteRegistration">CompleteRegistration</option>
514
-
515
- <?php
516
- }
517
-
518
- function woofp_event_help(){
519
- ?>
520
- <ul class="woofp-event-help">
521
- <li><b>ViewContent:</b> Track key page views (ex: product page, landing page or article)</li>
522
- <li><b>Search:</b> Track searches on your website (ex. product searches)</li>
523
- <li><b>AddToCart:</b> Track when items are added to a shopping cart (ex. click/landing page on Add to Cart button)</li>
524
- <li><b>AddToWishlist:</b> Track when items are added to a wishlist (ex. click/landing page on Add to Wishlist button)</li>
525
- <li><b>InitiateCheckout:</b> Track when people enter the checkout flow (ex. click/landing page on checkout button)</li>
526
- <li><b>AddPaymentInfo:</b> Track when payment information is added in the checkout flow (ex. click/landing page on billing info)</li>
527
- <li><b>Purchase:</b> Track purchases or checkout flow completions (ex. landing on "Thank You" or confirmation page)</li>
528
- <li><b>Lead:</b> Track when a user expresses interest in your offering (ex. form submission, sign up for trial, landing on pricing page)</li>
529
- <li><b>CompleteRegistration:</b> Track when a registration form is completed (ex. complete subscription, sign up for a service)</li>
530
- </ul>
531
- <?php
532
- }
533
-
534
-
535
-
536
- function woofp_currency_options( $current='USD' ){
537
- ?>
538
- <option <?php echo selected( 'AUD', $current, true ); ?> value="AUD">Australian Dollar</option>
539
- <option <?php echo selected( 'BRL', $current, true ); ?> value="BRL">Brazilian Real </option>
540
- <option <?php echo selected( 'CAD', $current, true ); ?> value="CAD">Canadian Dollar</option>
541
- <option <?php echo selected( 'CZK', $current, true ); ?> value="CZK">Czech Koruna</option>
542
- <option <?php echo selected( 'DKK', $current, true ); ?> value="DKK">Danish Krone</option>
543
- <option <?php echo selected( 'EUR', $current, true ); ?> value="EUR">Euro</option>
544
- <option <?php echo selected( 'HKD', $current, true ); ?> value="HKD">Hong Kong Dollar</option>
545
- <option <?php echo selected( 'HUF', $current, true ); ?> value="HUF">Hungarian Forint </option>
546
- <option <?php echo selected( 'ILS', $current, true ); ?> value="ILS">Israeli New Sheqel</option>
547
- <option <?php echo selected( 'JPY', $current, true ); ?> value="JPY">Japanese Yen</option>
548
- <option <?php echo selected( 'IDR', $current, true ); ?> value="USD">Indonesian Rupiah</option>
549
- <option <?php echo selected( 'KRW', $current, true ); ?> value="KRW">Korean Won</option>
550
- <option <?php echo selected( 'MYR', $current, true ); ?> value="MYR">Malaysian Ringgit</option>
551
- <option <?php echo selected( 'MXN', $current, true ); ?> value="MXN">Mexican Peso</option>
552
- <option <?php echo selected( 'NOK', $current, true ); ?> value="NOK">Norwegian Krone</option>
553
- <option <?php echo selected( 'NZD', $current, true ); ?> value="NZD">New Zealand Dollar</option>
554
- <option <?php echo selected( 'PHP', $current, true ); ?> value="PHP">Philippine Peso</option>
555
- <option <?php echo selected( 'PLN', $current, true ); ?> value="PLN">Polish Zloty</option>
556
- <option <?php echo selected( 'RON', $current, true ); ?> value="RON">Romanian Leu</option>
557
- <option <?php echo selected( 'GBP', $current, true ); ?> value="GBP">Pound Sterling</option>
558
- <option <?php echo selected( 'SGD', $current, true ); ?> value="SGD">Singapore Dollar</option>
559
- <option <?php echo selected( 'SEK', $current, true ); ?> value="SEK">Swedish Krona</option>
560
- <option <?php echo selected( 'CHF', $current, true ); ?> value="CHF">Swiss Franc</option>
561
- <option <?php echo selected( 'TWD', $current, true ); ?> value="TWD">Taiwan New Dollar</option>
562
- <option <?php echo selected( 'THB', $current, true ); ?> value="THB">Thai Baht</option>
563
- <option <?php echo selected( 'TRY', $current, true ); ?> value="TRY">Turkish Lira</option>
564
- <option <?php echo selected( 'USD', $current, true ); ?> value="USD">U.S. Dollar</option>
565
-
566
-
567
-
568
-
569
- <?php
570
- }
571
-
572
-
573
- function woofp_pixelcode(){
574
-
575
- //load facebook pixel on front only
576
- if( !is_admin() ){
577
-
578
- $facebookpixel = woofp_admin_settings('facebookpixel');
579
- $facebookpixel_code = woofp_page_event();
580
- if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 && '' != $facebookpixel_code[0] ){
581
- ?>
582
-
583
-
584
- <!-- Facebook Pixel Code -->
585
- <script>
586
- var PYS_DOMReady = function(a,b,c){b=document,c='addEventListener';b[c]?b[c]('DOMContentLoaded',a):window.attachEvent('onload',a)};
587
- !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
588
- n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
589
- n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
590
- t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
591
- document,'script','//connect.facebook.net/en_US/fbevents.js');
592
-
593
- /* pixel plugin code */
594
- PYS_DOMReady(function(){
595
-
596
- <?php
597
-
598
- echo $facebookpixel_code[0];
599
- ?>
600
-
601
- });
602
- /* pixel plugin code */
603
-
604
- </script>
605
-
606
- <!-- End Facebook Pixel Code -->
607
-
608
- <?php
609
- }
610
-
611
- } else {
612
- ?>
613
- <img src="<?php echo admin_url('admin-ajax.php'); ?>" style="display:none;">
614
-
615
- <?php
616
- }
617
-
618
-
619
-
620
- }
621
-
622
-
623
- /*
624
- Woocommerce Related Functions
625
- Check if woocommerce is install and activated.
626
- */
627
-
628
- function woofp_addtocart_urls($woofp_options=''){
629
-
630
-
631
- $facebookpixel = $woofp_options['facebookpixel'];
632
- $standardevent = $woofp_options['standardevent'];
633
- $woocommerce_settings = $woofp_options['woocommerce'];
634
- $results = array();
635
-
636
-
637
- /* whether facebook pixel is activated */
638
- if( woofp_get_option('facebookpixel', 'activate') == 1 ){
639
-
640
- /* whether standerd events is activated */
641
- if( woofp_get_option('standardevent', 'activate') == 1 ){
642
-
643
-
644
-
645
- $results = array();
646
- if( isset( $standardevent['pageurl'] ) && !empty($standardevent['pageurl']) ){
647
-
648
- foreach ( $standardevent['pageurl'] as $key => $link) {
649
-
650
- $pageurl = rtrim($standardevent['pageurl'][$key], '/');
651
- $cartvalue = $standardevent['value'][$key];
652
- $currency = $standardevent['currency'][$key];
653
- $eventtype = $standardevent['eventtype'][$key];
654
-
655
- if( !in_array($pageurl, $results) && $eventtype == 'AddToCart' )
656
- $results[] = $pageurl;
657
-
658
-
659
- }
660
-
661
- }
662
-
663
- if( woofp_get_option('woocommerce', 'activate') == 1 ){
664
-
665
- //Add pixel event for woocommerce pages
666
- foreach (woofp_woocommerce_events() as $key => $woocommerc_event) {
667
-
668
- $eventtype = $woocommerc_event['event'];
669
- if( !in_array( '***', $results) && woofp_is_woocommerce_event($eventtype, $woocommerce_settings, false) && $eventtype == 'AddToCart' )
670
- $results[] = '***';
671
- }
672
-
673
- }
674
-
675
- }
676
-
677
- }
678
-
679
-
680
- return $results;
681
-
682
- }
683
-
684
-
685
- function woofp_addtocart_pixel(){
686
-
687
-
688
- $woofp_options = get_option('woofp_admin_settings');
689
-
690
-
691
-
692
- /* whether facebook pixel is activated */
693
- if( 1 == woofp_get_option('facebookpixel', 'activate') && 1 == woofp_get_option('woocommerce', 'activate') ){
694
- ?>
695
-
696
- <!-- noscript facebook pixel -->
697
-
698
- <?php
699
- $facebookpixel_code = woofp_page_event();
700
- echo $facebookpixel_code[1];
701
- ?>
702
- <!-- end noscript facebook pixel -->
703
-
704
- <!-- Dynamic AddToCart when Ajax enabled on Woocommerce -->
705
- <?php
706
-
707
-
708
- if ( get_option( 'woocommerce_enable_ajax_add_to_cart' ) == 'yes' && ( is_woocommerce() || is_page() || is_single() ) ) {
709
-
710
- $php_array = woofp_addtocart_urls($woofp_options);
711
- $js_array = json_encode($php_array);
712
- ?>
713
-
714
-
715
- <script type="text/javascript">
716
- var fbpmpaddtocart_eventcode = '';
717
-
718
- jQuery(function($){
719
-
720
-
721
- //Run AddToCart Event when product are added using ajax
722
- var woofp_addtocart_btn = "a.add_to_cart_button:not('.product_type_variable')";
723
-
724
- jQuery(document).on( 'click', woofp_addtocart_btn, function(e) {
725
-
726
-
727
-
728
- var current_url = jQuery(this).attr('href') || '';
729
- var product_id = jQuery(this).attr('data-product_id') || 0;
730
-
731
- <?php echo "var url_array = ". $js_array . ";\n"; ?>
732
- <?php echo "var homeurl = '". home_url() . "';\n"; ?>
733
-
734
- if (current_url.indexOf('http://') < 0 || current_url.indexOf('https://') < 0){
735
- current_url = homeurl + current_url;
736
- }
737
-
738
-
739
- var code_exists = false;
740
- if( url_array != null && url_array != '' ){
741
-
742
- e.preventDefault();
743
-
744
- for (i = 0; i < url_array.length; i++) {
745
-
746
- if( url_array[i] == '***' && code_exists == false ){
747
-
748
- code_exists = true;
749
- fbq('track', 'AddToCart');
750
- return false;
751
- } else if( current_url.search(url_array[i]) !== -1 && code_exists == false ){
752
-
753
- code_exists = true;
754
- fbq('track', 'AddToCart');
755
- return false;
756
- }
757
-
758
- }
759
-
760
- } /* url_array != null */
761
-
762
-
763
- });
764
-
765
- });
766
- </script>
767
- <?php
768
- }
769
-
770
- } /* is woocommerce active */
771
-
772
-
773
- }
774
-
775
-
776
-
777
- function woofp_is_woocommerce_page ($page) {
778
-
779
- switch ($page) {
780
-
781
- case 'woocommerce_view_content':
782
-
783
- return is_product();
784
-
785
- case 'woocommerce_added_to_cart':
786
-
787
- if ( isset($_REQUEST['add-to-cart']) && is_numeric($_REQUEST['add-to-cart']) )
788
- return true;
789
- else
790
- return false;
791
-
792
-
793
- break;
794
-
795
-
796
- case 'woocommerce_cart_page_id':
797
-
798
- return is_cart();
799
-
800
- break;
801
-
802
- case 'woocommerce_checkout_page_id':
803
-
804
- if( is_checkout() && !is_wc_endpoint_url() )
805
- return true;
806
- else
807
- return false;
808
-
809
- break;
810
-
811
- case 'woocommerce_thanks_page_id':
812
-
813
- if( is_wc_endpoint_url( 'order-received' ) )
814
- return true;
815
- else
816
- return false;
817
-
818
-
819
- break;
820
-
821
- case 'woocommerce_search_product':
822
-
823
- if ( isset($_GET['s']) && ( isset($_GET['post_type']) && $_GET['post_type'] == 'product' ) ) {
824
-
825
- return true ;
826
-
827
- } else {
828
-
829
- return false;
830
- }
831
-
832
- break;
833
-
834
- default:
835
- return false;
836
- break;
837
- }
838
-
839
- }
840
-
841
-
842
- /**
843
- * Return appropriate pixel events for woocommerce pages
844
- *
845
- * @return array
846
- * @author PixelYourSite
847
- **/
848
- function woofp_woocommerce_events(){
849
-
850
- $woocommerce_events = array(
851
-
852
- array(
853
- 'event' => 'ViewContent',
854
- 'page' => 'woocommerce_view_content',
855
- 'title' => 'Single Product Pages',
856
- 'label' => 'ViewContent Event'
857
- ),
858
-
859
- array(
860
- 'event' => 'ProductAddToCart',
861
- 'page' => 'woocommerce_added_to_cart',
862
- 'title' => 'Product Added to Cart',
863
- 'label' => 'AddToCart Event'
864
- ),
865
-
866
- array(
867
- 'event' => 'AddToCart',
868
- 'page' => 'woocommerce_cart_page_id',
869
- 'title' => 'Cart Page',
870
- 'label' => 'AddToCart Event'
871
- ),
872
- array(
873
- 'event' => 'InitiateCheckout',
874
- 'page' => 'woocommerce_checkout_page_id',
875
- 'title' => 'CheckOut Page',
876
- 'label' => 'InitiateCheckout Event'
877
- ),
878
- /*array(
879
- 'event' => 'AddPaymentInfo',
880
- 'page' => 'woocommerce_checkout_page_id',
881
- 'title' => 'Checkout Page',
882
- 'label' => 'AddPaymentInfo Event'
883
- ),*/
884
- array(
885
- 'event' => 'Purchase',
886
- 'page' => 'woocommerce_thanks_page_id',
887
- 'title' => 'Thankyou Page',
888
- 'label' => 'Purchase Event'
889
- ),
890
- /*array(
891
- 'event' => 'Search',
892
- 'page' => 'woocommerce_search_product',
893
- 'title' => 'Product Search',
894
- 'label' => ' Search Event'
895
- ),*/
896
-
897
- );
898
-
899
- return $woocommerce_events;
900
- }
901
-
902
- /**
903
- * Check if woocommerce event is activated in settings
904
- * @return string | true/false
905
- * @author PixelYourSite
906
- **/
907
- function woofp_is_woocommerce_event($event, $settings, $echo=true){
908
-
909
-
910
- if( isset( $settings['events'] ) && !empty($settings['events']) && isset($settings['events'][$event]) && $settings['events'][$event] == 1 ){
911
- $checked = 'checked="checked"';
912
- $return = true;
913
- } else {
914
-
915
- $checked = '';
916
- $return = false;
917
- }
918
-
919
- if($echo){
920
- echo $checked;
921
- } else {
922
-
923
- return $return;
924
- }
925
- }
926
-
927
- function woofp_startsWith($haystack, $needle) {
928
- // search backwards starting from haystack length characters from the end
929
- return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
930
- }
931
-
932
- function woofp_endsWith($haystack, $needle) {
933
- // search forward starting from end minus needle length characters
934
- return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
935
- }
936
-
937
-
938
- function woofp_valid_url($value){
939
- $pattern = "@^(?:https?://)?(?:[a-z0-9-]+\.)*((?:[a-z0-9-]+\.)[a-z]+)@";
940
-
941
- if (!preg_match($pattern, $value)){
942
- return false;
943
- }
944
-
945
- return true;
946
- }
947
-
948
- /**
949
- * add http:// to url if missing
950
- *
951
- * @return string
952
- * @author PixelYourSite
953
- **/
954
- function woofp_addhttp($url=''){
955
-
956
- if (preg_match("#https?://#", $url) === 0) {
957
- $url = 'http://'.$url;
958
- }
959
-
960
- return $url;
961
- }
962
-
963
-
964
- /**
965
- * Remove http(s)/www. from url
966
- *
967
- * @return string
968
- * @author PixelYourSite
969
- **/
970
- function woofp_remove_protocol($url=''){
971
-
972
- if(empty($url) && !woofp_valid_url($url))
973
- return $url;
974
-
975
- $url = str_replace(array('http://', 'https://', 'http://www.', 'https://www.'), '', $url);
976
-
977
- $url = trim($url);
978
- $url = trim($url, '//');
979
- $url = rtrim($url, '/');
980
-
981
- return $url;
982
- }
983
-
984
-
985
- function woofp_match_url($current_url, $match_url, $eventtype='' ){
986
-
987
- $current_url = woofp_remove_protocol($current_url);
988
- $match_url = woofp_remove_protocol($match_url);
989
-
990
- if(strpos($match_url, '*') !== false && woofp_endsWith($match_url, '*') ){
991
-
992
- $temp_url = $match_url;
993
- $temp_url = rtrim($temp_url, '*');
994
-
995
- $temp_url = trim($temp_url);
996
- $temp_url = trim($temp_url, '//');
997
- $temp_url = rtrim($temp_url, '/');
998
-
999
-
1000
-
1001
- if ( woofp_valid_url($temp_url) === true) {
1002
-
1003
- $current_postid = url_to_postid( woofp_addhttp($current_url) );
1004
- $match_postid = url_to_postid( woofp_addhttp($temp_url) );
1005
- $current_length = strlen($current_url);
1006
- $match_length = strlen($temp_url);
1007
-
1008
- $postmatch = false;
1009
-
1010
- if( $current_postid && $match_postid && $current_postid == $match_postid ){
1011
- $postmatch = true;
1012
- }
1013
-
1014
-
1015
- $strcmp1 = strcmp($temp_url, $current_url);
1016
- $strcmp2 = strcmp($current_url, $temp_url);
1017
-
1018
- $found1 = ( (strpos($temp_url, $current_url) !== false ) ? 'true' : 'false' );
1019
- $found2 = ( (strpos($current_url, $temp_url) !== false ) ? 'true' : 'false' );
1020
-
1021
- if( $match_length > $current_length && $found1 == 'true' ){
1022
-
1023
- $ret = ( ( $strcmp1 < 0 || $postmatch ) ? 'true' : 'false' );
1024
-
1025
- } else if( $match_length < $current_length && $found2 == 'true' ){
1026
-
1027
- $ret = ( ( $strcmp2 > 0 || $postmatch ) ? 'true' : 'false' );
1028
-
1029
- } else {
1030
-
1031
- $ret = ( ( $strcmp1 == 0 || $postmatch ) ? 'true' : 'false' );
1032
-
1033
- }
1034
-
1035
-
1036
- return $ret;
1037
-
1038
- } else {
1039
-
1040
-
1041
- return 'false';
1042
- }
1043
-
1044
- } else {
1045
-
1046
-
1047
- if ( woofp_valid_url($match_url) === true ) {
1048
-
1049
- $current_postid = url_to_postid( woofp_addhttp($current_url) );
1050
- $match_postid = url_to_postid( woofp_addhttp($match_url) );
1051
-
1052
- $postmatch = false;
1053
- if( $current_postid && $match_postid && $current_postid == $match_postid ){
1054
- $postmatch = true;
1055
- }
1056
-
1057
- $strcmp = strcmp( $current_url, $match_url );
1058
- $ret = ( ( $strcmp == 0 || $postmatch ) ? 'true' : 'false' );
1059
-
1060
-
1061
- return $ret;
1062
-
1063
- } else {
1064
-
1065
- $strpos = strpos($current_url, $match_url);
1066
- $ret = ( $strpos !== false ? 'true' : 'false' );
1067
-
1068
-
1069
- return $ret;
1070
-
1071
- }
1072
-
1073
- }
1074
- }
1075
-
1076
- function woofp_is_woocommerce(){
1077
-
1078
- if ( !class_exists( 'WooCommerce' ) ) {
1079
-
1080
- return false;
1081
-
1082
- } else {
1083
-
1084
-
1085
- return true;
1086
- }
1087
-
1088
- }
1089
-
1090
-
1091
- function woofp_filter_standardevent_args($event, $args){
1092
-
1093
- $temp_args = woofp_standardevent_extented($event);
1094
-
1095
- if( !empty($temp_args) && !empty($args) ){
1096
- $new_args = array();
1097
- foreach ($temp_args as $ta => $ta_value) {
1098
-
1099
- $name = $ta_value['name'];
1100
- $new_args[$name] = $args[$name];
1101
-
1102
- }
1103
-
1104
- $new_args['currency'] = $args['currency'];
1105
- $new_args['value'] = $args['value'];
1106
-
1107
- return $new_args;
1108
- }
1109
-
1110
- return $args;
1111
- }
1112
-
1113
-
1114
- function woofp_vars(){
1115
- $vars = array();
1116
-
1117
- $vars['content_name'] = 'content_name';
1118
- $vars['content_category'] = 'content_category';
1119
- $vars['content_ids'] = 'content_ids';
1120
- $vars['content_type'] = 'content_type';
1121
- $vars['search_string'] = 'search_string';
1122
- $vars['num_items'] = 'num_items';
1123
- $vars['order_id'] = 'order_id';
1124
- $vars['status'] = 'status';
1125
-
1126
- return $vars;
1127
- }
1128
-
1129
- function woofp_standardevent_extented($event){
1130
-
1131
-
1132
- $params = array();
1133
-
1134
- if(
1135
- $event == 'ViewContent'
1136
- || $event == 'AddToCart'
1137
- || $event == 'AddToWishlist'
1138
- || $event == 'InitiateCheckout'
1139
- || $event == 'Purchase'
1140
- || $event == 'Lead'
1141
- || $event == 'CompleteRegistration' ){
1142
-
1143
- $name = 'content_name';
1144
- $example = "'Really Fast Running Shoes'";
1145
- $info = "Name of the page/product";
1146
- $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1147
- }
1148
-
1149
-
1150
- if(
1151
- $event == 'Search'
1152
- || $event == 'AddToWishlist'
1153
- || $event == 'InitiateCheckout'
1154
- || $event == 'AddPaymentInfo'
1155
- || $event == 'Lead' ){
1156
-
1157
- $name = 'content_category';
1158
- $example = "'Apparel & Accessories > Shoes'";
1159
- $info = "Category of the page/product.";
1160
- $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1161
-
1162
- }
1163
-
1164
- if(
1165
- $event == 'ViewContent'
1166
- || $event == 'Search'
1167
- || $event == 'AddToCart'
1168
- || $event == 'AddToWishlist'
1169
- || $event == 'InitiateCheckout'
1170
- || $event == 'AddPaymentInfo'
1171
- || $event == 'Purchase' ){
1172
-
1173
- $name = 'content_ids';
1174
- $example = "['1234']";
1175
- $info = "Product ids/SKUs associated with the event.";
1176
- $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1177
-
1178
- }
1179
-
1180
-
1181
-
1182
- if(
1183
- $event == 'ViewContent'
1184
- || $event == 'AddToCart'
1185
- || $event == 'InitiateCheckout'
1186
- || $event == 'Purchase' ){
1187
-
1188
- $name = 'content_type';
1189
- $example = "'product' or 'product_group'";
1190
- $info = "The type of content_ids.";
1191
- $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1192
- }
1193
-
1194
-
1195
-
1196
- if( $event == 'Search' ) {
1197
-
1198
- $name = 'search_string';
1199
- $example = "'Shoes'";
1200
- $info = "The string entered by the user for the search.";
1201
- $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1202
-
1203
- }
1204
-
1205
- if(
1206
- $event == 'Purchase'
1207
- || $event == 'InitiateCheckout' ){
1208
-
1209
- $name = 'num_items';
1210
- $example = "'3'";
1211
- $info = "The number of items in the cart.";
1212
- $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1213
- }
1214
-
1215
- if( $event == 'Purchase' ){
1216
-
1217
- $name = 'order_id';
1218
- $example = "19";
1219
- $info = "The unique order id of the successful purchase.";
1220
- $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1221
- }
1222
-
1223
- if( $event == 'CompleteRegistration' ){
1224
-
1225
- $name = 'status';
1226
- $example = "completed";
1227
- $info = "The status of the registration.";
1228
- $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1229
- }
1230
-
1231
- return $params;
1232
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -196,6 +196,11 @@ We have an article about how to optimize Facebook Ads Reports:
196
 
197
  == Changelog ==
198
 
 
 
 
 
 
199
  = PixelYourSite 3.0 =
200
 
201
  This is a major release, with new design and new features:
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.1
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
196
 
197
  == Changelog ==
198
 
199
+ = PixelYourSite 3.0.1 =
200
+
201
+ * Fixing potential problem with importing settings from older versions
202
+
203
+
204
  = PixelYourSite 3.0 =
205
 
206
  This is a major release, with new design and new features: