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

Version Description

Download this release

Release Info

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

Code changes from version 1.05.1 to 2.0

Files changed (6) hide show
  1. css/admin.css +162 -19
  2. facebook-pixel-master.php +28 -4
  3. inc/admin.php +214 -52
  4. inc/helper-functions.php +367 -33
  5. js/admin.js +248 -12
  6. readme.txt +36 -28
css/admin.css CHANGED
@@ -2,23 +2,6 @@
2
  display: none;
3
  }
4
 
5
- .facebook-pixel-body ul.facebook-pixel-menu li {
6
- float: left;
7
- padding: 10px 10px;
8
- font-size: 14px;
9
- font-weight: bold;
10
- background-color: #ccc;
11
- border-radius: 10px 10px 0 0;
12
- border: 1px solid #777;
13
- color: #222;
14
- cursor: pointer;
15
- margin-bottom: 0;
16
- }
17
- .facebook-pixel-body ul.facebook-pixel-menu li.selected, .facebook-pixel-body ul.facebook-pixel-menu li:hover{
18
- background: #00a0d2;
19
- border-color: #0073aa;
20
- color: #fff;
21
- }
22
 
23
 
24
  .facebook-pixel-content {
@@ -124,10 +107,27 @@
124
  width: 100%;
125
  }
126
 
127
- .facebook-pixel-panel td p b {
128
  font-size: 16px;
129
  color: #00a0d2;
130
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  .facebook-pixel-panel a {
132
  color: #DD4E4E;
133
  font-size: 14px;
@@ -139,4 +139,147 @@ tr.hide-standardevent{
139
 
140
  tr.show-standardevent{
141
 
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  display: none;
3
  }
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
 
7
  .facebook-pixel-content {
107
  width: 100%;
108
  }
109
 
110
+ .facebook-pixel-panel td p b.woofpimportant {
111
  font-size: 16px;
112
  color: #00a0d2;
113
  }
114
+
115
+ .facebook-pixel-panel .standarevent-value, .facebook-pixel-panel .standarevent-currency{
116
+ display: none;
117
+ }
118
+
119
+ .facebook-pixel-panel td p b.event_param, .facebook-pixel-panel td .event_param_wrap b.event_param {
120
+ color: #333;
121
+ display: inline-block;
122
+ font-size: 12px;
123
+ width: 120px;
124
+ }
125
+
126
+
127
+ .facebook-pixel-panel td .event_param_wrap input, .facebook-pixel-panel td .woofp-input-pageurl{
128
+ width: 30em;
129
+ }
130
+
131
  .facebook-pixel-panel a {
132
  color: #DD4E4E;
133
  font-size: 14px;
139
 
140
  tr.show-standardevent{
141
 
142
+ }
143
+
144
+
145
+ .woofp-sub-option{
146
+ }
147
+
148
+ tr th input.woofp-reset-event{
149
+ display: block !important;
150
+ margin-top: 10px !important;
151
+
152
+ }
153
+
154
+ .event_param_wrap {
155
+ padding: 4px 0;
156
+ }
157
+
158
+ tr.woofp-pageurl-tr {
159
+ border-bottom: 1px solid #ddd;
160
+ }
161
+
162
+ .woofp-asterik{
163
+ color: #dd4e4e;
164
+ }
165
+
166
+ /* menu css */
167
+
168
+ #facebook-pixel-wrap .facebook-pixel-menu{
169
+ border-bottom: 1px solid #ccc;
170
+ padding-bottom: 0;
171
+ padding-left: 10px;
172
+ font-size: 23px;
173
+ font-weight: 400;
174
+ line-height: 29px;
175
+ color: #23282d;
176
+ margin-bottom: -1px;
177
+ }
178
+
179
+
180
+
181
+ #facebook-pixel-wrap .facebook-pixel-menu li {
182
+
183
+ font-size: 15px;
184
+ font-weight: 700;
185
+ line-height: 24px;
186
+ padding: 6px 10px;
187
+ cursor: pointer;
188
+
189
+ -moz-border-bottom-colors: none;
190
+ -moz-border-left-colors: none;
191
+ -moz-border-right-colors: none;
192
+ -moz-border-top-colors: none;
193
+ border-top-color: none;
194
+ border-bottom-color: none;
195
+ border-left-color: none;
196
+ border-right-color: none;
197
+
198
+ background: #e4e4e4 none repeat scroll 0 0;
199
+ border-color: #ccc #ccc -moz-use-text-color;
200
+ border-image: none;
201
+ border-style: solid solid none;
202
+ border-width: 1px 1px medium;
203
+ color: #555;
204
+ margin: -4px 4px -1px 0;
205
+
206
+ }
207
+
208
+
209
+ #facebook-pixel-wrap .facebook-pixel-menu li:hover {
210
+ background-color: #fff;
211
+ color: #464646;
212
+ }
213
+
214
+ #facebook-pixel-wrap .facebook-pixel-menu li.selected{
215
+ font-size: 15px;
216
+ font-weight: 700;
217
+ line-height: 24px;
218
+ padding: 6px 10px;
219
+ display: inline-block;
220
+ cursor: pointer;
221
+ -moz-border-bottom-colors: none;
222
+ -moz-border-left-colors: none;
223
+ -moz-border-right-colors: none;
224
+ -moz-border-top-colors: none;
225
+ border-top-color: none;
226
+ border-bottom-color: none;
227
+ border-left-color: none;
228
+ border-right-color: none;
229
+ border-image: none;
230
+ margin: -4px 4px -1px 0;
231
+
232
+ }
233
+
234
+ #facebook-pixel-wrap .facebook-pixel-menu li.selected, #facebook-pixel-wrap .facebook-pixel-menu li.selected:hover {
235
+ background: #f1f1f1 none repeat scroll 0 0;
236
+ border-bottom: 1px solid #f1f1f1;
237
+ color: #000;
238
+ }
239
+
240
+
241
+ span.woofpbold{
242
+ font-weight: 600;
243
+ font-size: 14px;
244
+ }
245
+
246
+ .affiliate_row td p label {
247
+ width: 132px;
248
+ display: inline-block;
249
+ font-weight: bold;
250
+ font-size: 11px;
251
+ }
252
+
253
+ .woofp-or{
254
+ display: inline-block;
255
+ text-align: center;
256
+ width: 300px;
257
+ padding: 10px 0;
258
+ }
259
+
260
+ #pysf_notice_tab {
261
+ padding-right: 38px;
262
+ position: relative;
263
+ margin: 5px 0 15px;
264
+ display: inline-block;
265
+ line-height: 19px;
266
+ padding: 0px 15px;
267
+ font-size: 14px;
268
+ text-align: left;
269
+ background-color: #fff;
270
+ border-left: 4px solid #ffba00;
271
+ -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
272
+ box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
273
+ background: #fff;
274
+ padding-top: 0;
275
+ padding-bottom: 0;
276
+ border-left-width: 10px;
277
+ }
278
+
279
+ #pysf_notice_tab p, #pysf_notice p{
280
+ margin: .5em 0;
281
+ padding: 2px;
282
+ width: 98%;
283
+ }
284
+
285
+ #pysf_notice_tab p { font-size:14px;}
facebook-pixel-master.php CHANGED
@@ -2,15 +2,28 @@
2
  /*
3
  Plugin Name: PixelYourSite
4
  Description: Add the Facebook Pixel code into your Wordpress site and set up standard events with just a few clicks. Fully compatible with Woocommerce, purchase event included.
5
- Plugin URI: http://www.pixelyoursite.com/free
6
  Author: PixelYourSite
7
  Author URI: http://www.pixelyoursite.com
8
- Version: 1.05.1
9
  License: GPLv3
10
  */
11
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  require_once('inc/helper-functions.php');
 
14
 
15
  add_action('init', 'woofp_init');
16
 
