Version Description
Download this release
Release Info
Developer | PixelYourSite |
Plugin | PixelYourSite – Facebook Pixel (Events, WooCommerce & Easy Digital Downloads) |
Version | 5.0.1 |
Comparing to | |
See all releases |
Code changes from version 5.0.0 to 5.0.1
- facebook-pixel-master.php +6 -10
- inc/common.php +83 -36
- inc/core.php +37 -19
- readme.txt +7 -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: 5.0.
|
9 |
License: GPLv3
|
10 |
*/
|
11 |
|
@@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
13 |
exit; // Exit if accessed directly.
|
14 |
}
|
15 |
|
16 |
-
define( 'PYS_FREE_VERSION', '5.0.
|
17 |
|
18 |
require_once( 'inc/admin_notices.php' );
|
19 |
require_once( 'inc/common.php' );
|
@@ -64,18 +64,14 @@ function pys_free_init() {
|
|
64 |
add_action( 'wp_footer', 'pys_output_woo_ajax_events_code', 10 );
|
65 |
add_action( 'wp_footer', 'pys_output_edd_ajax_events_code', 10 );
|
66 |
|
67 |
-
//
|
68 |
-
if ( pys_get_option( 'woo', 'enabled' ) &&
|
69 |
-
|
70 |
add_filter( 'woocommerce_loop_add_to_cart_link', 'pys_add_code_to_woo_cart_link', 10, 2 );
|
71 |
-
|
72 |
}
|
73 |
|
74 |
## add pixel code to EDD add_to_cart buttons
|
75 |
if ( pys_get_option( 'edd', 'enabled' ) && pys_get_option( 'edd', 'on_add_to_cart_btn', false ) ) {
|
76 |
-
|
77 |
add_filter( 'edd_purchase_link_args', 'pys_edd_purchase_link_args', 10, 1 );
|
78 |
-
|
79 |
}
|
80 |
|
81 |
add_filter( 'pys_event_params', 'pys_add_domain_param', 10, 2 );
|
@@ -159,7 +155,7 @@ if ( ! function_exists( 'pys_admin_scripts' ) ) {
|
|
159 |
add_thickbox();
|
160 |
|
161 |
wp_enqueue_style( 'pys', plugins_url( 'css/admin.css', __FILE__ ), array(), PYS_FREE_VERSION );
|
162 |
-
wp_enqueue_script( 'pys', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), PYS_FREE_VERSION );
|
163 |
|
164 |
}
|
165 |
|
@@ -173,7 +169,7 @@ if ( ! function_exists( 'pys_public_scripts' ) ) {
|
|
173 |
|
174 |
$in_footer = (bool) pys_get_option( 'general', 'in_footer', false );
|
175 |
|
176 |
-
wp_enqueue_script( 'pys', plugins_url( 'js/public.js', __FILE__ ), array( 'jquery' ), PYS_FREE_VERSION, $in_footer );
|
177 |
|
178 |
}
|
179 |
|
5 |
Plugin URI: http://www.pixelyoursite.com/facebook-pixel-plugin-help
|
6 |
Author: PixelYourSite
|
7 |
Author URI: http://www.pixelyoursite.com
|
8 |
+
Version: 5.0.1
|
9 |
License: GPLv3
|
10 |
*/
|
11 |
|
13 |
exit; // Exit if accessed directly.
|
14 |
}
|
15 |
|
16 |
+
define( 'PYS_FREE_VERSION', '5.0.1' );
|
17 |
|
18 |
require_once( 'inc/admin_notices.php' );
|
19 |
require_once( 'inc/common.php' );
|
64 |
add_action( 'wp_footer', 'pys_output_woo_ajax_events_code', 10 );
|
65 |
add_action( 'wp_footer', 'pys_output_edd_ajax_events_code', 10 );
|
66 |
|
67 |
+
// woocommerce shop page add_to_cart
|
68 |
+
if ( pys_get_option( 'woo', 'enabled' ) && pys_get_option( 'woo', 'on_add_to_cart_btn' ) ) {
|
|
|
69 |
add_filter( 'woocommerce_loop_add_to_cart_link', 'pys_add_code_to_woo_cart_link', 10, 2 );
|
|
|
70 |
}
|
71 |
|
72 |
## add pixel code to EDD add_to_cart buttons
|
73 |
if ( pys_get_option( 'edd', 'enabled' ) && pys_get_option( 'edd', 'on_add_to_cart_btn', false ) ) {
|
|
|
74 |
add_filter( 'edd_purchase_link_args', 'pys_edd_purchase_link_args', 10, 1 );
|
|
|
75 |
}
|
76 |
|
77 |
add_filter( 'pys_event_params', 'pys_add_domain_param', 10, 2 );
|
155 |
add_thickbox();
|
156 |
|
157 |
wp_enqueue_style( 'pys', plugins_url( 'css/admin.css', __FILE__ ), array(), PYS_FREE_VERSION );
|
158 |
+
wp_enqueue_script( 'pys-admin', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), PYS_FREE_VERSION );
|
159 |
|
160 |
}
|
161 |
|
169 |
|
170 |
$in_footer = (bool) pys_get_option( 'general', 'in_footer', false );
|
171 |
|
172 |
+
wp_enqueue_script( 'pys-public', plugins_url( 'js/public.js', __FILE__ ), array( 'jquery' ), PYS_FREE_VERSION, $in_footer );
|
173 |
|
174 |
}
|
175 |
|
inc/common.php
CHANGED
@@ -471,64 +471,95 @@ if ( ! function_exists( 'pys_insert_attribute' ) ) {
|
|
471 |
/**
|
472 |
* Add attribute with value to a HTML tag.
|
473 |
*
|
474 |
-
* @param string $attr_name Attribute name
|
475 |
* @param string $attr_value Attribute value
|
476 |
-
* @param string $
|
477 |
-
* @param bool $overwrite
|
478 |
-
* @param string $
|
479 |
*
|
480 |
* @return string Modified HTML content
|
481 |
*/
|
482 |
-
function pys_insert_attribute( $attr_name, $attr_value, $
|
483 |
|
484 |
## do not modify js attributes
|
485 |
if( $attr_name == 'on' ) {
|
486 |
-
return $
|
487 |
}
|
488 |
|
489 |
$attr_value = trim( $attr_value );
|
490 |
|
491 |
-
|
492 |
|
493 |
-
|
494 |
-
* Old libxml does not support options parameter.
|
495 |
-
* @since 3.2.0
|
496 |
-
*/
|
497 |
-
if( defined('LIBXML_DOTTED_VERSION') && version_compare( LIBXML_DOTTED_VERSION, '2.6.0', '>=' ) &&
|
498 |
-
version_compare( phpversion(), '5.4.0', '>=' ) ) {
|
499 |
-
@$doc->loadHTML( '<?xml encoding="UTF-8">' . $tag, LIBXML_NOEMPTYTAG );
|
500 |
-
} else {
|
501 |
-
@$doc->loadHTML( '<?xml encoding="UTF-8">' . $tag );
|
502 |
-
}
|
503 |
|
504 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
505 |
|
506 |
-
|
507 |
-
|
508 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
509 |
|
510 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
511 |
|
512 |
-
|
513 |
-
|
514 |
|
515 |
-
|
|
|
516 |
|
517 |
-
|
|
|
518 |
|
519 |
-
|
520 |
|
521 |
-
|
522 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
|
524 |
-
|
525 |
-
|
|
|
526 |
|
527 |
-
|
528 |
|
529 |
}
|
530 |
|
531 |
-
return $
|
532 |
|
533 |
}
|
534 |
|
@@ -899,7 +930,7 @@ if( ! function_exists( 'pys_output_js_events_code' ) ) {
|
|
899 |
return;
|
900 |
}
|
901 |
|
902 |
-
wp_localize_script( 'pys', 'pys_events', $pys_events );
|
903 |
|
904 |
}
|
905 |
|
@@ -914,7 +945,7 @@ if( ! function_exists( 'pys_output_custom_events_code' ) ) {
|
|
914 |
return;
|
915 |
}
|
916 |
|
917 |
-
wp_localize_script( 'pys', 'pys_customEvents', $pys_custom_events );
|
918 |
|
919 |
}
|
920 |
|
@@ -1322,7 +1353,7 @@ if( ! function_exists( 'pys_output_options' ) ) {
|
|
1322 |
'traffic_source_enabled' => pys_get_option( 'general', 'add_traffic_source' )
|
1323 |
);
|
1324 |
|
1325 |
-
wp_localize_script( 'pys', 'pys_options', $options );
|
1326 |
|
1327 |
}
|
1328 |
|
@@ -1470,4 +1501,20 @@ if ( ! function_exists( 'pys_delete_events' ) ) {
|
|
1470 |
|
1471 |
}
|
1472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1473 |
}
|
471 |
/**
|
472 |
* Add attribute with value to a HTML tag.
|
473 |
*
|
474 |
+
* @param string $attr_name Attribute name, eg. "class"
|
475 |
* @param string $attr_value Attribute value
|
476 |
+
* @param string $content HTML content where attribute should be inserted
|
477 |
+
* @param bool $overwrite Override existing value of attribute or append it
|
478 |
+
* @param string $tag Selector name, eg. "button". Default "a"
|
479 |
*
|
480 |
* @return string Modified HTML content
|
481 |
*/
|
482 |
+
function pys_insert_attribute( $attr_name, $attr_value, $content, $overwrite = false, $tag = 'a' ) {
|
483 |
|
484 |
## do not modify js attributes
|
485 |
if( $attr_name == 'on' ) {
|
486 |
+
return $content;
|
487 |
}
|
488 |
|
489 |
$attr_value = trim( $attr_value );
|
490 |
|
491 |
+
try {
|
492 |
|
493 |
+
$doc = new DOMDocument();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
494 |
|
495 |
+
/**
|
496 |
+
* Old libxml does not support options parameter.
|
497 |
+
*
|
498 |
+
* @since 3.2.0
|
499 |
+
*/
|
500 |
+
if ( defined( 'LIBXML_DOTTED_VERSION' ) && version_compare( LIBXML_DOTTED_VERSION, '2.6.0', '>=' ) &&
|
501 |
+
version_compare( phpversion(), '5.4.0', '>=' )
|
502 |
+
) {
|
503 |
+
@$doc->loadHTML( '<?xml encoding="UTF-8">' . $content, LIBXML_NOEMPTYTAG );
|
504 |
+
} else {
|
505 |
+
@$doc->loadHTML( '<?xml encoding="UTF-8">' . $content );
|
506 |
+
}
|
507 |
|
508 |
+
/**
|
509 |
+
* Select top-level tag if it is not specified in args.
|
510 |
+
*
|
511 |
+
* @since: 5.0.6
|
512 |
+
*/
|
513 |
+
if ( $tag == 'any' ) {
|
514 |
+
|
515 |
+
/** @var DOMNodeList $node */
|
516 |
+
$node = $doc->getElementsByTagName( 'body' );
|
517 |
|
518 |
+
if ( $node->length == 0 ) {
|
519 |
+
throw new Exception( 'Empty or wrong tag passed to filter.' );
|
520 |
+
}
|
521 |
+
|
522 |
+
$node = $node->item( 0 )->childNodes->item( 0 );
|
523 |
+
|
524 |
+
} else {
|
525 |
+
$node = $doc->getElementsByTagName( $tag )->item( 0 );
|
526 |
+
}
|
527 |
+
|
528 |
+
if ( is_null( $node ) ) {
|
529 |
+
return $content;
|
530 |
+
}
|
531 |
|
532 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
533 |
+
$attribute = $node->getAttribute( $attr_name );
|
534 |
|
535 |
+
// add attribute or override old one
|
536 |
+
if ( empty( $attribute ) || $overwrite ) {
|
537 |
|
538 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
539 |
+
$node->setAttribute( $attr_name, $attr_value );
|
540 |
|
541 |
+
return str_replace( array( '<?xml encoding="UTF-8">', '<html>', '</html>', '<body>', '</body>' ), null, $doc->saveHTML() );
|
542 |
|
543 |
+
}
|
544 |
+
|
545 |
+
// append value to exist attribute
|
546 |
+
if ( $overwrite == false ) {
|
547 |
+
|
548 |
+
$value = $attribute . ' ' . $attr_value;
|
549 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
550 |
+
$node->setAttribute( $attr_name, $value );
|
551 |
+
|
552 |
+
return str_replace( array( '<?xml encoding="UTF-8">', '<html>', '</html>', '<body>', '</body>' ), null, $doc->saveHTML() );
|
553 |
|
554 |
+
}
|
555 |
+
|
556 |
+
} catch ( Exception $e ) {
|
557 |
|
558 |
+
error_log( $e );
|
559 |
|
560 |
}
|
561 |
|
562 |
+
return $content;
|
563 |
|
564 |
}
|
565 |
|
930 |
return;
|
931 |
}
|
932 |
|
933 |
+
wp_localize_script( 'pys-public', 'pys_events', $pys_events );
|
934 |
|
935 |
}
|
936 |
|
945 |
return;
|
946 |
}
|
947 |
|
948 |
+
wp_localize_script( 'pys-public', 'pys_customEvents', $pys_custom_events );
|
949 |
|
950 |
}
|
951 |
|
1353 |
'traffic_source_enabled' => pys_get_option( 'general', 'add_traffic_source' )
|
1354 |
);
|
1355 |
|
1356 |
+
wp_localize_script( 'pys-public', 'pys_options', $options );
|
1357 |
|
1358 |
}
|
1359 |
|
1501 |
|
1502 |
}
|
1503 |
|
1504 |
+
}
|
1505 |
+
|
1506 |
+
if( ! function_exists( 'pys_is_wc_version_gte' ) ) {
|
1507 |
+
|
1508 |
+
function pys_is_wc_version_gte( $version ) {
|
1509 |
+
|
1510 |
+
if ( defined( 'WC_VERSION' ) && WC_VERSION ) {
|
1511 |
+
return version_compare( WC_VERSION, $version, '>=' );
|
1512 |
+
} else if ( defined( 'WOOCOMMERCE_VERSION' ) && WOOCOMMERCE_VERSION ) {
|
1513 |
+
return version_compare( WOOCOMMERCE_VERSION, $version, '>=' );
|
1514 |
+
} else {
|
1515 |
+
return false;
|
1516 |
+
}
|
1517 |
+
|
1518 |
+
}
|
1519 |
+
|
1520 |
}
|
inc/core.php
CHANGED
@@ -158,24 +158,52 @@ if( !function_exists( 'pys_get_woo_code' ) ) {
|
|
158 |
}
|
159 |
|
160 |
if( !function_exists( 'pys_add_code_to_woo_cart_link' ) ) {
|
161 |
-
|
162 |
/**
|
163 |
* Adds data-pixelcode attribute to "add to cart" buttons in the WooCommerce loop.
|
|
|
|
|
|
|
|
|
|
|
164 |
*/
|
165 |
function pys_add_code_to_woo_cart_link( $tag, $product ) {
|
166 |
global $pys_woo_ajax_events;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
-
if (
|
169 |
return $tag;
|
170 |
}
|
171 |
|
172 |
$event_id = uniqid();
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
// common params
|
175 |
$params = array();
|
176 |
$params['content_type'] = 'product';
|
177 |
-
$params['content_ids'] = '[' . pys_get_product_content_id( $
|
178 |
-
|
179 |
// currency, value
|
180 |
if ( pys_get_option( 'woo', 'enable_add_to_cart_value' ) ) {
|
181 |
|
@@ -184,22 +212,12 @@ if( !function_exists( 'pys_add_code_to_woo_cart_link' ) ) {
|
|
184 |
|
185 |
}
|
186 |
|
187 |
-
|
188 |
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
}
|
194 |
-
|
195 |
-
$tag = pys_insert_attribute( 'data-pys-event-id', $event_id, $tag, true );
|
196 |
-
|
197 |
-
$pys_woo_ajax_events[ $event_id ] = array(
|
198 |
-
'name' => 'AddToCart',
|
199 |
-
'params' => $params
|
200 |
-
);
|
201 |
-
|
202 |
-
}
|
203 |
|
204 |
return $tag;
|
205 |
|
158 |
}
|
159 |
|
160 |
if( !function_exists( 'pys_add_code_to_woo_cart_link' ) ) {
|
161 |
+
|
162 |
/**
|
163 |
* Adds data-pixelcode attribute to "add to cart" buttons in the WooCommerce loop.
|
164 |
+
*
|
165 |
+
* @param string $tag
|
166 |
+
* @param WC_Product $product
|
167 |
+
*
|
168 |
+
* @return string
|
169 |
*/
|
170 |
function pys_add_code_to_woo_cart_link( $tag, $product ) {
|
171 |
global $pys_woo_ajax_events;
|
172 |
+
|
173 |
+
// do not add code if AJAX is disabled. event will be processed by another function
|
174 |
+
if ( 'yes' !== get_option( 'woocommerce_enable_ajax_add_to_cart' ) ) {
|
175 |
+
return $tag;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* @since 5.0.1
|
180 |
+
*/
|
181 |
+
if( pys_is_wc_version_gte( '2.7' ) ) {
|
182 |
+
$is_simple_product = $product->is_type( 'simple' );
|
183 |
+
} else {
|
184 |
+
$is_simple_product = $product->product_type == 'simple';
|
185 |
+
}
|
186 |
|
187 |
+
if ( false == $is_simple_product ) {
|
188 |
return $tag;
|
189 |
}
|
190 |
|
191 |
$event_id = uniqid();
|
192 |
|
193 |
+
/**
|
194 |
+
* @since 5.0.1
|
195 |
+
*/
|
196 |
+
if ( pys_is_wc_version_gte( '2.6' ) ) {
|
197 |
+
$product_id = $product->get_id();
|
198 |
+
} else {
|
199 |
+
$product_id = $product->post->ID;
|
200 |
+
}
|
201 |
+
|
202 |
// common params
|
203 |
$params = array();
|
204 |
$params['content_type'] = 'product';
|
205 |
+
$params['content_ids'] = '[' . pys_get_product_content_id( $product_id ) . ']';
|
206 |
+
|
207 |
// currency, value
|
208 |
if ( pys_get_option( 'woo', 'enable_add_to_cart_value' ) ) {
|
209 |
|
212 |
|
213 |
}
|
214 |
|
215 |
+
$tag = pys_insert_attribute( 'data-pys-event-id', $event_id, $tag, true, 'any' );
|
216 |
|
217 |
+
$pys_woo_ajax_events[ $event_id ] = array(
|
218 |
+
'name' => 'AddToCart',
|
219 |
+
'params' => $params
|
220 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
return $tag;
|
223 |
|
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, Easy Digital Downloads Pixel, Easy Digital Downloads Facebook Pixel
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 4.7
|
6 |
-
Stable tag: 5.0.
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -108,6 +108,8 @@ Retargeting the users that performed a search on your site is a smart strategy b
|
|
108 |
|
109 |
<strong>Superb WooCommerce Integration</strong><br>
|
110 |
|
|
|
|
|
111 |
* You can **insert the Facebook pixel and start tracking events on any WooCommerce** website with just a few clicks (Purchase, ViewContent, AddToCart, InitiateCheckout)
|
112 |
|
113 |
* Out of the box **Facebook Dynamic Ads** (promote a product catalog) pixel setup for your Woocommerce website (we also have a dedicated feed plugin for Facebook Dynamic Ads Product Catalog)
|
@@ -292,6 +294,10 @@ We have an article about how to optimize Facebook Ads Reports:
|
|
292 |
|
293 |
== Changelog ==
|
294 |
|
|
|
|
|
|
|
|
|
295 |
= PixelYourSite 5.0 =
|
296 |
|
297 |
* Easy Digital Downloads Integration - Dynamic Ads (promote a product catalog) are fully supported.
|
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, Easy Digital Downloads Pixel, Easy Digital Downloads Facebook Pixel
|
4 |
Requires at least: 3.0.1
|
5 |
Tested up to: 4.7
|
6 |
+
Stable tag: 5.0.1
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
108 |
|
109 |
<strong>Superb WooCommerce Integration</strong><br>
|
110 |
|
111 |
+
Tested with WooCommerce 2.7
|
112 |
+
|
113 |
* You can **insert the Facebook pixel and start tracking events on any WooCommerce** website with just a few clicks (Purchase, ViewContent, AddToCart, InitiateCheckout)
|
114 |
|
115 |
* Out of the box **Facebook Dynamic Ads** (promote a product catalog) pixel setup for your Woocommerce website (we also have a dedicated feed plugin for Facebook Dynamic Ads Product Catalog)
|
294 |
|
295 |
== Changelog ==
|
296 |
|
297 |
+
= PixelYourSite 5.0.1 =
|
298 |
+
|
299 |
+
* WooCommerce 2.7 compatibility update: we made sure everything works with the latest WooCommerce version.
|
300 |
+
|
301 |
= PixelYourSite 5.0 =
|
302 |
|
303 |
* Easy Digital Downloads Integration - Dynamic Ads (promote a product catalog) are fully supported.
|