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

Version Description

Download this release

Release Info

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

Code changes from version 1.03 to 1.04

facebook-pixel-master.php CHANGED
@@ -5,7 +5,7 @@ Description: Add the Facebook Pixel code into your Wordpress site and set up sta
5
  Plugin URI: http://www.pixelyoursite.com/free
6
  Author: PixelYourSite
7
  Author URI: http://www.pixelyoursite.com
8
- Version: 1.03
9
  License: GPLv3
10
  */
11
 
5
  Plugin URI: http://www.pixelyoursite.com/free
6
  Author: PixelYourSite
7
  Author URI: http://www.pixelyoursite.com
8
+ Version: 1.04
9
  License: GPLv3
10
  */
11
 
inc/helper-functions.php CHANGED
@@ -107,19 +107,20 @@ function woofp_page_event(){
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";
@@ -243,9 +244,7 @@ function woofp_page_event(){
243
 
244
  }/* facebook pixel activated */
245
 
246
- $pixelcode .= "\n";
247
- $nojs_pixelcode .= "\n";
248
-
249
  return array($pixelcode, $nojs_pixelcode);
250
  }
251
 
@@ -379,8 +378,9 @@ function woofp_pixelcode(){
379
  if( !is_admin() ){
380
 
381
  $facebookpixel = woofp_admin_settings('facebookpixel');
 
382
 
383
- if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 ) {
384
  ?>
385
 
386
 
@@ -397,7 +397,6 @@ var PYS_DOMReady = function(a,b,c){b=document,c='addEventListener';b[c]?b[c]('DO
397
  PYS_DOMReady(function(){
398
 
399
  <?php
400
- $facebookpixel_code = woofp_page_event();
401
  echo $facebookpixel_code[0];
402
  ?>
403
 
@@ -528,30 +527,12 @@ 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
- if ( jQuery(this).attr('class').indexOf( 'product_type_variable' ) > 1 ) {
551
- return true;
552
- }
553
 
554
- e.preventDefault();
555
 
556
  var current_url = jQuery(this).attr('href') || '';
557
  var product_id = jQuery(this).attr('data-product_id') || 0;
@@ -564,23 +545,29 @@ jQuery(document).on( 'click', '.add_to_cart_button', function(e) {
564
  }
565
 
566
 
 
 
567
 
568
- for (i = 0; i < url_array.length; i++) {
569
-
570
- if( url_array[i] == '***' ){
571
 
572
-
573
- fbq('track', 'AddToCart');
 
574
 
575
- } else if( current_url.search(url_array[i]) !== -1 ){
 
 
 
576
 
577
-
578
- fbq('track', 'AddToCart');
579
-
580
- }
581
 
582
- }
583
 
 
 
584
 
585
  });
586
 
107
  $facebookpixel = woofp_admin_settings('facebookpixel');
108
  $standardevent = woofp_admin_settings('standardevent');
109
  $woocommerce_settings = woofp_admin_settings('woocommerce');
110
+ $pixel_id = isset($facebookpixel['ID']) ? $facebookpixel['ID'] : '';
111
 
112
  $pixelcode = "";
113
+ $nojs_pixelcode = "";
114
 
115
  /* whether facebook pixel is activated */
116
+ if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 && '' != $pixel_id ){
117
 
118
+
119
  $current_url = woofp_current_url();
120
  $event_added = array();
121
 
122
 
123
+
124
 
125
  $pixelcode .= "\n";
126
  $nojs_pixelcode .= "\n";
244
 
245
  }/* facebook pixel activated */
246
 
247
+
 
 
248
  return array($pixelcode, $nojs_pixelcode);
249
  }
250
 
378
  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
  PYS_DOMReady(function(){
398
 
399
  <?php
 
400
  echo $facebookpixel_code[0];
401
  ?>
402
 
527
 
528
  jQuery(function($){
529
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
 
 
536
 
537
  var current_url = jQuery(this).attr('href') || '';
538
  var product_id = jQuery(this).attr('data-product_id') || 0;
545
  }
546
 
547
 
548
+ var code_exists = false;
549
+ if( url_array != null && url_array != '' ){
550
 
551
+ e.preventDefault();
 
 
552
 
553
+ for (i = 0; i < url_array.length; i++) {
554
+
555
+ if( url_array[i] == '***' && code_exists == false ){
556
 
557
+ code_exists = true;
558
+ fbq('track', 'AddToCart');
559
+ return false;
560
+ } else if( current_url.search(url_array[i]) !== -1 && code_exists == false ){
561
 
562
+ code_exists = true;
563
+ fbq('track', 'AddToCart');
564
+ return false;
565
+ }
566
 
567
+ }
568
 
569
+ } /* url_array != null */
570
+
571
 
572
  });
573
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: PixelYourSite
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
4
  Requires at least: 3.0.1
5
  Tested up to: 4.4
6
- Stable tag: 1.03
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -95,6 +95,10 @@ PixelYourSite 1.03
95
 
96
  - Fixed "Select options" error for variable products on categories pages
97
 
 
 
 
 
98
 
99
  == Upgrade Notice ==
100
- Important update: Error fix for "Select options" variable product button on category pages. Please update now!
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
4
  Requires at least: 3.0.1
5
  Tested up to: 4.4
6
+ Stable tag: 1.04
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
95
 
96
  - Fixed "Select options" error for variable products on categories pages
97
 
98
+ PixelYourSite 1.04
99
+
100
+ - Fixed fresh install error (when no settings saved)
101
+
102
 
103
  == Upgrade Notice ==
104
+ Important update: This new version fixes an error that was pressent when the plugin was first time activated and had no settings saved. Please Update Now!