@@ -134,6 +147,9 @@ function ajax_woofbsavesettings(){
134
 
135
  //Save admin settings
136
  update_option('woofp_admin_settings', $woofp_options_update);
 
 
 
137
  $status = array( 'msg' => 'Settings Saved.', 'status' => 2 , 'woo' => $woo);
138
 
139
  } else {
@@ -145,12 +161,20 @@ function ajax_woofbsavesettings(){
145
 
146
  //exit ajax
147
  die(json_encode($status));
 
148
  }
149
 
150
 
151
- //Todo:
152
  function woofp_plugin_activated(){
153
- //todo
 
 
 
 
 
 
 
154
 
155
  }
156
 
2
  /*
3
  Plugin Name: PixelYourSite
4
  Description: Add the Facebook Pixel code into your Wordpress site and set up standard events with just a few clicks. Fully compatible with Woocommerce, purchase event included.
5
+ Plugin URI: http://www.pixelyoursite.com/facebook-pixel-plugin-help
6
  Author: PixelYourSite
7
  Author URI: http://www.pixelyoursite.com
8
+ Version: 2.0
9
  License: GPLv3
10
  */
11
 
12
+ // If this file is called directly, abort.
13
+ if ( ! defined( 'WPINC' ) ) {
14
+ die;
15
+ }
16
+
17
+ /*
18
+ * Constants
19
+ */
20
+ //Plugin Version
21
+ define( 'FBPMP_VERSION', '2.0');
22
+
23
+
24
 
25
  require_once('inc/helper-functions.php');
26
+ require_once('inc/admin_notices.php');
27
 
28
  add_action('init', 'woofp_init');
29
 
147
 
148
  //Save admin settings
149
  update_option('woofp_admin_settings', $woofp_options_update);
150
+
151
+
152
+
153
  $status = array( 'msg' => 'Settings Saved.', 'status' => 2 , 'woo' => $woo);
154
 
155
  } else {
161
 
162
  //exit ajax
163
  die(json_encode($status));
164
+
165
  }
166
 
167
 
168
+ //When The p
169
  function woofp_plugin_activated(){
170
+
171
+
172
+ if ( !function_exists( 'is_plugin_active' ) ) {
173
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
174
+ }
175
+ if ( is_plugin_active( 'pixelyoursite-pro/pixelyoursite-pro.php' ) ) {
176
+ wp_die( 'Please deactivate PixelYourSite Pro Version First.', 'Plugin Activation');
177
+ }
178
 
179
  }
180
 
inc/admin.php CHANGED
@@ -2,17 +2,18 @@
2
  <br>
3
  <h2>PixelYourSite: Manage your Facebook Pixel</h2>
4
  <br>
5
- <p><b>Implement and control Facebook Pixel with just few clicks.</b></p>
6
  <br>
7
-
8
  <div class="facebook-pixel-wrap" id="facebook-pixel-wrap">
9
  <div class="facebook-pixel-body">
10
- <ul class="facebook-pixel-menu">
11
- <li id="facebook-pixel-menu-1" class="selected">Facebook Pixel</li>
12
- <li id="facebook-pixel-menu-2">Standard Events Setup</li>
13
- <li id="facebook-pixel-menu-3">Woocommerce Setup</li>
14
  </ul>
15
 
 
16
  <div class="facebook-pixel-content">
17
  <form action="" method="post" name="facebook-pixel-form" id="facebook-pixel-form">
18
 
@@ -23,13 +24,14 @@
23
  <table class="form-table">
24
  <tbody>
25
  <tr>
26
- <th scope="row">&nbsp;</th>
27
- <td><p><b>Important:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Read this before starting.</a></p></td>
28
  </tr>
29
  <tr>
30
  <th scope="row">&nbsp;</th>
31
- <td><p><b>This Super Special Offer will expire on December 31. Don't lose it, because you might need the PRO version in the future:</b> <a href="http://www.pixelyoursite.com/super-offer?utm_source=wordpress-tab1&utm_medium=plugin&utm_campaign=plugin-super-offer" target="_blank">Click Here for your HUGE discount</a></p></td>
32
  </tr>
 
 
33
  <tr>
34
  <th scope="row">Your Pixel ID:</th>
35
  <td>
@@ -65,50 +67,107 @@
65
  <div id="facebook-pixel-panel-2" class="facebook-pixel-panel ">
66
  <table class="form-table">
67
  <tbody>
 
 
 
 
 
68
  <tr>
69
  <th scope="row">&nbsp;</th>
70
- <td><p><b>Important:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Read this before starting.</a></p></td>
71
  </tr>
72
 
73
 
74
  <tr class=" <?php echo $hide_standardevent; ?>">
75
  <th scope="row">&nbsp;</th>
76
- <td><h3 style="float:left;">Customize your code with standard events <span class="woofp-events-help"><b class="woofp-help-icon">?</b><?php woofp_event_help(); ?></span></h3></td>
77
  </tr>
78
 
79
  <?php
