Version Description
Download this release
Release Info
Developer | PixelYourSite |
Plugin | PixelYourSite – Facebook Pixel (Events, WooCommerce & Easy Digital Downloads) |
Version | 5.0.5.2 |
Comparing to | |
See all releases |
Code changes from version 5.0.4 to 5.0.5.2
- facebook-pixel-master.php +31 -195
- inc/common.php +55 -68
- inc/core.php +18 -13
- inc/general.php +198 -0
- inc/html-tab-woo-general.php +22 -21
- inc/integrations/facebook-for-woocommerce.php +25 -11
- readme.txt +12 -2
facebook-pixel-master.php
CHANGED
@@ -5,223 +5,59 @@
|
|
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 |
|
12 |
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
-
|
14 |
}
|
15 |
|
16 |
-
define( 'PYS_FREE_VERSION', '5.0.
|
17 |
-
|
18 |
-
require_once( 'inc/admin_notices.php' );
|
19 |
-
require_once( 'inc/common.php' );
|
20 |
-
require_once( 'inc/common-edd.php' );
|
21 |
-
require_once( 'inc/core.php' );
|
22 |
-
require_once( 'inc/core-edd.php' );
|
23 |
-
require_once( 'inc/ajax-standard.php' );
|
24 |
-
require_once( 'inc/integrations/facebook-for-woocommerce.php' );
|
25 |
-
|
26 |
-
add_action( 'plugins_loaded', 'pys_free_init' );
|
27 |
-
function pys_free_init() {
|
28 |
-
|
29 |
-
$options = get_option( 'pixel_your_site' );
|
30 |
-
if ( ! $options || ! isset( $options['general']['pixel_id'] ) || empty( $options['general']['pixel_id'] ) ) {
|
31 |
-
pys_initialize_settings();
|
32 |
-
}
|
33 |
-
|
34 |
-
if ( is_admin() || pys_get_option( 'general', 'enabled' ) == false || pys_is_disabled_for_role() || ! pys_get_option( 'general', 'pixel_id' ) ) {
|
35 |
-
return;
|
36 |
-
}
|
37 |
-
|
38 |
-
add_action( 'wp_enqueue_scripts', 'pys_public_scripts' );
|
39 |
-
add_action( 'wp_head', 'pys_head_comments', 10 );
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Hooks call priority:
|
43 |
-
* wp_head:
|
44 |
-
* 1 - pixel events options - PRO only;
|
45 |
-
* 2 - init event;
|
46 |
-
* 3 - evaluate events;
|
47 |
-
* 4 - output events;
|
48 |
-
* 9 (20) - enqueue public scripts (head/footer);
|
49 |
-
* wp_footer
|
50 |
-
*/
|
51 |
-
|
52 |
-
add_action( 'wp_head', 'pys_pixel_init_event', 2 );
|
53 |
-
|
54 |
-
add_action( 'wp_head', 'pys_page_view_event', 3 );
|
55 |
-
add_action( 'wp_head', 'pys_general_event', 3 );
|
56 |
-
add_action( 'wp_head', 'pys_search_event', 3 );
|
57 |
-
add_action( 'wp_head', 'pys_standard_events', 3 );
|
58 |
-
add_action( 'wp_head', 'pys_woocommerce_events', 3 );
|
59 |
-
add_action( 'wp_head', 'pys_edd_events', 3 );
|
60 |
-
|
61 |
-
add_action( 'wp_head', 'pys_output_js_events_code', 4 );
|
62 |
-
add_action( 'wp_head', 'pys_output_custom_events_code', 4 );
|
63 |
-
|
64 |
-
add_action( 'wp_footer', 'pys_output_noscript_code', 10 );
|
65 |
-
add_action( 'wp_footer', 'pys_output_woo_ajax_events_code', 10 );
|
66 |
-
add_action( 'wp_footer', 'pys_output_edd_ajax_events_code', 10 );
|
67 |
-
|
68 |
-
// woocommerce shop page add_to_cart
|
69 |
-
if ( pys_get_option( 'woo', 'enabled' ) && pys_get_option( 'woo', 'on_add_to_cart_btn' ) ) {
|
70 |
-
add_filter( 'woocommerce_loop_add_to_cart_link', 'pys_add_code_to_woo_cart_link', 10, 2 );
|
71 |
-
}
|
72 |
-
|
73 |
-
## add pixel code to EDD add_to_cart buttons
|
74 |
-
if ( pys_get_option( 'edd', 'enabled' ) && pys_get_option( 'edd', 'on_add_to_cart_btn', false ) ) {
|
75 |
-
add_filter( 'edd_purchase_link_args', 'pys_edd_purchase_link_args', 10, 1 );
|
76 |
-
}
|
77 |
-
|
78 |
-
add_filter( 'pys_event_params', 'pys_add_domain_param', 10, 2 );
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
if ( ! function_exists( 'pys_admin_menu' ) ) {
|
83 |
-
|
84 |
-
function pys_admin_menu() {
|
85 |
-
|
86 |
-
if ( false == current_user_can( 'manage_options' ) ) {
|
87 |
-
return;
|
88 |
-
}
|
89 |
-
|
90 |
-
add_menu_page( 'PixelYourSite', 'PixelYourSite', 'manage_options', 'pixel-your-site', 'pys_admin_page_callback', plugins_url( 'pixelyoursite/img/favicon.png' ) );
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
add_action( 'admin_menu', 'pys_admin_menu' );
|
95 |
-
|
96 |
-
}
|
97 |
-
|
98 |
-
if ( ! function_exists( 'pys_restrict_admin_pages' ) ) {
|
99 |
-
|
100 |
-
function pys_restrict_admin_pages() {
|
101 |
-
|
102 |
-
$screen = get_current_screen();
|
103 |
-
|
104 |
-
if ( $screen->id == 'toplevel_page_pixel-your-site' & false == current_user_can( 'manage_options' ) ) {
|
105 |
-
wp_die( __( 'Sorry, you are not allowed to access this page.' ) );
|
106 |
-
}
|
107 |
-
|
108 |
-
}
|
109 |
-
|
110 |
-
add_action( 'current_screen', 'pys_restrict_admin_pages' );
|
111 |
-
|
112 |
-
}
|
113 |
-
|
114 |
-
if ( ! function_exists( 'pys_admin_page_callback' ) ) {
|
115 |
-
|
116 |
-
function pys_admin_page_callback() {
|
117 |
-
|
118 |
-
## update plugin options
|
119 |
-
if ( ! empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'pys_update_options' ) && isset( $_POST['pys'] ) ) {
|
120 |
-
update_option( 'pixel_your_site', $_POST['pys'] );
|
121 |
-
}
|
122 |
-
|
123 |
-
## delete standard events
|
124 |
-
if ( isset( $_GET['action'] ) && $_GET['action'] == 'pys_delete_events'
|
125 |
-
&& isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'pys_delete_events' )
|
126 |
-
&& isset( $_GET['events_ids'] ) && isset( $_GET['events_type'] )
|
127 |
-
) {
|
128 |
-
|
129 |
-
pys_delete_events( $_GET['events_ids'], $_GET['events_type'] );
|
130 |
-
|
131 |
-
$redirect_to = add_query_arg(
|
132 |
-
array(
|
133 |
-
'page' => 'pixel-your-site',
|
134 |
-
'active_tab' => $_GET['events_type'] == 'standard' ? 'posts-events' : 'dynamic-events',
|
135 |
-
),
|
136 |
-
admin_url( 'admin.php' )
|
137 |
-
);
|
138 |
-
|
139 |
-
wp_safe_redirect( $redirect_to );
|
140 |
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
-
|
|
|
|
|
144 |
|
145 |
-
|
146 |
|
147 |
-
}
|
148 |
-
|
149 |
-
if ( ! function_exists( 'pys_admin_scripts' ) ) {
|
150 |
-
|
151 |
-
add_action( 'admin_enqueue_scripts', 'pys_admin_scripts' );
|
152 |
-
function pys_admin_scripts() {
|
153 |
-
|
154 |
-
if ( isset( $_GET['page'] ) && $_GET['page'] == 'pixel-your-site' ) {
|
155 |
-
|
156 |
-
add_thickbox();
|
157 |
-
|
158 |
-
wp_enqueue_style( 'pys', plugins_url( 'css/admin.css', __FILE__ ), array(), PYS_FREE_VERSION );
|
159 |
-
wp_enqueue_script( 'pys-admin', plugins_url( 'js/admin.js', __FILE__ ), array( 'jquery' ), PYS_FREE_VERSION );
|
160 |
-
|
161 |
-
}
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
if ( ! function_exists( 'pys_public_scripts' ) ) {
|
168 |
-
|
169 |
-
function pys_public_scripts() {
|
170 |
-
|
171 |
-
$in_footer = (bool) pys_get_option( 'general', 'in_footer', false );
|
172 |
-
|
173 |
-
wp_enqueue_script( 'pys-public', plugins_url( 'js/public.js', __FILE__ ), array( 'jquery' ), PYS_FREE_VERSION, $in_footer );
|
174 |
-
|
175 |
-
}
|
176 |
|
177 |
}
|
178 |
|
179 |
if ( ! function_exists( 'pys_free_plugin_activated' ) ) {
|
180 |
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
if ( false == is_admin() || false == current_user_can( 'manage_options' ) ) {
|
185 |
-
return;
|
186 |
-
}
|
187 |
-
|
188 |
-
if ( ! function_exists( 'is_plugin_active' ) ) {
|
189 |
-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
190 |
-
}
|
191 |
-
|
192 |
-
if ( is_plugin_active( 'pixelyoursite-pro/pixelyoursite-pro.php' ) ) {
|
193 |
-
wp_die( 'Please deactivate PixelYourSite Pro version First.', 'Plugin Activation' );
|
194 |
-
}
|
195 |
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
200 |
|
201 |
-
|
202 |
|
203 |
-
|
204 |
-
|
205 |
-
if ( ! function_exists( 'pys_initialize_settings' ) ) {
|
206 |
-
|
207 |
-
function pys_initialize_settings() {
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
}
|
212 |
|
213 |
-
|
214 |
-
$defaults = pys_get_default_options();
|
215 |
-
update_option( 'pixel_your_site', $defaults );
|
216 |
|
217 |
-
|
218 |
-
if ( get_option( 'woofp_admin_settings' ) ) {
|
219 |
|
220 |
-
|
221 |
-
pys_migrate_from_22x();
|
222 |
-
|
223 |
-
}
|
224 |
-
|
225 |
-
}
|
226 |
|
|
|
|
|
227 |
}
|
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.5.2
|
9 |
License: GPLv3
|
10 |
*/
|
11 |
|
12 |
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
+
exit; // Exit if accessed directly.
|
14 |
}
|
15 |
|
16 |
+
define( 'PYS_FREE_VERSION', '5.0.5.2' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
if ( ! function_exists( 'pys_is_pixelyoursite_pro_active' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
/**
|
21 |
+
* Check whatever PixelYourSite PRO version activated.
|
22 |
+
*
|
23 |
+
* @return bool
|
24 |
+
*/
|
25 |
+
function pys_is_pixelyoursite_pro_active() {
|
26 |
|
27 |
+
if ( ! function_exists( 'is_plugin_active' ) ) {
|
28 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
29 |
+
}
|
30 |
|
31 |
+
return is_plugin_active( 'pixelyoursite-pro/pixelyoursite-pro.php' );
|
32 |
|
33 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
}
|
36 |
|
37 |
if ( ! function_exists( 'pys_free_plugin_activated' ) ) {
|
38 |
|
39 |
+
register_activation_hook( __FILE__, 'pys_free_plugin_activated' );
|
40 |
+
function pys_free_plugin_activated() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
if ( pys_is_pixelyoursite_pro_active() ) {
|
43 |
+
wp_die( 'Please deactivate PixelYourSite PRO version first.', 'Plugin Activation', array(
|
44 |
+
'back_link' => true,
|
45 |
+
) );
|
46 |
+
}
|
47 |
|
48 |
+
$options = get_option( 'pixel_your_site' );
|
49 |
|
50 |
+
if ( ! $options || ! isset( $options['general']['pixel_id'] ) || empty( $options['general']['pixel_id'] ) ) {
|
|
|
|
|
|
|
|
|
51 |
|
52 |
+
require_once 'inc/general.php';
|
53 |
+
pys_initialize_settings();
|
|
|
54 |
|
55 |
+
}
|
|
|
|
|
56 |
|
57 |
+
}
|
|
|
58 |
|
59 |
+
}
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
+
if ( ! pys_is_pixelyoursite_pro_active() ) {
|
62 |
+
require_once 'inc/general.php';
|
63 |
}
|
inc/common.php
CHANGED
@@ -7,23 +7,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
7 |
exit; // Exit if accessed directly.
|
8 |
}
|
9 |
|
10 |
-
if( !function_exists( 'dd' ) ) {
|
11 |
-
|
12 |
-
function dd( $data ) {
|
13 |
-
echo "<pre>" . print_r( $data, 1 ) . "</pre>";
|
14 |
-
die();
|
15 |
-
}
|
16 |
-
|
17 |
-
}
|
18 |
-
|
19 |
-
if( !function_exists( 'precho' ) ) {
|
20 |
-
|
21 |
-
function precho( $data ) {
|
22 |
-
echo "<pre>" . print_r( $data, 1 ) . "</pre>";
|
23 |
-
}
|
24 |
-
|
25 |
-
}
|
26 |
-
|
27 |
/**
|
28 |
* Check if WooCommerce plugin is installed and activated.
|
29 |
*/
|
@@ -77,19 +60,20 @@ if( !function_exists( 'pys_get_option' ) ) {
|
|
77 |
|
78 |
if( !function_exists( 'pys_checkbox_state' ) ) {
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
88 |
|
89 |
$options = get_option( 'pixel_your_site' );
|
90 |
|
91 |
if ( isset( $options[ $section ][ $option ] ) ) {
|
92 |
-
$value = $options[ $section ][ $option ] ==
|
93 |
} else {
|
94 |
$value = '';
|
95 |
}
|
@@ -105,21 +89,24 @@ if( !function_exists( 'pys_checkbox_state' ) ) {
|
|
105 |
}
|
106 |
|
107 |
if ( ! function_exists( 'pys_checkbox' ) ) {
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
123 |
}
|
124 |
|
125 |
if ( ! function_exists( 'pys_text_field' ) ) {
|
@@ -429,19 +416,20 @@ if ( ! function_exists( 'pys_get_product_content_id' ) ) {
|
|
429 |
/**
|
430 |
* Return product id or sku.
|
431 |
*/
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
|
|
445 |
|
446 |
}
|
447 |
|
@@ -452,11 +440,11 @@ if ( ! function_exists( 'pys_get_product_id' ) ) {
|
|
452 |
*/
|
453 |
function pys_get_product_id( $product ) {
|
454 |
|
455 |
-
$
|
456 |
-
|
457 |
-
if ( pys_get_option( 'woo', 'variation_id' ) == 'variation' && isset( $product['variation_id'] ) && $product['variation_id'] != 0 ) {
|
458 |
$id = $product['variation_id'];
|
459 |
-
}
|
|
|
|
|
460 |
|
461 |
return $id;
|
462 |
}
|
@@ -985,9 +973,8 @@ if( !function_exists( 'pys_get_woo_checkout_params' ) ) {
|
|
985 |
|
986 |
foreach ( $woocommerce->cart->cart_contents as $cart_item_key => $item ) {
|
987 |
|
988 |
-
|
989 |
-
|
990 |
-
$ids[] = $value;
|
991 |
|
992 |
// content_name, category_name for each cart item
|
993 |
if ( $additional_params_enabled ) {
|
@@ -1006,7 +993,7 @@ if( !function_exists( 'pys_get_woo_checkout_params' ) ) {
|
|
1006 |
$params['num_items'] = $woocommerce->cart->get_cart_contents_count();
|
1007 |
}
|
1008 |
|
1009 |
-
$params['content_ids'] =
|
1010 |
|
1011 |
if ( ! empty( $names ) ) {
|
1012 |
$params['content_name'] = $names;
|
@@ -1056,7 +1043,7 @@ if( !function_exists( 'pys_get_default_options' ) ) {
|
|
1056 |
$options['woo']['enabled'] = pys_is_woocommerce_active() ? 1 : 0;
|
1057 |
|
1058 |
$options['woo']['content_id'] = 'id';
|
1059 |
-
$options['woo']['variation_id'] = '
|
1060 |
|
1061 |
$options['woo']['enable_additional_params'] = 1;
|
1062 |
$options['woo']['enable_tags'] = 1;
|
@@ -1272,12 +1259,12 @@ if( ! function_exists( 'pys_woocommerce_events' ) ) {
|
|
1272 |
|
1273 |
// WooCommerce non-ajax AddToCart Event handler
|
1274 |
if ( isset( $_REQUEST['add-to-cart'] ) ) {
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
if ( pys_get_option( 'woo', 'variation_id' ) == 'variation' && isset( $_REQUEST['variation_id'] ) ) {
|
1279 |
$product_id = $_REQUEST['variation_id'];
|
1280 |
-
}
|
|
|
|
|
1281 |
|
1282 |
$params = pys_get_woo_ajax_addtocart_params( $product_id );
|
1283 |
|
7 |
exit; // Exit if accessed directly.
|
8 |
}
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
* Check if WooCommerce plugin is installed and activated.
|
12 |
*/
|
60 |
|
61 |
if( !function_exists( 'pys_checkbox_state' ) ) {
|
62 |
|
63 |
+
/**
|
64 |
+
* @param string $section Option section name
|
65 |
+
* @param string $option Option name
|
66 |
+
* @param bool $echo Echo or return value
|
67 |
+
* @param int $checked Value to state compare
|
68 |
+
*
|
69 |
+
* @return string
|
70 |
+
*/
|
71 |
+
function pys_checkbox_state( $section, $option, $echo = true, $checked = 1 ) {
|
72 |
|
73 |
$options = get_option( 'pixel_your_site' );
|
74 |
|
75 |
if ( isset( $options[ $section ][ $option ] ) ) {
|
76 |
+
$value = $options[ $section ][ $option ] == $checked ? 'checked' : '';
|
77 |
} else {
|
78 |
$value = '';
|
79 |
}
|
89 |
}
|
90 |
|
91 |
if ( ! function_exists( 'pys_checkbox' ) ) {
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Echos checkbox input.
|
95 |
+
*
|
96 |
+
* @param string $section Input section name
|
97 |
+
* @param string $option Input option name
|
98 |
+
* @param string $classes Class names (optional)
|
99 |
+
* @param int $value Input value (optional)
|
100 |
+
*/
|
101 |
+
function pys_checkbox( $section, $option, $classes = '', $value = 1 ) {
|
102 |
+
|
103 |
+
$state = pys_checkbox_state( $section, $option, false, $value );
|
104 |
+
$value = esc_attr( $value );
|
105 |
+
|
106 |
+
echo "<input type='checkbox' value='$value' name='pys[$section][$option]' class='$classes' $state>";
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
}
|
111 |
|
112 |
if ( ! function_exists( 'pys_text_field' ) ) {
|
416 |
/**
|
417 |
* Return product id or sku.
|
418 |
*/
|
419 |
+
function pys_get_product_content_id( $product_id ) {
|
420 |
+
|
421 |
+
$content_id_format = pys_get_option( 'woo', 'content_id_format', 'default' );
|
422 |
+
|
423 |
+
if ( pys_get_option( 'woo', 'content_id' ) == 'sku' ) {
|
424 |
+
$content_id = get_post_meta( $product_id, '_sku', true );
|
425 |
+
} else {
|
426 |
+
$content_id = intval( $product_id );
|
427 |
+
}
|
428 |
+
|
429 |
+
return apply_filters( 'pys_fb_pixel_woo_product_content_id', array( $content_id ), $product_id,
|
430 |
+
$content_id_format );
|
431 |
+
|
432 |
+
}
|
433 |
|
434 |
}
|
435 |
|
440 |
*/
|
441 |
function pys_get_product_id( $product ) {
|
442 |
|
443 |
+
if ( pys_get_option( 'woo', 'variation_id' ) != 'main' && isset( $product['variation_id'] ) && $product['variation_id'] != 0 ) {
|
|
|
|
|
444 |
$id = $product['variation_id'];
|
445 |
+
} else {
|
446 |
+
$id = $product['product_id'];
|
447 |
+
}
|
448 |
|
449 |
return $id;
|
450 |
}
|
973 |
|
974 |
foreach ( $woocommerce->cart->cart_contents as $cart_item_key => $item ) {
|
975 |
|
976 |
+
$product_id = pys_get_product_id( $item );
|
977 |
+
$ids = array_merge( $ids, pys_get_product_content_id( $product_id ) );
|
|
|
978 |
|
979 |
// content_name, category_name for each cart item
|
980 |
if ( $additional_params_enabled ) {
|
993 |
$params['num_items'] = $woocommerce->cart->get_cart_contents_count();
|
994 |
}
|
995 |
|
996 |
+
$params['content_ids'] = json_encode( $ids );
|
997 |
|
998 |
if ( ! empty( $names ) ) {
|
999 |
$params['content_name'] = $names;
|
1043 |
$options['woo']['enabled'] = pys_is_woocommerce_active() ? 1 : 0;
|
1044 |
|
1045 |
$options['woo']['content_id'] = 'id';
|
1046 |
+
$options['woo']['variation_id'] = 'variation';
|
1047 |
|
1048 |
$options['woo']['enable_additional_params'] = 1;
|
1049 |
$options['woo']['enable_tags'] = 1;
|
1259 |
|
1260 |
// WooCommerce non-ajax AddToCart Event handler
|
1261 |
if ( isset( $_REQUEST['add-to-cart'] ) ) {
|
1262 |
+
|
1263 |
+
if ( pys_get_option( 'woo', 'variation_id' ) != 'main' && isset( $_REQUEST['variation_id'] ) ) {
|
|
|
|
|
1264 |
$product_id = $_REQUEST['variation_id'];
|
1265 |
+
} else {
|
1266 |
+
$product_id = isset( $_REQUEST['add-to-cart'] ) ? $_REQUEST['add-to-cart'] : null;
|
1267 |
+
}
|
1268 |
|
1269 |
$params = pys_get_woo_ajax_addtocart_params( $product_id );
|
1270 |
|
inc/core.php
CHANGED
@@ -10,7 +10,7 @@ if ( ! function_exists( 'pys_get_woo_ajax_addtocart_params' ) ) {
|
|
10 |
|
11 |
$params = array();
|
12 |
$params['content_type'] = 'product';
|
13 |
-
$params['content_ids'] =
|
14 |
|
15 |
// currency, value
|
16 |
if ( pys_get_option( 'woo', 'enable_add_to_cart_value' ) ) {
|
@@ -73,7 +73,14 @@ if ( ! function_exists( 'pys_get_woo_code' ) ) {
|
|
73 |
$product = wc_get_product( $post->ID );
|
74 |
|
75 |
$params['content_type'] = $product->get_type() == 'variable' ? 'product_group' : 'product';
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
// currency, value
|
79 |
if ( pys_get_option( 'woo', 'enable_view_content_value' ) ) {
|
@@ -109,14 +116,13 @@ if ( ! function_exists( 'pys_get_woo_code' ) ) {
|
|
109 |
$ids = array(); // cart items ids or sku
|
110 |
|
111 |
foreach ( $woocommerce->cart->cart_contents as $cart_item_key => $item ) {
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
$ids[] = $value;
|
116 |
|
117 |
}
|
118 |
|
119 |
-
$params['content_ids'] =
|
120 |
|
121 |
// currency, value
|
122 |
if ( pys_get_option( 'woo', 'enable_add_to_cart_value' ) ) {
|
@@ -189,14 +195,13 @@ if ( ! function_exists( 'pys_get_woo_code' ) ) {
|
|
189 |
$ids = array(); // order items ids or sku
|
190 |
|
191 |
foreach ( $items as $item ) {
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
$ids[] = $value;
|
196 |
|
197 |
}
|
198 |
|
199 |
-
$params['content_ids'] =
|
200 |
|
201 |
// currency, value
|
202 |
if ( pys_get_option( 'woo', 'enable_purchase_value' ) ) {
|
@@ -275,7 +280,7 @@ if ( ! function_exists( 'pys_add_code_to_woo_cart_link' ) ) {
|
|
275 |
// common params
|
276 |
$params = array();
|
277 |
$params['content_type'] = 'product';
|
278 |
-
$params['content_ids'] =
|
279 |
|
280 |
// currency, value
|
281 |
if ( pys_get_option( 'woo', 'enable_add_to_cart_value' ) ) {
|
10 |
|
11 |
$params = array();
|
12 |
$params['content_type'] = 'product';
|
13 |
+
$params['content_ids'] = json_encode( pys_get_product_content_id( $product_id ) );
|
14 |
|
15 |
// currency, value
|
16 |
if ( pys_get_option( 'woo', 'enable_add_to_cart_value' ) ) {
|
73 |
$product = wc_get_product( $post->ID );
|
74 |
|
75 |
$params['content_type'] = $product->get_type() == 'variable' ? 'product_group' : 'product';
|
76 |
+
|
77 |
+
$params['content_ids'] = json_encode( pys_get_product_content_id( $post->ID ) );
|
78 |
+
|
79 |
+
if ( $product->get_type() == 'variable' && pys_get_option( 'woo', 'variation_id' ) != 'main' ) {
|
80 |
+
$params['content_type'] = 'product_group';
|
81 |
+
} else {
|
82 |
+
$params['content_type'] = 'product';
|
83 |
+
}
|
84 |
|
85 |
// currency, value
|
86 |
if ( pys_get_option( 'woo', 'enable_view_content_value' ) ) {
|
116 |
$ids = array(); // cart items ids or sku
|
117 |
|
118 |
foreach ( $woocommerce->cart->cart_contents as $cart_item_key => $item ) {
|
119 |
+
|
120 |
+
$product_id = pys_get_product_id( $item );
|
121 |
+
$ids = array_merge( $ids, pys_get_product_content_id( $product_id ) );
|
|
|
122 |
|
123 |
}
|
124 |
|
125 |
+
$params['content_ids'] = json_encode( $ids );
|
126 |
|
127 |
// currency, value
|
128 |
if ( pys_get_option( 'woo', 'enable_add_to_cart_value' ) ) {
|
195 |
$ids = array(); // order items ids or sku
|
196 |
|
197 |
foreach ( $items as $item ) {
|
198 |
+
|
199 |
+
$product_id = pys_get_product_id( $item );
|
200 |
+
$ids = array_merge( $ids, pys_get_product_content_id( $product_id ) );
|
|
|
201 |
|
202 |
}
|
203 |
|
204 |
+
$params['content_ids'] = json_encode( $ids );
|
205 |
|
206 |
// currency, value
|
207 |
if ( pys_get_option( 'woo', 'enable_purchase_value' ) ) {
|
280 |
// common params
|
281 |
$params = array();
|
282 |
$params['content_type'] = 'product';
|
283 |
+
$params['content_ids'] = json_encode( pys_get_product_content_id( $product_id ) );
|
284 |
|
285 |
// currency, value
|
286 |
if ( pys_get_option( 'woo', 'enable_add_to_cart_value' ) ) {
|
inc/general.php
ADDED
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // Exit if accessed directly.
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once 'admin_notices.php';
|
8 |
+
require_once 'common.php';
|
9 |
+
require_once 'common-edd.php';
|
10 |
+
require_once 'core.php';
|
11 |
+
require_once 'core-edd.php';
|
12 |
+
require_once 'ajax-standard.php';
|
13 |
+
|
14 |
+
if ( ! function_exists( 'pys_initialize_settings' ) ) {
|
15 |
+
|
16 |
+
function pys_initialize_settings() {
|
17 |
+
|
18 |
+
if ( false == current_user_can( 'manage_options' ) ) {
|
19 |
+
return;
|
20 |
+
}
|
21 |
+
|
22 |
+
// set default options values
|
23 |
+
$defaults = pys_get_default_options();
|
24 |
+
update_option( 'pixel_your_site', $defaults );
|
25 |
+
|
26 |
+
// migrate settings from old versions
|
27 |
+
if ( get_option( 'woofp_admin_settings' ) ) {
|
28 |
+
|
29 |
+
require_once 'migrate.php';
|
30 |
+
pys_migrate_from_22x();
|
31 |
+
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
37 |
+
|
38 |
+
if ( ! function_exists( 'pys_admin_menu' ) ) {
|
39 |
+
|
40 |
+
function pys_admin_menu() {
|
41 |
+
|
42 |
+
if ( false == current_user_can( 'manage_options' ) ) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
add_menu_page( 'PixelYourSite', 'PixelYourSite', 'manage_options', 'pixel-your-site', 'pys_admin_page_callback',
|
47 |
+
plugins_url( 'pixelyoursite/img/favicon.png' ) );
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
add_action( 'admin_menu', 'pys_admin_menu' );
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
if ( ! function_exists( 'pys_admin_page_callback' ) ) {
|
56 |
+
|
57 |
+
function pys_admin_page_callback() {
|
58 |
+
|
59 |
+
## update plugin options
|
60 |
+
if ( ! empty( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'],
|
61 |
+
'pys_update_options' ) && isset( $_POST['pys'] )
|
62 |
+
) {
|
63 |
+
update_option( 'pixel_your_site', $_POST['pys'] );
|
64 |
+
}
|
65 |
+
|
66 |
+
## delete standard events
|
67 |
+
if ( isset( $_GET['action'] ) && $_GET['action'] == 'pys_delete_events'
|
68 |
+
&& isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'pys_delete_events' )
|
69 |
+
&& isset( $_GET['events_ids'] ) && isset( $_GET['events_type'] )
|
70 |
+
) {
|
71 |
+
|
72 |
+
pys_delete_events( $_GET['events_ids'], $_GET['events_type'] );
|
73 |
+
|
74 |
+
$redirect_to = add_query_arg(
|
75 |
+
array(
|
76 |
+
'page' => 'pixel-your-site',
|
77 |
+
'active_tab' => $_GET['events_type'] == 'standard' ? 'posts-events' : 'dynamic-events',
|
78 |
+
),
|
79 |
+
admin_url( 'admin.php' )
|
80 |
+
);
|
81 |
+
|
82 |
+
wp_safe_redirect( $redirect_to );
|
83 |
+
|
84 |
+
}
|
85 |
+
|
86 |
+
include 'html-admin.php';
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
if ( ! function_exists( 'pys_restrict_admin_pages' ) ) {
|
93 |
+
|
94 |
+
function pys_restrict_admin_pages() {
|
95 |
+
|
96 |
+
$screen = get_current_screen();
|
97 |
+
|
98 |
+
if ( $screen->id == 'toplevel_page_pixel-your-site' & false == current_user_can( 'manage_options' ) ) {
|
99 |
+
wp_die( __( 'Sorry, you are not allowed to access this page.' ) );
|
100 |
+
}
|
101 |
+
|
102 |
+
}
|
103 |
+
|
104 |
+
add_action( 'current_screen', 'pys_restrict_admin_pages' );
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
if ( ! function_exists( 'pys_admin_scripts' ) ) {
|
109 |
+
|
110 |
+
add_action( 'admin_enqueue_scripts', 'pys_admin_scripts' );
|
111 |
+
function pys_admin_scripts() {
|
112 |
+
|
113 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'pixel-your-site' ) {
|
114 |
+
|
115 |
+
add_thickbox();
|
116 |
+
|
117 |
+
wp_enqueue_style( 'pys', plugins_url( 'pixelyoursite/css/admin.css' ), array(), PYS_FREE_VERSION );
|
118 |
+
wp_enqueue_script( 'pys-admin', plugins_url( 'pixelyoursite/js/admin.js' ), array( 'jquery' ),
|
119 |
+
PYS_FREE_VERSION );
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
if ( ! function_exists( 'pys_public_scripts' ) ) {
|
128 |
+
|
129 |
+
function pys_public_scripts() {
|
130 |
+
|
131 |
+
$in_footer = (bool) pys_get_option( 'general', 'in_footer', false );
|
132 |
+
|
133 |
+
wp_enqueue_script( 'pys-public', plugins_url( 'pixelyoursite/js/public.js' ), array( 'jquery' ), PYS_FREE_VERSION,
|
134 |
+
$in_footer );
|
135 |
+
|
136 |
+
}
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
add_action( 'plugins_loaded', 'pys_free_init' );
|
141 |
+
function pys_free_init() {
|
142 |
+
|
143 |
+
require_once 'integrations/facebook-for-woocommerce.php';
|
144 |
+
|
145 |
+
$options = get_option( 'pixel_your_site' );
|
146 |
+
if ( ! $options || ! isset( $options['general']['pixel_id'] ) || empty( $options['general']['pixel_id'] ) ) {
|
147 |
+
pys_initialize_settings();
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( is_admin() || pys_get_option( 'general',
|
151 |
+
'enabled' ) == false || pys_is_disabled_for_role() || ! pys_get_option( 'general', 'pixel_id' )
|
152 |
+
) {
|
153 |
+
return;
|
154 |
+
}
|
155 |
+
|
156 |
+
add_action( 'wp_enqueue_scripts', 'pys_public_scripts' );
|
157 |
+
add_action( 'wp_head', 'pys_head_comments', 10 );
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Hooks call priority:
|
161 |
+
* wp_head:
|
162 |
+
* 1 - pixel events options - PRO only;
|
163 |
+
* 2 - init event;
|
164 |
+
* 3 - evaluate events;
|
165 |
+
* 4 - output events;
|
166 |
+
* 9 (20) - enqueue public scripts (head/footer);
|
167 |
+
* wp_footer
|
168 |
+
*/
|
169 |
+
|
170 |
+
add_action( 'wp_head', 'pys_pixel_init_event', 2 );
|
171 |
+
|
172 |
+
add_action( 'wp_head', 'pys_page_view_event', 3 );
|
173 |
+
add_action( 'wp_head', 'pys_general_event', 3 );
|
174 |
+
add_action( 'wp_head', 'pys_search_event', 3 );
|
175 |
+
add_action( 'wp_head', 'pys_standard_events', 3 );
|
176 |
+
add_action( 'wp_head', 'pys_woocommerce_events', 3 );
|
177 |
+
add_action( 'wp_head', 'pys_edd_events', 3 );
|
178 |
+
|
179 |
+
add_action( 'wp_head', 'pys_output_js_events_code', 4 );
|
180 |
+
add_action( 'wp_head', 'pys_output_custom_events_code', 4 );
|
181 |
+
|
182 |
+
add_action( 'wp_footer', 'pys_output_noscript_code', 10 );
|
183 |
+
add_action( 'wp_footer', 'pys_output_woo_ajax_events_code', 10 );
|
184 |
+
add_action( 'wp_footer', 'pys_output_edd_ajax_events_code', 10 );
|
185 |
+
|
186 |
+
// woocommerce shop page add_to_cart
|
187 |
+
if ( pys_get_option( 'woo', 'enabled' ) && pys_get_option( 'woo', 'on_add_to_cart_btn' ) ) {
|
188 |
+
add_filter( 'woocommerce_loop_add_to_cart_link', 'pys_add_code_to_woo_cart_link', 10, 2 );
|
189 |
+
}
|
190 |
+
|
191 |
+
## add pixel code to EDD add_to_cart buttons
|
192 |
+
if ( pys_get_option( 'edd', 'enabled' ) && pys_get_option( 'edd', 'on_add_to_cart_btn', false ) ) {
|
193 |
+
add_filter( 'edd_purchase_link_args', 'pys_edd_purchase_link_args', 10, 1 );
|
194 |
+
}
|
195 |
+
|
196 |
+
add_filter( 'pys_event_params', 'pys_add_domain_param', 10, 2 );
|
197 |
+
|
198 |
+
}
|
inc/html-tab-woo-general.php
CHANGED
@@ -22,27 +22,28 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
22 |
</tr>
|
23 |
|
24 |
<?php do_action( 'pys_fb_pixel_admin_woo_content_id_before' ); ?>
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
46 |
|
47 |
<tr>
|
48 |
<td></td>
|
22 |
</tr>
|
23 |
|
24 |
<?php do_action( 'pys_fb_pixel_admin_woo_content_id_before' ); ?>
|
25 |
+
|
26 |
+
<tr class="content_id">
|
27 |
+
<td></td>
|
28 |
+
<td>
|
29 |
+
<?php pys_checkbox( 'woo', 'variation_id', null, 'main' ); ?>
|
30 |
+
<?php _e( 'Treat variable products like simple products', 'pys' ); ?>
|
31 |
+
|
32 |
+
<span class="help">Turn this option ON when your Product Catalog doesn't include the variants for variable products.</span>
|
33 |
+
</td>
|
34 |
+
</tr>
|
35 |
+
|
36 |
+
<tr class="content_id">
|
37 |
+
<td class="alignright"><p class="label">content_ids:</p></td>
|
38 |
+
<td>
|
39 |
+
<select name="pys[woo][content_id]">
|
40 |
+
<option <?php selected( 'id', pys_get_option( 'woo', 'content_id' ) ); ?> value="id">Product ID
|
41 |
+
</option>
|
42 |
+
<option <?php selected( 'sku', pys_get_option( 'woo', 'content_id' ) ); ?> value="sku">Product SKU
|
43 |
+
</option>
|
44 |
+
</select>
|
45 |
+
</td>
|
46 |
+
</tr>
|
47 |
|
48 |
<tr>
|
49 |
<td></td>
|
inc/integrations/facebook-for-woocommerce.php
CHANGED
@@ -2,17 +2,22 @@
|
|
2 |
|
3 |
/**
|
4 |
* Manage integration with Facebook for WooCommerce plugin.
|
|
|
|
|
|
|
|
|
5 |
*/
|
6 |
|
7 |
if ( ! defined( 'ABSPATH' ) ) {
|
8 |
exit; // Exit if accessed directly.
|
9 |
}
|
10 |
|
11 |
-
/**
|
12 |
-
* Create fake WC_Facebookcommerce_EventsTracker class to remove all unwanted front-end pixel events.
|
13 |
-
*/
|
14 |
if ( class_exists( 'WC_Facebookcommerce' ) && ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
|
15 |
|
|
|
|
|
|
|
|
|
16 |
/** @noinspection PhpUndefinedClassInspection */
|
17 |
class WC_Facebookcommerce_EventsTracker {
|
18 |
|
@@ -44,11 +49,12 @@ if ( class_exists( 'WC_Facebookcommerce' ) && ! class_exists( 'WC_Facebookcommer
|
|
44 |
|
45 |
endif;
|
46 |
|
47 |
-
/**
|
48 |
-
* Setup extra hooks.
|
49 |
-
*/
|
50 |
if ( class_exists( 'WC_Facebookcommerce' ) ) :
|
51 |
|
|
|
|
|
|
|
|
|
52 |
add_filter( 'pys_fb_pixel_woo_product_content_id', 'fb_for_woo_pys_fb_pixel_woo_product_content_id', 10, 4 );
|
53 |
function fb_for_woo_pys_fb_pixel_woo_product_content_id( $content_id, $product_id, $content_id_format ) {
|
54 |
|
@@ -56,11 +62,19 @@ if ( class_exists( 'WC_Facebookcommerce' ) ) :
|
|
56 |
if( $content_id_format !== 'facebook_for_woocommerce' ) {
|
57 |
return $content_id;
|
58 |
}
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
}
|
66 |
|
2 |
|
3 |
/**
|
4 |
* Manage integration with Facebook for WooCommerce plugin.
|
5 |
+
*
|
6 |
+
* When Facebook for WooCommerce is activated this integration completely removes
|
7 |
+
* default Facebook for WooCommerce pixels and replaces them with PYS's. Also, new "Pixel ID format" option added to
|
8 |
+
* PYS WooCommerce tab where user can decide what format to use in pixel: PYS default or Facebook for WooCommerce.
|
9 |
*/
|
10 |
|
11 |
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
exit; // Exit if accessed directly.
|
13 |
}
|
14 |
|
|
|
|
|
|
|
15 |
if ( class_exists( 'WC_Facebookcommerce' ) && ! class_exists( 'WC_Facebookcommerce_EventsTracker' ) ) :
|
16 |
|
17 |
+
/**
|
18 |
+
* Declare fake WC_Facebookcommerce_EventsTracker class to remove all unwanted front-end pixel events.
|
19 |
+
*/
|
20 |
+
|
21 |
/** @noinspection PhpUndefinedClassInspection */
|
22 |
class WC_Facebookcommerce_EventsTracker {
|
23 |
|
49 |
|
50 |
endif;
|
51 |
|
|
|
|
|
|
|
52 |
if ( class_exists( 'WC_Facebookcommerce' ) ) :
|
53 |
|
54 |
+
/**
|
55 |
+
* Setup PYS hooks and filters for Facebook for WooCommerce related options and pixel ID output format.
|
56 |
+
*/
|
57 |
+
|
58 |
add_filter( 'pys_fb_pixel_woo_product_content_id', 'fb_for_woo_pys_fb_pixel_woo_product_content_id', 10, 4 );
|
59 |
function fb_for_woo_pys_fb_pixel_woo_product_content_id( $content_id, $product_id, $content_id_format ) {
|
60 |
|
62 |
if( $content_id_format !== 'facebook_for_woocommerce' ) {
|
63 |
return $content_id;
|
64 |
}
|
65 |
+
|
66 |
+
$ids = array(
|
67 |
+
'wc_post_id_' . $product_id
|
68 |
+
);
|
69 |
+
|
70 |
+
if ( $sku = get_post_meta( $product_id, '_sku', true ) ) {
|
71 |
+
|
72 |
+
$ids[] = $sku;
|
73 |
+
$ids[] = 'wc_post_id_' . $sku;
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
return $ids;
|
78 |
|
79 |
}
|
80 |
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: PixelYourSite, c0d3fev3r, themister
|
3 |
Tags: Facebook Pixel, New Facebook Pixel, Facebook Conversion Pixel, Facebook Pixel Events, Facebook, New Facebook Pixel Events, Dynamic Events, Standard Events, Facebook Events, Facebook Standard Events, Facebook Dynamic Product Ads, WooCommerce, WooCommerce Facebook Pixel, Facebook Custom Events, Facebook Conversion Value, WooCommerce Affiliate Products, Easy Digital Downloads Pixel, Easy Digital Downloads Facebook Pixel
|
4 |
Requires at least: 3.0.1
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 5.0.
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -318,6 +318,16 @@ We have an article about how to create Custom Reports:
|
|
318 |
|
319 |
== Changelog ==
|
320 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
321 |
= PixelYourSite 5.0.4 =
|
322 |
|
323 |
* Changed WooCommerce ViewContent event content_type to product_group for variable products
|
2 |
Contributors: PixelYourSite, c0d3fev3r, themister
|
3 |
Tags: Facebook Pixel, New Facebook Pixel, Facebook Conversion Pixel, Facebook Pixel Events, Facebook, New Facebook Pixel Events, Dynamic Events, Standard Events, Facebook Events, Facebook Standard Events, Facebook Dynamic Product Ads, WooCommerce, WooCommerce Facebook Pixel, Facebook Custom Events, Facebook Conversion Value, WooCommerce Affiliate Products, Easy Digital Downloads Pixel, Easy Digital Downloads Facebook Pixel
|
4 |
Requires at least: 3.0.1
|
5 |
+
Tested up to: 4.8
|
6 |
+
Stable tag: 5.0.5.2
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
318 |
|
319 |
== Changelog ==
|
320 |
|
321 |
+
= PixelYourSite 5.0.5.2 =
|
322 |
+
|
323 |
+
|
324 |
+
* Quick fix for a small error with our previous release (we didn't included all the files)
|
325 |
+
|
326 |
+
|
327 |
+
= PixelYourSite 5.0.5 =
|
328 |
+
|
329 |
+
* Treat WooCommerce variable products like simple products - useful if your Product Catalog doesn't include variations. When ON, ViewContent content_type will be product and the main item ID will be used for all events instead of the variation item.
|
330 |
+
|
331 |
= PixelYourSite 5.0.4 =
|
332 |
|
333 |
* Changed WooCommerce ViewContent event content_type to product_group for variable products
|