80
-
81
  if( !empty( $standardevent['pageurl'] ) ) {
82
 
83
 
84
  foreach ( $standardevent['pageurl'] as $key => $link) {
85
 
86
- $pageurl = $standardevent['pageurl'][$key];
87
- $cartvalue = $standardevent['value'][$key];
88
- $currency = $standardevent['currency'][$key];
89
- $eventtype = $standardevent['eventtype'][$key];
 
90
 
91
  ?>
92
 
93
  <tr class="woofp-pageurl-tr <?php echo $hide_standardevent; ?>">
94
- <th scope="row">Page(URL or Partial URL)</th>
95
  <td>
96
- <input type="text" name="standardevent[pageurl][]" value="<?php echo $pageurl; ?>" class="woofp-input-pageurl" />
97
-
 
 
 
 
 
 
 
98
  <select name="standardevent[eventtype][]" class="woofp-input-event">
99
- <option vlaue="">- Select Event -</option>
100
  <?php echo woofp_event_types($eventtype); ?>
101
  </select>
102
- <p>
103
- Value:<input type="text" name="standardevent[value][]" value="<?php echo $cartvalue; ?>" class=" woofp-input-value" />
104
- Currency:<select name="standardevent[currency][]" class=" woofp-input-currency">
 
 
 
 
 
 
105
  <option value="">Select Currency</option>
106
  <?php echo woofp_currency_options($currency); ?>
107
  </select>
 
108
 
109
- <span class="woofp-input-desc">*Mandatory for purchase event only.</span>
110
  </p>
111
- <p class="description">This Event will trigger on any URL that contains this string.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  </td>
113
  </tr>
114
 
@@ -116,27 +175,44 @@
116
 
117
  }
118
  } else {
119
- ?>
 
120
 
121
  <tr class="woofp-pageurl-tr <?php echo $hide_standardevent; ?>">
122
  <th scope="row">Page(URL or Partial URL)</th>
123
  <td>
124
- <input type="text" name="standardevent[pageurl][]" value="" class="woofp-input-pageurl" />
125
-
126
- <select name="standardevent[eventtype][]" class="woofp-input-event">
127
- <option vlaue="">- Select Event -</option>
128
- <?php echo woofp_event_types(''); ?>
129
- </select>
 
130
  <p>
131
- Value:<input type="text" name="standardevent[value][]" value="" class=" woofp-input-value" />
132
- Currency:<select name="standardevent[currency][]" class=" woofp-input-currency">
 
 
 
 
 
 
 
 
 
133
  <option value="">Select Currency</option>
134
  <?php echo woofp_currency_options(''); ?>
135
  </select>
136
-
137
  <span class="woofp-input-desc">*Mandatory for purchase event only.</span>
138
  </p>
139
- <p class="description">This Event will trigger on any URL that contains this string.</p>
 
 
 
 
 
 
 
140
  </td>
141
  </tr>
142
 
@@ -170,19 +246,24 @@
170
  <?php if( woofp_is_woocommerce() ){ ?>
171
  <table class="form-table">
172
  <tbody>
 
 
 
 
 
173
  <tr>
174
  <th scope="row">&nbsp;</th>
175
- <td><p><b>Important:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Read this before starting.</a></p></td>
176
  </tr>
177
 
178
  <tr>
179
  <th scope="row">&nbsp;</th>
180
- <td><p><b>Don't miss this:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-woocommerce" target="_blank">Read this before activating WooCommerce Setup.</a></p></td>
181
  </tr>
182
 
183
  <tr>
184
  <th scope="row">&nbsp;</th>
185
- <td><h3 style="float:left;">Activate Pixel Event for WooCommerce Flow</h3>
186
  </td>
187
  </tr>
188
  <?php foreach ( woofp_woocommerce_events() as $key => $woocommerce_event) { ?>
@@ -198,45 +279,126 @@
198
 
199
  <tr>
200
  <th scope="row">&nbsp;</th>
201
- <td>
202
- <input type="checkbox" value="1" id="woocommerce-activate" name="woocommerce[activate]" <?php checked( '1', woofp_get_option('woocommerce', 'activate'), true ); ?> />Activate WooCommerce Setup.
203
- <p class="description">Check this to enable WooCommerce Setup.</p>
 
 
 
 
 
204
  </td>
205
  </tr>
 
206
  <tr>
207
  <th scope="row">&nbsp;</th>
208
- <td><h3>Enable Facebook Dynamic Ads Mode</h3></td>
 
 
 
 
 
209
  </tr>
 
210
  <tr>
211
  <th scope="row">&nbsp;</th>
212
  <td>
213
- <input type="checkbox" value="1" name="woocommerce[addtocart]" disabled="disabled" <?php checked( '1', woofp_get_option('woocommerce', 'addtocart'), true ); ?> /><span class="disabled">Activate AddToCart for Facebook Dynamic Ads.</span>
214
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo" target="_blank">Update to the Pro Version</a>
215
- <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(AddToCart Page)</i></p>
216
  </td>
217
  </tr>
218
  <tr>
219
  <th scope="row">&nbsp;</th>
220
  <td>
221
- <input type="checkbox" value="1" name="woocommerce[intiatecheckout]" disabled="disabled" <?php checked( '1', woofp_get_option('woocommerce', 'intiatecheckout'), true ); ?> /><span class="disabled">Activate InitiateCheckout for Facebook Dynamic Ads.</span>
222
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo" target="_blank">Update to the Pro Version</a>
223
  <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. </i>(Checkout Page)</i></p>
224
  </td>
225
  </tr>
226
  <tr>
227
  <th scope="row">&nbsp;</th>
228
  <td>
229
- <input type="checkbox" value="1" name="woocommerce[purchase]" disabled="disabled" <?php checked( '1', woofp_get_option('woocommerce', 'purchase'), true ); ?> /><span class="disabled">Activate Purchase for Facebook Dynamic Ads.</span>
230
- <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo" target="_blank">Update to the Pro Version</a>
231
  <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(Order Recieved/Thank You Page)</i></p>
232
  </td>
233
  </tr>
234
  <tr>
235
  <th scope="row">&nbsp;</th>
236
  <td>
237
- <h2>Super Special Offer - Will expire on December 31:</h2><a href="http://www.pixelyoursite.com/super-offer?utm_source=wordpress-tab3&utm_medium=plugin&utm_campaign=plugin-super-offer" target="_blank">Click Here to get your HUGE discount now</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  </td>
239
  </tr>
 
240
  <tr>
241
  <th scope="row">&nbsp;</th>
242
  <td><input type="button" class="button button-primary woofp-savesettings" value="Save WooCommerce Settings" /></td>
@@ -247,7 +409,7 @@
247
  <?php } else { ?>
248
  <div>
249
  <br>
250
- <p>Please Install and Activate <b>WooCommerce</b> to enable WooCommerce Integeration.</p>
251
  </div>
252
  <?php } ?>
253
  </div><!-- panel 3 -->
2
  <br>
3
  <h2>PixelYourSite: Manage your Facebook Pixel</h2>
4
  <br>
5
+ <p><b>Implement and control Facebook Pixel with just few clicks</b></p>
6
  <br>
7
+
8
  <div class="facebook-pixel-wrap" id="facebook-pixel-wrap">
9
  <div class="facebook-pixel-body">
10
+ <ul class="facebook-pixel-menu nav-tab-wrapper">
11
+ <li id="facebook-pixel-menu-1" class="nav-tab nav-tab-active selected">Facebook Pixel</li>
12
+ <li id="facebook-pixel-menu-2" class="nav-tab">Standard Events Setup</li>
13
+ <li id="facebook-pixel-menu-3" class="nav-tab">Woocommerce Setup</li>
14
  </ul>
15
 
16
+
17
  <div class="facebook-pixel-content">
18
  <form action="" method="post" name="facebook-pixel-form" id="facebook-pixel-form">
19
 
24
  <table class="form-table">
25
  <tbody>
26
  <tr>
27
+ <td colspan="2"><?php echo woofp_admin_notices(true); ?></td>
 
28
  </tr>
29
  <tr>
30
  <th scope="row">&nbsp;</th>
31
+ <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>
32
  </tr>
33
+
34
+
35
  <tr>
36
  <th scope="row">Your Pixel ID:</th>
37
  <td>
67
  <div id="facebook-pixel-panel-2" class="facebook-pixel-panel ">
68
  <table class="form-table">
69
  <tbody>
70
+
71
+ <tr>
72
+ <td colspan="2"><?php echo woofp_admin_notices(true); ?></td>
73
+ </tr>
74
+
75
  <tr>
76
  <th scope="row">&nbsp;</th>
77
+ <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>
78
  </tr>
79
 
80
 
81
  <tr class=" <?php echo $hide_standardevent; ?>">
82
  <th scope="row">&nbsp;</th>
83
+ <td><h3 style="float:left;" class="woofpimportant">Customize your code with standard events <span class="woofp-events-help"><b class="woofp-help-icon">?</b><?php woofp_event_help(); ?></span></h3></td>
84
  </tr>
85
 
86
  <?php
87
+ $code = '';
88
  if( !empty( $standardevent['pageurl'] ) ) {
89
 
90
 
91
  foreach ( $standardevent['pageurl'] as $key => $link) {
92
 
93
+ $pageurl = isset( $standardevent['pageurl'][$key] ) ? $standardevent['pageurl'][$key] : '';
94
+ $cartvalue = isset( $standardevent['value'][$key] ) ? $standardevent['value'][$key] : '';
95
+ $currency = isset( $standardevent['currency'][$key] ) ? $standardevent['currency'][$key] : '';
96
+ $eventtype = isset( $standardevent['eventtype'][$key] ) ? $standardevent['eventtype'][$key] : '';
97
+ $code = isset( $standardevent['code'][$key] ) ? $standardevent['code'][$key] : '';
98
 
99
  ?>
100
 
101
  <tr class="woofp-pageurl-tr <?php echo $hide_standardevent; ?>">
102
+ <th scope="row">Page( Full or Partial URL)</th>
103
  <td>
104
+ <p>
105
+ <input type="text" name="standardevent[pageurl][]" value="<?php echo $pageurl; ?>" class="woofp-input-pageurl" />
106
+ </p>
107
+ <p class="description">This Event will trigger on any URL that contains this string..<br>
108
+ If you add * at the end of the URL string it will match all URLs starting with the URL string.
109
+ </p>
110
+
111
+ <p>
112
+ <b class="event_param">Event Type: </b>
113
  <select name="standardevent[eventtype][]" class="woofp-input-event">
114
+ <option value="">- Select Event -</option>
115
  <?php echo woofp_event_types($eventtype); ?>
116
  </select>
117
+ </p>
118
+
119
+ <p class="standarevent-value">
120
+ <b class="event_param">Value: </b><input type="text" name="standardevent[value][]" value="<?php echo $cartvalue; ?>" class=" woofp-input-value" />
121
+ <span class="woofp-input-desc">&nbsp;&nbsp;*Mandatory for purchase event only.</span>
122
+ </p>
123
+
124
+ <p class="standarevent-currency">
125
+ <b class="event_param">Currency: </b><select name="standardevent[currency][]" class=" woofp-input-currency">
126
  <option value="">Select Currency</option>
127
  <?php echo woofp_currency_options($currency); ?>
128
  </select>
129
+ <span class="woofp-input-desc">&nbsp;&nbsp;*Mandatory for purchase event only.</span>
130
 
 
131
  </p>
132
+
133
+ <div class="standardevent-params">
134
+ <?php
135
+ $woofp_vars = woofp_vars();
136
+ $standardevent_params = woofp_standardevent_extented($eventtype);
137
+ foreach ($standardevent_params as $k => $param) {
138
+ $parame_name = $param['name'];
139
+
140
+ unset($woofp_vars[$parame_name]);
141
+
142
+ $param_value = ( isset( $standardevent[$parame_name][$key] ) ? $standardevent[$parame_name][$key] : '' );
143
+
144
+ ?>
145
+ <div class="event_param_wrap">
146
+ <?php if( $parame_name == 'content_type') { ?>
147
+ <b class="event_param"><?php echo $parame_name; ?>: </b><select name="standardevent[<?php echo $parame_name; ?>][]" >
148
+ <option <?php selected( 'product', $param_value, true ); ?>value="product">product</option>
149
+ <option <?php selected( 'product_group', $param_value, true ); ?>value="product_group">product_group</option>
150
+ </select>
151
+ <?php } else {?>
152
+ <b class="event_param"><?php echo $parame_name; ?>: </b><input type="text" name="standardevent[<?php echo $parame_name; ?>][]" value="<?php echo stripslashes($param_value); ?>" />
153
+ <?php } ?>
154
+ <p class="description"><?php echo $param['info'] . ' i.e ' . $param['example'] ?></p>
155
+ </div>
156
+
157
+ <?php
158
+ }
159
+ ?>
160
+ <?php foreach ($woofp_vars as $woofp_vars_key => $woofp_vars_value) {?>
161
+ <input type="hidden" name="standardevent[<?php echo $woofp_vars_value; ?>][]" value="" style="display:none;" />
162
+ <?php } ?>
163
+ </div>
164
+ <h4>OR add event code here (Advance users only):</h4>
165
+ <textarea style="width:35em;height:180px;" name="standardevent[code][]"><?php echo stripslashes($code); ?></textarea>
166
+ <div class="code_important">
167
+ <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>
168
+ <p class="description"><span class="woofp-asterik">*</span>The code inserted in the field MUST be complete, including fbq('track', 'AddToCart', { …… });</p>
169
+ </div>
170
+
171
  </td>
172
  </tr>
173
 
175
 
176
  }
177
  } else {
178
+
179
+ ?>
180
 
181
  <tr class="woofp-pageurl-tr <?php echo $hide_standardevent; ?>">
182
  <th scope="row">Page(URL or Partial URL)</th>
183
  <td>
184
+
185
+ <p><input type="text" name="standardevent[pageurl][]" value="" class="woofp-input-pageurl" /></p>
186
+ <p class="description">
187
+ This Event will trigger on any URL that contains this string.<br>
188
+ If you add * at the end of the URL string it will match all URLs starting with the URL string.
189
+ </p>
190
+
191
  <p>
192
+ <select name="standardevent[eventtype][]" class="woofp-input-event">
193
+ <option value="">- Select Event -</option>
194
+ <?php echo woofp_event_types(''); ?>
195
+ </select>
196
+ </p>
197
+
198
+ <p class="standarevent-value">
199
+ <b class="event_param">Value: </b><input type="text" name="standardevent[value][]" value="" class=" woofp-input-value" />
200
+ </p>
201
+ <p class="standarevent-currency">
202
+ <b class="event_param">Currency: </b><select name="standardevent[currency][]" class=" woofp-input-currency">
203
  <option value="">Select Currency</option>
204
  <?php echo woofp_currency_options(''); ?>
205
  </select>
 
206
  <span class="woofp-input-desc">*Mandatory for purchase event only.</span>
207
  </p>
208
+ <div class="standardevent-params"></div>
209
+ <h4>OR add event code here (Advance users only):</h4>
210
+ <textarea style="width:35em;height:180px;" name="standardevent[code][]"></textarea>
211
+ <div class="code_important">
212
+ <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>
213
+ <p class="description"><span class="woofp-asterik">*</span>The code inserted in the field MUST be complete, including fbq('track', 'EventName', { …… });</p>
214
+ </div>
215
+
216
  </td>
217
  </tr>
218
 
246
  <?php if( woofp_is_woocommerce() ){ ?>
247
  <table class="form-table">
248
  <tbody>
249
+
250
+ <tr>
251
+ <td colspan="2"><?php echo woofp_admin_notices(true); ?></td>
252
+ </tr>
253
+
254
  <tr>
255
  <th scope="row">&nbsp;</th>
256
+ <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>
257
  </tr>
258
 
259
  <tr>
260
  <th scope="row">&nbsp;</th>
261
+ <td><p><b class="woofpimportant">Don't miss this:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-woocommerce" target="_blank">Read this before activating WooCommerce Setup.</a></p></td>
262
  </tr>
263
 
264
  <tr>
265
  <th scope="row">&nbsp;</th>
266
+ <td><h3 style="float:left;">Activate WooCommerce events</h3>
267
  </td>
268
  </tr>
269
  <?php foreach ( woofp_woocommerce_events() as $key => $woocommerce_event) { ?>
279
 
280
  <tr>
281
  <th scope="row">&nbsp;</th>
282
+ <td style="color:#333;">
283
+ <h2 style="font-weight: 400;color:#333;">Update to the PRO to start tracking conversion value and enable Facebook Dynamic Ads for WooCommerce</h2>
284
+
285
+ <p style="font-weight: 400; font-size:12px; color:#333;">
286
+ The PRO version will pull all the parameters for your WooCommerce events and will enable you to use<br> Facebook Dynamic Ads
287
+ </p>
288
+ <br>
289
+ <b style="font-weight: 400;color:#333;">Track conversion value & Facebook Dynamic Ads for WooCommerce</b>
290
  </td>
291
  </tr>
292
+
293
  <tr>
294
  <th scope="row">&nbsp;</th>
295
+ <td>
296
+ <input type="checkbox" value="1" name="woocommerce_dynamic[ViewContent]" disabled="disabled" /><span class="disabled">Activate ViewContent event for Facebook Dynamic Ads.</span>
297
+ <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>
298
+ <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(any WooCommerce Page)</i></p>
299
+
300
+ </td>
301
  </tr>
302
+
303
  <tr>
304
  <th scope="row">&nbsp;</th>
305
  <td>
306
+ <input type="checkbox" value="1" name="woocommerce_dynamic[AddToCart]" disabled="disabled" /><span class="disabled">Activate AddToCart event for Facebook Dynamic Ads.</span>
307
+ <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>
308
+ <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(Cart Page)</i></p>
309
  </td>
310
  </tr>
311
  <tr>
312
  <th scope="row">&nbsp;</th>
313
  <td>
314
+ <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>
315
+ <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>
316
  <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. </i>(Checkout Page)</i></p>
317
  </td>
318
  </tr>
319
  <tr>
320
  <th scope="row">&nbsp;</th>
321
  <td>
322
+ <input type="checkbox" value="1" name="woocommerce_dynamic[purchase]" disabled="disabled" /><span class="disabled">Activate Purchase event for Facebook Dynamic Ads.</span>
323
+ <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>
324
  <p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(Order Recieved/Thank You Page)</i></p>
325
  </td>
326
  </tr>
327
  <tr>
328
  <th scope="row">&nbsp;</th>
329
  <td>
330
+ <input type="checkbox" value="1" name="woocommerce_dynamic[ProductAddToCart]" disabled="disabled" /><span class="disabled">Activate Product AddToCart event for Facebook Dynamic Ads.</span>
331
+ <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>
332
+ <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>
333
+ </td>
334
+ </tr>
335
+
336
+ <tr>
337
+ <td colspan="2" style="padding:0;"><hr></td>
338
+ </tr>
339
+
340
+ <tr class="affiliate_row">
341
+ <th scope="row">&nbsp;</th>
342
+ <td>
343
+
344
+ <h2 style="font-weight: 400;color:#333;">WooCommerce Affiliate Products Events</h2>
345
+ <p style="font-weight: 400; font-size:12px; color:#333;">It will add a dynamic event on WooCommerce affiliate products buttons</p>
346
+
347
+ <p>
348
+ <label>Affiliate button event:</label>
349
+ <select name="woocommerce_affiliate[affiliate_event]" class="woofp-input-event" disabled="disabled" >
350
+ <?php echo woofp_event_types(''); ?>
351
+ </select>
352
+ </p>
353
+ <span class="woofpbold woofp-or">OR</span>
354
+ <p>
355
+ <label>Name for custom event:</label>
356
+ <input type="text" value="" name="woocommerce_affiliate[affiliate_custom]" disabled="disabled" />
357
+ </p>
358
+ <p>
359
+ <p class="description">*In the PRO version this event will have all the parameters values specific for the selected event.</p>
360
+ <p class="description">*In the PRO version the custom event will have <i>value, currency, content_name, content_type, content_ids</i>.</p>
361
+ </p>
362
+ <br>
363
+ <p>
364
+ <input type="checkbox" value="" name="woocommerce_affiliate[affiliate_value]" disabled="disabled" /><span class="woofpbold"> Event value = Product Price</span>
365
+ If left unchecked the event will not pull product price as event value
366
+ </p>
367
+ <p>
368
+ <label>Global value:</label><input type="text" value="" name="woocommerce_affiliate[affiliate_global]" disabled="disabled" />
369
+ <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>
370
+ </p>
371
+ <br>
372
+
373
+ <br>
374
+ <p>
375
+ <input type="checkbox" value="1" name="woocommerce_affiliate[activate]" disabled="disabled" /><span class="disabled"><span class="woofpbold">Activate WooCommerce Affiliate Products Events.</span></span>
376
+ <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>
377
+ </p>
378
+ </td>
379
+ </tr>
380
+
381
+ <tr>
382
+ <td colspan="2" style="padding:0;"><hr></td>
383
+ </tr>
384
+
385
+ <tr>
386
+ <th scope="row">&nbsp;</th>
387
+ <td>
388
+ <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>
389
+ </td>
390
+ </tr>
391
+
392
+
393
+
394
+ <tr>
395
+ <th scope="row">&nbsp;</th>
396
+ <td>
397
+ <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>
398
+ <p class="description">Check this to enable WooCommerce Setup.</p>
399
  </td>
400
  </tr>
401
+
402
  <tr>
403
  <th scope="row">&nbsp;</th>
404
  <td><input type="button" class="button button-primary woofp-savesettings" value="Save WooCommerce Settings" /></td>
409
  <?php } else { ?>
410
  <div>
411
  <br>
412
+ <p>Please install and activate <b>WooCommerce</b> to enable WooCommerce integration</p>
413
  </div>
414
  <?php } ?>
415
  </div><!-- panel 3 -->
inc/helper-functions.php CHANGED
@@ -95,6 +95,74 @@ function woofp_current_url(){
95
  return $current_url;
96
  }
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  /**
99
  * Return Javascript Code for facebook standard event
100
  * ( With fallback for No Javascript )
@@ -145,26 +213,58 @@ function woofp_page_event(){
145
 
146
  foreach ( $standardevent['pageurl'] as $key => $link) {
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  //if url or event is empty don't go further
149
- if( empty($standardevent['pageurl'][$key]) || empty($standardevent['eventtype'][$key]) )
150
  continue;
151
 
152
- $pageurl = rtrim($standardevent['pageurl'][$key], '/');
153
- $cartvalue = $standardevent['value'][$key];
154
- $currency = $standardevent['currency'][$key];
155
- $eventtype = $standardevent['eventtype'][$key];
156
-
157
 
158
-
 
 
159
 
160
 
 
 
 
 
 
 
 
 
 
161
 
 
162
  //Add pixel event for added url
163
  if( !woofp_is_eventadded( $event_added, $eventtype ) && woofp_match_url($current_url, $pageurl, $eventtype) == 'true' ){
 
164
  $event_added[] = array($current_url, $eventtype );
165
 
 
 
 
166
 
167
- $pixelcode .= "//Standard Event\n" . woofp_get_event( $eventtype, $cartvalue, $currency, 'standardevent') . " \n\n";
 
 
 
 
 
168
  $nojs_pixelcode .= "<!-- Standard Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'standardevent') . " \n\n";
169
 
170
  }
@@ -277,26 +377,118 @@ function woofp_is_eventadded($addedevents, $event){
277
  return $result;
278
  }
279
 
280
- function woofp_get_event($event='', $value=false, $currency='USD', $type=''){
281
 
282
  if( 'ProductAddToCart' == $event )
283
  $event = 'AddToCart';
284
 
 
 
 
 
 
285
  if( 'Purchase' == $event ){
286
 
287
- if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
288
- return "fbq('track', '".$event."', {currency:'".$currency."', value:".$value."});";
289
  else
290
  return "fbq('track', '".$event."', {currency:'USD', value:0.00});";
291
 
 
 
 
 
292
  } else {
293
 
294
- if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
295
- return "fbq('track', '".$event."', {currency:'".$currency."', value:".$value."});";
296
- else
 
297
  return "fbq('track', '".$event."');";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
 
 
 
299
  }
 
 
 
 
 
 
 
 
 
300
  }
301
 
302
  function woofp_get_event_noscript($pixel_id, $event, $type=''){
@@ -379,8 +571,7 @@ if( !is_admin() ){
379
 
380
  $facebookpixel = woofp_admin_settings('facebookpixel');
381
  $facebookpixel_code = woofp_page_event();
382
-
383
- if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 && '' != $facebookpixel_code[0] ) {
384
  ?>
385
 
386
 
@@ -397,6 +588,7 @@ var PYS_DOMReady = function(a,b,c){b=document,c='addEventListener';b[c]?b[c]('DO
397
  PYS_DOMReady(function(){
398
 
399
  <?php
 
400
  echo $facebookpixel_code[0];
401
  ?>
402
 
@@ -487,8 +679,12 @@ function woofp_addtocart_urls($woofp_options=''){
487
  function woofp_addtocart_pixel(){
488
 
489
 
490
- //
 
491
 
 
 
 
492
  ?>
493
 
494
  <!-- noscript facebook pixel -->
@@ -497,24 +693,12 @@ function woofp_addtocart_pixel(){
497
  $facebookpixel_code = woofp_page_event();
498
  echo $facebookpixel_code[1];
499
  ?>
500
-
501
  <!-- end noscript facebook pixel -->
502
 
503
- <?php
504
- //Run AddToCart Event when product are added using ajax
505
- //todo: woocommerce_cart_redirect_after_add
506
-
507
- $woofp_options = get_option('woofp_admin_settings');
508
- $facebookpixel = $woofp_options['facebookpixel'];
509
- $standardevent = $woofp_options['standardevent'];
510
- $woocommerce_settings = $woofp_options['woocommerce'];
511
-
512
-
513
-
514
- ?>
515
  <!-- Dynamic AddToCart when Ajax enabled on Woocommerce -->
516
  <?php
517
 
 
518
  if ( get_option( 'woocommerce_enable_ajax_add_to_cart' ) == 'yes' && ( is_woocommerce() || is_page() || is_single() ) ) {
519
 
520
  $php_array = woofp_addtocart_urls($woofp_options);
@@ -530,6 +714,7 @@ jQuery(function($){
530
 
531
  //Run AddToCart Event when product are added using ajax
532
  var woofp_addtocart_btn = "a.add_to_cart_button:not('.product_type_variable')";
 
533
  jQuery(document).on( 'click', woofp_addtocart_btn, function(e) {
534
 
535
 
@@ -573,7 +758,12 @@ jQuery(document).on( 'click', woofp_addtocart_btn, function(e) {
573
 
574
  });
575
  </script>
576
- <?php }
 
 
 
 
 
577
  }
578
 
579
 
@@ -656,7 +846,7 @@ function woofp_woocommerce_events(){
656
  array(
657
  'event' => 'ViewContent',
658
  'page' => 'woocommerce_view_content',
659
- 'title' => 'Any WooCommerce Page',
660
  'label' => 'ViewContent Event'
661
  ),
662
 
@@ -670,7 +860,7 @@ function woofp_woocommerce_events(){
670
  array(
671
  'event' => 'AddToCart',
672
  'page' => 'woocommerce_cart_page_id',
673
- 'title' => 'AddToCart Page',
674
  'label' => 'AddToCart Event'
675
  ),
676
  array(
@@ -890,3 +1080,147 @@ function woofp_is_woocommerce(){
890
  }
891
 
892
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 )
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
  }
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=''){
571
 
572
  $facebookpixel = woofp_admin_settings('facebookpixel');
573
  $facebookpixel_code = woofp_page_event();
574
+ if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 && '' != $facebookpixel_code[0] ){
 
575
  ?>
576
 
577
 
588
  PYS_DOMReady(function(){
589
 
590
  <?php
591
+
592
  echo $facebookpixel_code[0];
593
  ?>
594
 
679
  function woofp_addtocart_pixel(){
680
 
681
 
682
+ $woofp_options = get_option('woofp_admin_settings');
683
+
684
 
685
+
686
+ /* whether facebook pixel is activated */
687
+ if( 1 == woofp_get_option('facebookpixel', 'activate') && 1 == woofp_get_option('woocommerce', 'activate') ){
688
  ?>
689
 
690
  <!-- noscript facebook pixel -->
693
  $facebookpixel_code = woofp_page_event();
694
  echo $facebookpixel_code[1];
695
  ?>
 
696
  <!-- end noscript facebook pixel -->
697
 
 
 
 
 
 
 
 
 
 
 
 
 
698
  <!-- Dynamic AddToCart when Ajax enabled on Woocommerce -->
699
  <?php
700
 
701
+
702
  if ( get_option( 'woocommerce_enable_ajax_add_to_cart' ) == 'yes' && ( is_woocommerce() || is_page() || is_single() ) ) {
703
 
704
  $php_array = woofp_addtocart_urls($woofp_options);
714
 
715
  //Run AddToCart Event when product are added using ajax
716
  var woofp_addtocart_btn = "a.add_to_cart_button:not('.product_type_variable')";
717
+
718
  jQuery(document).on( 'click', woofp_addtocart_btn, function(e) {
719
 
720
 
758
 
759
  });
760
  </script>
761
+ <?php
762
+ }
763
+
764
+ } /* is woocommerce active */
765
+
766
+
767
  }
768
 
769
 
846
  array(
847
  'event' => 'ViewContent',
848
  'page' => 'woocommerce_view_content',
849
+ 'title' => 'Single Product Pages',
850
  'label' => 'ViewContent Event'
851
  ),
852
 
860
  array(
861
  'event' => 'AddToCart',
862
  'page' => 'woocommerce_cart_page_id',
863
+ 'title' => 'Cart Page',
864
  'label' => 'AddToCart Event'
865
  ),
866
  array(
1080
  }
1081
 
1082
  }
1083
+
1084
+
1085
+ function woofp_filter_standardevent_args($event, $args){
1086
+
1087
+ $temp_args = woofp_standardevent_extented($event);
1088
+
1089
+ if( !empty($temp_args) && !empty($args) ){
1090
+ $new_args = array();
1091
+ foreach ($temp_args as $ta => $ta_value) {
1092
+
1093
+ $name = $ta_value['name'];
1094
+ $new_args[$name] = $args[$name];
1095
+
1096
+ }
1097
+
1098
+ $new_args['currency'] = $args['currency'];
1099
+ $new_args['value'] = $args['value'];
1100
+
1101
+ return $new_args;
1102
+ }
1103
+
1104
+ return $args;
1105
+ }
1106
+
1107
+
1108
+ function woofp_vars(){
1109
+ $vars = array();
1110
+
1111
+ $vars['content_name'] = 'content_name';
1112
+ $vars['content_category'] = 'content_category';
1113
+ $vars['content_ids'] = 'content_ids';
1114
+ $vars['content_type'] = 'content_type';
1115
+ $vars['search_string'] = 'search_string';
1116
+ $vars['num_items'] = 'num_items';
1117
+ $vars['order_id'] = 'order_id';
1118
+ $vars['status'] = 'status';
1119
+
1120
+ return $vars;
1121
+ }
1122
+
1123
+ function woofp_standardevent_extented($event){
1124
+
1125
+
1126
+ $params = array();
1127
+
1128
+ if(
1129
+ $event == 'ViewContent'
1130
+ || $event == 'AddToCart'
1131
+ || $event == 'AddToWishlist'
1132
+ || $event == 'InitiateCheckout'
1133
+ || $event == 'Purchase'
1134
+ || $event == 'Lead'
1135
+ || $event == 'CompleteRegistration' ){
1136
+
1137
+ $name = 'content_name';
1138
+ $example = "'Really Fast Running Shoes'";
1139
+ $info = "Name of the page/product";
1140
+ $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1141
+ }
1142
+
1143
+
1144
+ if(
1145
+ $event == 'Search'
1146
+ || $event == 'AddToWishlist'
1147
+ || $event == 'InitiateCheckout'
1148
+ || $event == 'AddPaymentInfo'
1149
+ || $event == 'Lead' ){
1150
+
1151
+ $name = 'content_category';
1152
+ $example = "'Apparel & Accessories > Shoes'";
1153
+ $info = "Category of the page/product.";
1154
+ $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1155
+
1156
+ }
1157
+
1158
+ if(
1159
+ $event == 'ViewContent'
1160
+ || $event == 'Search'
1161
+ || $event == 'AddToCart'
1162
+ || $event == 'AddToWishlist'
1163
+ || $event == 'InitiateCheckout'
1164
+ || $event == 'AddPaymentInfo'
1165
+ || $event == 'Purchase' ){
1166
+
1167
+ $name = 'content_ids';
1168
+ $example = "['1234']";
1169
+ $info = "Product ids/SKUs associated with the event.";
1170
+ $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1171
+
1172
+ }
1173
+
1174
+
1175
+
1176
+ if(
1177
+ $event == 'ViewContent'
1178
+ || $event == 'AddToCart'
1179
+ || $event == 'InitiateCheckout'
1180
+ || $event == 'Purchase' ){
1181
+
1182
+ $name = 'content_type';
1183
+ $example = "'product' or 'product_group'";
1184
+ $info = "The type of content_ids.";
1185
+ $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1186
+ }
1187
+
1188
+
1189
+
1190
+ if( $event == 'Search' ) {
1191
+
1192
+ $name = 'search_string';
1193
+ $example = "'Shoes'";
1194
+ $info = "The string entered by the user for the search.";
1195
+ $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1196
+
1197
+ }
1198
+
1199
+ if(
1200
+ $event == 'Purchase'
1201
+ || $event == 'InitiateCheckout' ){
1202
+
1203
+ $name = 'num_items';
1204
+ $example = "'3'";
1205
+ $info = "The number of items in the cart.";
1206
+ $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1207
+ }
1208
+
1209
+ if( $event == 'Purchase' ){
1210
+
1211
+ $name = 'order_id';
1212
+ $example = "19";
1213
+ $info = "The unique order id of the successful purchase.";
1214
+ $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1215
+ }
1216
+
1217
+ if( $event == 'CompleteRegistration' ){
1218
+
1219
+ $name = 'status';
1220
+ $example = "completed";
1221
+ $info = "The status of the registration.";
1222
+ $params[] = array('name'=>$name, 'example'=>$example, 'info'=>$info );
1223
+ }
1224
+
1225
+ return $params;
1226
+ }
js/admin.js CHANGED
@@ -6,8 +6,8 @@ jQuery(function($){
6
 
7
  event.preventDefault();
8
  var i = $(this).attr('id').replace('facebook-pixel-menu-', '');
9
- $('.facebook-pixel-body ul li').removeClass('selected');
10
- $(this).addClass('selected');
11
 
12
  $('.facebook-pixel-panel').hide();
13
  $('#facebook-pixel-panel-'+i).show();
@@ -72,24 +72,45 @@ jQuery(function($){
72
  event.preventDefault();
73
  var events_options = $('tr.woofp-pageurl-tr:first td:first select.woofp-input-event').html();
74
  var currencty_options = $('tr.woofp-pageurl-tr:first td:first select.woofp-input-currency').html();
75
-
76
  var html = '';
 
 
 
77
  html += '<tr class="woofp-pageurl-tr">';
78
  html += '<th scope="row">Page(URL or Partial URL)</th>';
79
  html += '<td>';
80
- html += '<input type="text" name="standardevent[pageurl][]" value="" class="woofp-input-pageurl" />';
81
- html += '<select name="standardevent[eventtype][]">';
 
 
 
 
 
 
82
  html += events_options;
83
  html += '</select>';
84
- html += '<p>';
85
- html += 'Value:<input type="text" name="standardevent[value][]" value="" class=" woofp-input-value" />';
86
- html += 'Currency:<select name="standardevent[currency][]" class=" woofp-input-currency">';
87
- html += '<option value="">Select Currency</option>';
 
 
 
 
 
88
  html += currencty_options;
89
  html += '</select>';
90
- html += '<span class="woofp-input-desc">*Mandatory for purchase event only.</span>';
91
  html += '</p>';
92
- html += '<p class="description">This Event will trigger on any URL that contains this string.</p>';
 
 
 
 
 
 
 
93
  html += '</td>';
94
  html += '</tr>';
95
 
@@ -98,8 +119,30 @@ jQuery(function($){
98
  $this.closest('tr').before(html).hide().fadeIn();
99
  woofp_removebutton();
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  });
102
 
 
 
 
 
 
 
 
103
  /*
104
  Save Settings
105
  */
@@ -153,4 +196,197 @@ jQuery(function($){
153
  });
154
 
155
 
156
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  event.preventDefault();
8
  var i = $(this).attr('id').replace('facebook-pixel-menu-', '');
9
+ $('.facebook-pixel-body ul li').removeClass('nav-tab-active selected');
10
+ $(this).addClass('nav-tab-active selected');
11
 
12
  $('.facebook-pixel-panel').hide();
13
  $('#facebook-pixel-panel-'+i).show();
72
  event.preventDefault();
73
  var events_options = $('tr.woofp-pageurl-tr:first td:first select.woofp-input-event').html();
74
  var currencty_options = $('tr.woofp-pageurl-tr:first td:first select.woofp-input-currency').html();
75
+ var extentedoption = '';
76
  var html = '';
77
+
78
+
79
+
80
  html += '<tr class="woofp-pageurl-tr">';
81
  html += '<th scope="row">Page(URL or Partial URL)</th>';
82
  html += '<td>';
83
+
84
+ html += '<p><input type="text" name="standardevent[pageurl][]" value="" class="woofp-input-pageurl" /></p>';
85
+ html += '<p class="description">This Event will trigger on any URL that contains this string.<br>';
86
+ html += 'If you add * at the end of the URL string it will match all URLs starting with the URL string.</p>';
87
+
88
+ html += '<p>';
89
+ html += '<b class="event_param">Event Type: </b>';
90
+ html += '<select name="standardevent[eventtype][]" class="woofp-input-event">';
91
  html += events_options;
92
  html += '</select>';
93
+ html += '</p>';
94
+
95
+ html += '<p class="standarevent-value">';
96
+ html += '<b class="event_param">Value: </b><input type="text" name="standardevent[value][]" value="" class=" woofp-input-value" />';
97
+ html += '<span class="woofp-input-desc">&nbsp;&nbsp;*Mandatory for purchase event only.</span>';
98
+ html += '</p>';
99
+
100
+ html += '<p class="standarevent-currency">';
101
+ html += '<b class="event_param">Currency: </b><select name="standardevent[currency][]" class=" woofp-input-currency">';
102
  html += currencty_options;
103
  html += '</select>';
104
+ html += '<span class="woofp-input-desc">&nbsp;&nbsp;*Mandatory for purchase event only.</span>';
105
  html += '</p>';
106
+
107
+ html += '<div class="standardevent-params"></div>';
108
+ html += '<h4>OR add Event Code here (Advances users only):</h4>';
109
+ html += '<textarea style="width:35em;height:180px;" name="standardevent[code][]"></textarea>';
110
+ html += '<div class="code_important">';
111
+ html += '<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>';
112
+ html += '<p class="description"><span class="woofp-asterik">*</span>The code inserted in the field MUST be complete, including fbq(\'track\', \'AddToCart\', { …… });</p>';
113
+ html += '</div>';
114
  html += '</td>';
115
  html += '</tr>';
116
 
119
  $this.closest('tr').before(html).hide().fadeIn();
120
  woofp_removebutton();
121
 
122
+ //select newly created tr
123
+ var new_element = $('tr.woofp-pageurl-tr').last();
124
+
125
+ //reset event select
126
+ new_element.find('select option:eq(0)').prop('selected', true);
127
+
128
+ //scroll to newly created element.
129
+ var offset = new_element.offset().top;
130
+
131
+ $('body, html').animate({ scrollTop: parseInt(offset) - 100 }, 1000);
132
+ // do fading 3 times
133
+ for(i=0;i<3;i++) {
134
+ new_element.fadeTo('fast', 0.3).fadeTo('fast', 1.0);
135
+ }
136
+
137
  });
138
 
139
+
140
+
141
+ function woofp_vars(){
142
+ var vars = ['content_name','content_category','content_ids','content_type','search_string','num_items','order_id','status'];
143
+ return vars;
144
+ }
145
+
146
  /*
147
  Save Settings
148
  */
196
  });
197
 
198
 
199
+ $('#facebook-pixel-panel-2 .woofp-pageurl-tr td').each(function(index, el) {
200
+
201
+
202
+ var td = $(this);
203
+ var val = td.find('select.woofp-input-event option:selected').val();
204
+
205
+
206
+ if( val != '' ){
207
+ td.find('.standarevent-value').show();
208
+ td.find('.standarevent-currency').show();
209
+ } else {
210
+
211
+ td.find('.standarevent-value').hide();
212
+ td.find('.standarevent-currency').hide();
213
+ }
214
+
215
+ });
216
+
217
+
218
+
219
+ $(document).on('change', 'select.woofp-input-event', function(e){
220
+
221
+
222
+ var val = $(this).val();
223
+
224
+ if( val == '' )
225
+ return false;
226
+
227
+ var params = woofp_standardevent_extented(val);
228
+ var params_vars = woofp_vars();
229
+
230
+ console.log(params);
231
+
232
+ var html = '';
233
+ var i = 0;
234
+ for (var key in params) {
235
+ if (params.hasOwnProperty(key)) {
236
+
237
+
238
+
239
+ var param = params[key];
240
+
241
+
242
+ if( param != undefined && param != '' ){
243
+
244
+ for(var i = 0; i < params_vars.length; i++){
245
+
246
+ if (params_vars[i] === param.name) params_vars.splice(i, 1);
247
+ }
248
+
249
+
250
+ html +='<div class="event_param_wrap">';
251
+
252
+ if( param.name == 'content_type')
253
+ html +='<b class="event_param">'+param.name+': </b><select name="standardevent['+param.name+'][]" ><option value="product">product</option><option value="product_group">product_group</option></select>';
254
+ else
255
+ html +='<b class="event_param">'+param.name+': </b><input type="text" name="standardevent['+param.name+'][]" value="" />';
256
+
257
+
258
+
259
+ html +='<p class="description">'+param.info+' i.e '+param.example+'</p>';
260
+ html +='</div>';
261
+ }
262
+
263
+ }
264
+
265
+
266
+ }
267
+
268
+ var hidden_params = '';
269
+
270
+ for(var i= 0; i < params_vars.length; i++){
271
+ var param = params_vars[i];
272
+ hidden_params +='<input type="hidden" name="standardevent['+param+'][]" value="" style="display:none;" />';
273
+ }
274
+
275
+ var tr = $(this).closest('tr');
276
+ tr.find('.standardevent-params').html(html + hidden_params);
277
+
278
+ tr.find('.standarevent-value').show();
279
+ tr.find('.standarevent-currency').show();
280
+
281
+ });
282
+
283
+ function woofp_standardevent_extented(event){
284
+
285
+
286
+ var params = {};
287
+ params['0'] = params['1'] = params['2'] = params['3'] = '';
288
+ params['4'] = params['5'] = params['6'] = params['7'] = '';
289
+
290
+ if(
291
+ event == 'ViewContent'
292
+ || event == 'AddToCart'
293
+ || event == 'AddToWishlist'
294
+ || event == 'InitiateCheckout'
295
+ || event == 'Purchase'
296
+ || event == 'Lead'
297
+ || event == 'CompleteRegistration' ){
298
+
299
+ var name = 'content_name';
300
+ var example = "'Really Fast Running Shoes'";
301
+ var info = "Name of the page/product";
302
+ params[0] = { name:name, example:example, info:info}
303
+ }
304
+
305
+
306
+ if(
307
+ event == 'Search'
308
+ || event == 'AddToWishlist'
309
+ || event == 'InitiateCheckout'
310
+ || event == 'AddPaymentInfo'
311
+ || event == 'Lead' ){
312
+
313
+ var name = 'content_category';
314
+ var example = "'Apparel & Accessories > Shoes'";
315
+ var info = "Category of the page/product.";
316
+ params[1] = { name:name, example:example, info:info}
317
+
318
+ }
319
+
320
+ if(
321
+ event == 'ViewContent'
322
+ || event == 'Search'
323
+ || event == 'AddToCart'
324
+ || event == 'AddToWishlist'
325
+ || event == 'InitiateCheckout'
326
+ || event == 'AddPaymentInfo'
327
+ || event == 'Purchase' ){
328
+
329
+ var name = 'content_ids';
330
+ var example = "['1234']";
331
+ var info = "Product ids/SKUs associated with the event.";
332
+ params[2] = { name:name, example:example, info:info}
333
+
334
+ }
335
+
336
+
337
+
338
+ if(
339
+ event == 'ViewContent'
340
+ || event == 'AddToCart'
341
+ || event == 'InitiateCheckout'
342
+ || event == 'Purchase' ){
343
+
344
+ var name = 'content_type';
345
+ var example = "'product' or 'product_group'";
346
+ var info = "The type of content_ids.";
347
+ params[3] = { name:name, example:example, info:info}
348
+ }
349
+
350
+
351
+
352
+ if( event == 'Search' ) {
353
+
354
+ var name = 'search_string';
355
+ var example = "'Shoes'";
356
+ var info = "The string entered by the user for the search.";
357
+ params[4] = { name:name, example:example, info:info}
358
+
359
+ }
360
+
361
+ if(
362
+ event == 'Purchase'
363
+ || event == 'InitiateCheckout' ){
364
+
365
+ var name = 'num_items';
366
+ var example = "'3'";
367
+ var info = "The number of items in the cart.";
368
+ params[5] = { name:name, example:example, info:info}
369
+ }
370
+
371
+ if( event == 'Purchase' ){
372
+
373
+ var name = 'order_id';
374
+ var example = "19";
375
+ var info = "The unique order id of the successful purchase.";
376
+ params[6] = { name:name, example:example, info:info}
377
+ }
378
+
379
+ if( event == 'CompleteRegistration' ){
380
+
381
+ var name = 'status';
382
+ var example = "completed";
383
+ var info = "The status of the registration.";
384
+ params[7] = { name:name, example:example, info:info}
385
+ }
386
+
387
+ return params;
388
+ }
389
+
390
+
391
+
392
+ }); /* Dom Loaded */
readme.txt CHANGED
@@ -1,16 +1,16 @@
1
  === PixelYourSite: Insert Facebook Pixel and track Standard Events ===
2
  Contributors: PixelYourSite, c0d3fev3r
3
- Tags: Facebook Pixel, Facebook, Facebook Conversion Pixel, Facebook Pixel Events, tracking, standard events, Facebook Events, Facebook Standard Events, New Facebook Pixel, Facebook Dynamic Ads, WooCommerce, Facebook Custom Events, Custom Events, conversion pixel, track conversion, Facebook pixel WooCommerce, Facebook Ads, Facebook Campaign, Facebook Ads Campaign, Facebook Conversion Value, Conversion Value
4
  Requires at least: 3.0.1
5
- Tested up to: 4.4
6
- Stable tag: 1.05.1
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
10
- Insert Facebook Pixel, add standard events, or activate WooCommerce events with just a few clicks (Purchase, ViewContent, AddToCart, InitiateCheckout)
11
 
12
  == Description ==
13
- As you probably know, Facebook will retire the old Facebook Conversion Pixel in 2016. They recommend to use the new Facebook Pixel for conversion tracking, optimization and remarketing. **This plugin will help you insert the pixel code on every page with just one click, setup standard events and add them value or currency**. There is an **out of the box setup for Woocommerce** that will configure all the necessary standard events for you.
14
 
15
  **There is a Special Offer for the PRO version that will exiper soon. You'll get more details and a secret link inside the plugin admin area.**
16
 
@@ -18,18 +18,22 @@ As you probably know, Facebook will retire the old Facebook Conversion Pixel in
18
 
19
  * You can **insert the pixel on every page of your website with just a few clicks**. No need to edit any post or pages
20
 
21
- * You can **set up and track Standard Events** and add parameters for each of them
22
 
23
- * Track **conversion value** for standard events
24
 
25
- * You can **insert the Facebook pixel and start tracking events on any Woocommerce** website with just a few clicks (Purchase, ViewContent, AddToCart, InitiateCheckout)
26
 
27
  * **Dynamic AddToCart** is fully supported (the AddToCart event will fire on add to cart button click)
28
 
 
 
29
  * **Track conversion value for WooCommerce** (<a href="http://www.pixelyoursite.com" target="_blank">Pro Version</a>)
30
 
31
  * Out of the box **Facebook Dynamic Ads** setup for your Woocommerce website (<a href="http://www.pixelyoursite.com" target="_blank">Pro Version</a>)
32
 
 
 
33
  **Important**
34
 
35
  If you are testing your pixel with Pixel Helper Chrome extension you will see some **false** errors:
@@ -41,13 +45,10 @@ You can safely ignore them. It is a normal error trigger by the dynamic AddToCar
41
 
42
  **What's next**
43
 
44
- We are already testing version 1.1 of the FREE plugin, and it will be really cool:
45
 
46
- 1. You will have a lot more control over standard events, with the possibility to define every type of parameter for each of your events (value, currency, content_name, content_ids, content_type, content_category)
47
 
48
- 2. You will be able to define custom events on any URL of your website.
49
-
50
- 3. Search event will pass the search_string by default
51
 
52
 
53
  <p style="text-align: center;">Visit this page for <strong><a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank"><span style="color:#DE4D4D;">more&nbsp;details about how to use the plugin: Click Here</span></a></strong></p>
@@ -82,34 +83,41 @@ We maintain an up to date FAQ page on our site:
82
  <strong><a href="http://www.pixelyoursite.com/facebool-pixel-master-faq" target="_blank"><span style="color:#DE4D4D;">Click here for the FAQ page</span></a></strong>
83
 
84
  == Changelog ==
85
- PixelYourSite 1.01
86
 
87
- - Dynamic AddToCart event for WooCommerce (the AddToCart event will trigger when a users click on the add to cart button)
88
- - Dynamic AddToCart works with WooCommerce shortcodes.
89
- - Fixed a false error that was reported for the Purchase WooCommerce event by Pixel Helper extension on the Thank You page.
90
 
91
- PixelYourSite 1.02
92
 
93
- - Fixed currency symbol error
94
- - Added super special offer for the PRO version
95
 
96
- PixelYourSite 1.03
97
 
98
- - Fixed "Select options" error for variable products on categories pages
 
 
 
 
99
 
100
  PixelYourSite 1.04
101
 
102
  - Fixed fresh install error (when no settings saved)
103
 
104
- PixelYourSite 1.05
105
 
106
- - Updated offer for the PRO version
 
 
107
 
108
- PixelYourSite 1.05.1
 
 
 
 
 
 
 
109
 
110
- - Fixing a possible minification error
111
- - Adding a new contributor for the plugin
112
 
113
  == Upgrade Notice ==
114
 
115
- This update is pushing a fix for a possible minification conflict.
1
  === PixelYourSite: Insert Facebook Pixel and track Standard Events ===
2
  Contributors: PixelYourSite, c0d3fev3r
3
+ Tags: Facebook Pixel, Facebook, Facebook Conversion Pixel, Facebook Pixel Events, tracking, standard events, Facebook Events, Facebook Standard Events, New Facebook Pixel, Facebook Dynamic Ads, WooCommerce, Facebook Custom Events, Custom Events, conversion pixel, track conversion, Facebook pixel WooCommerce, Facebook Ads, Facebook Campaign, Facebook Ads Campaign, Facebook Conversion Value, Conversion Value, WooCommerce Affiliate Products, Track Affiliate Products, Affiliate links
4
  Requires at least: 3.0.1
5
+ Tested up to: 4.4.1
6
+ Stable tag: 2.0
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
10
+ Insert Facebook Pixel, add Custom or Standard Events, activate WooCommerce events with just a few clicks, WooCommerce Affiliate Products events
11
 
12
  == Description ==
13
+ As you probably know, Facebook will retire the old Facebook Conversion Pixel in 2016. They recommend to use the new Facebook Pixel for conversion tracking, optimization and remarketing. **This plugin will help you insert the pixel code on every page with just one click and setup custom or standard events on any page or post.** There is an **out of the box WooCommerce setup** that will configure all the necessary standard events for you.
14
 
15
  **There is a Special Offer for the PRO version that will exiper soon. You'll get more details and a secret link inside the plugin admin area.**
16
 
18
 
19
  * You can **insert the pixel on every page of your website with just a few clicks**. No need to edit any post or pages
20
 
21
+ * You can **set up and track Standard or Custom Events** and add parameters for each of them
22
 
23
+ * Track **conversion value** for standard or custom events
24
 
25
+ * You can **insert the Facebook pixel and start tracking events on any WooCommerce** website with just a few clicks (Purchase, ViewContent, AddToCart, InitiateCheckout)
26
 
27
  * **Dynamic AddToCart** is fully supported (the AddToCart event will fire on add to cart button click)
28
 
29
+ * **Search Event** on the search page
30
+
31
  * **Track conversion value for WooCommerce** (<a href="http://www.pixelyoursite.com" target="_blank">Pro Version</a>)
32
 
33
  * Out of the box **Facebook Dynamic Ads** setup for your Woocommerce website (<a href="http://www.pixelyoursite.com" target="_blank">Pro Version</a>)
34
 
35
+ * **WooCommerce Affiliate Products Events:** you can add a dynamic event that will trigger on affiliate button clicks (<a href="http://www.pixelyoursite.com" target="_blank">Pro Version</a>)
36
+
37
  **Important**
38
 
39
  If you are testing your pixel with Pixel Helper Chrome extension you will see some **false** errors:
45
 
46
  **What's next**
47
 
 
48
 
49
+ 1. **PayPal integration**
50
 
51
+ 2. More control for WooCommerce variable products events - some cool new things comming soon
 
 
52
 
53
 
54
  <p style="text-align: center;">Visit this page for <strong><a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank"><span style="color:#DE4D4D;">more&nbsp;details about how to use the plugin: Click Here</span></a></strong></p>
83
  <strong><a href="http://www.pixelyoursite.com/facebool-pixel-master-faq" target="_blank"><span style="color:#DE4D4D;">Click here for the FAQ page</span></a></strong>
84
 
85
  == Changelog ==
 
86
 
87
+ PixelYourSite 2.0
 
 
88
 
89
+ - This update adds full control on Standard Events, with the possibility to define all the availeable parameters for each event
90
 
91
+ - You can also add the code for each event with the new event text field. This also lets you define custom events
 
92
 
93
+ - WooCommerce Affiliate Products events: you can define events that will trigger on affiliate buttons clicks
94
 
95
+ - Fixed a potential error for the WooCommerce Purchase Event
96
+
97
+ PixelYourSite 1.05
98
+
99
+ - Updated offer for the PRO version
100
 
101
  PixelYourSite 1.04
102
 
103
  - Fixed fresh install error (when no settings saved)
104
 
105
+ PixelYourSite 1.03
106
 
107
+ - Fixed "Select options" error for variable products on categories pages
108
+
109
+ PixelYourSite 1.02
110
 
111
+ - Fixed currency symbol error
112
+ - Added super special offer for the PRO version
113
+
114
+ PixelYourSite 1.01
115
+
116
+ - Dynamic AddToCart event for WooCommerce (the AddToCart event will trigger when a users click on the add to cart button)
117
+ - Dynamic AddToCart works with WooCommerce shortcodes.
118
+ - Fixed a false error that was reported for the Purchase WooCommerce event by Pixel Helper extension on the Thank You page.
119
 
 
 
120
 
121
  == Upgrade Notice ==
122
 
123
+ New Cool features (more control for Standard Events, WooCommerce Affiliate Products Events + some important fixes). Update Now!