Version Description
Download this release
Release Info
Developer | PixelYourSite |
Plugin | PixelYourSite – Facebook Pixel (Events, WooCommerce & Easy Digital Downloads) |
Version | 7.1.6 |
Comparing to | |
See all releases |
Code changes from version 7.1.4 to 7.1.6
- dist/scripts/admin.js +23 -0
- dist/scripts/public.js +147 -0
- facebook-pixel-master.php +2 -2
- includes/class-events-manager.php +67 -2
- includes/class-pys.php +8 -3
- includes/class-settings.php +4 -1
- includes/functions-admin.php +76 -0
- includes/functions-common.php +207 -0
- includes/functions-custom-event.php +4 -3
- includes/functions-woo.php +71 -1
- includes/views/html-main-events-edit.php +11 -1
- includes/views/html-main-general.php +86 -0
- includes/views/html-main-woo.php +60 -0
- modules/facebook/FDPEvent.php +33 -0
- modules/facebook/facebook.php +94 -4
- modules/facebook/function-helpers.php +105 -2
- modules/facebook/options_defaults.json +12 -1
- modules/facebook/options_fields.json +11 -1
- modules/google_analytics/ga.php +53 -18
- modules/head_footer/head_footer.php +1 -1
- pixelyoursite.php +24 -24
- readme.txt +27 -4
dist/scripts/admin.js
CHANGED
@@ -1,2 +1,25 @@
|
|
1 |
|
2 |
jQuery(document).ready(function(c){function n(e){var t=c("#"+e.data("target"));e.val()===e.data("value")?t.removeClass("form-control-hidden"):t.addClass("form-control-hidden")}function e(){"price"===c('input[name="pys[core][woo_event_value]"]:checked').val()?c(".woo-event-value-option").hide():c(".woo-event-value-option").show()}function t(){"price"===c('input[name="pys[core][edd_event_value]"]:checked').val()?c(".edd-event-value-option").hide():c(".edd-event-value-option").show()}function a(){var e=c("#pys_event_trigger_type").val(),t="#"+e+"_panel";c(".event_triggers_panel").hide(),c(t).show(),"page_visit"===e?c("#url_filter_panel").hide():c("#url_filter_panel").show();var n=c(t),a=n.data("trigger_type");0===c(".event_trigger",n).length-1&&s(n,a)}function s(e,t){var n=c(".event_trigger",e),a=c(n[0]).clone(!0),s=c(n[n.length-1]).data("trigger_id")+1,i="pys[event]["+t+"_triggers]["+s+"]";a.data("trigger_id",s),c("select",a).attr("name",i+"[rule]"),c("input",a).attr("name",i+"[value]"),a.css("display","block"),a.insertBefore(c(".insert-marker",e))}function i(){"page_visit"===c("#pys_event_trigger_type").val()?c(".event-delay").css("visibility","visible"):c(".event-delay").css("visibility","hidden")}function o(){c("#pys_event_facebook_enabled").is(":checked")?c("#facebook_panel").show():c("#facebook_panel").hide()}function r(){"CustomEvent"===c("#pys_event_facebook_event_type").val()?c(".facebook-custom-event-type").css("visibility","visible"):c(".facebook-custom-event-type").css("visibility","hidden")}function p(){c("#pys_event_facebook_params_enabled").is(":checked")?c("#facebook_params_panel").show():c("#facebook_params_panel").hide()}function _(){var e=c("#pys_event_facebook_event_type").val();c("#facebook_params_panel").removeClass().addClass(e)}function l(){"custom"===c("#pys_event_facebook_params_currency").val()?c(".facebook-custom-currency").css("visibility","visible"):c(".facebook-custom-currency").css("visibility","hidden")}function v(){c("#pys_event_pinterest_enabled").is(":checked")?c("#pinterest_panel").show():c("#pinterest_panel").hide()}function u(){"CustomEvent"===c("#pys_event_pinterest_event_type").val()?c(".pinterest-custom-event-type").css("visibility","visible"):c(".pinterest-custom-event-type").css("visibility","hidden")}function d(){c("#pys_event_pinterest_params_enabled").is(":checked")?c("#pinterest_params_panel").show():c("#pinterest_params_panel").hide()}function y(){var e=c("#pys_event_pinterest_event_type").val();c("#pinterest_params_panel").removeClass().addClass(e)}function m(){"custom"===c("#pys_event_pinterest_params_currency").val()?c(".pinterest-custom-currency").css("visibility","visible"):c(".pinterest-custom-currency").css("visibility","hidden")}function f(){c("#pys_event_ga_enabled").is(":checked")?c("#analytics_panel").show():c("#analytics_panel").hide()}function h(){"_custom"===c("#pys_event_ga_event_action").val()?c("#ga-custom-action").css("visibility","visible"):c("#ga-custom-action").css("visibility","hidden")}function g(){c("#pys_event_bing_enabled").is(":checked")?c("#bing_panel").show():c("#bing_panel").hide()}c(function(){c('[data-toggle="pys-popover"]').popover({container:"#pys",html:!0,content:function(){return c("#pys-"+c(this).data("popover_id")).html()}})}),c(".pys-select2").select2(),c(".pys-tags-select2").select2({tags:!0,tokenSeparators:[","," "]}),c("select.controls-visibility").on("change",function(e){n(c(this))}).each(function(e,t){n(c(t))}),c(".card-collapse").click(function(){var e=c(this).closest(".card").find(".card-body");e.hasClass("show")?e.hide().removeClass("show"):e.show().addClass("show")}),c(".collapse-control .custom-switch-input").change(function(){var e=c(this),t=c("."+e.data("target"));0<t.length&&(e.prop("checked")?t.show():t.hide())}).trigger("change"),e(),c('input[name="pys[core][woo_event_value]"]').change(function(){e()}),t(),c('input[name="pys[core][edd_event_value]"]').change(function(){t()}),c("#pys_select_all_events").change(function(){c(this).prop("checked")?c(".pys-select-event").prop("checked","checked"):c(".pys-select-event").prop("checked",!1)}),i(),a(),c("#pys_event_trigger_type").change(function(){i(),a()}),c(".add-event-trigger").click(function(){var e=c(this).closest(".event_triggers_panel");s(e,e.data("trigger_type"))}),c(".remove-row").click(function(e){c(this).closest(".row.event_trigger, .row.facebook-custom-param, .row.pinterest-custom-param").remove()}),o(),r(),p(),_(),l(),c("#pys_event_facebook_enabled").click(function(){o()}),c("#pys_event_facebook_event_type").change(function(){r(),_()}),c("#pys_event_facebook_params_enabled").click(function(){p()}),c("#pys_event_facebook_params_currency").change(function(){l()}),c(".add-facebook-parameter").click(function(){var e=c("#facebook_params_panel"),t=c(".facebook-custom-param",e),n=c(t[0]).clone(!0),a=c(t[t.length-1]).data("param_id")+1,s="pys[event][facebook_custom_params]["+a+"]";n.data("param_id",a),c("input.custom-param-name",n).attr("name",s+"[name]"),c("input.custom-param-value",n).attr("name",s+"[value]"),n.css("display","flex"),n.insertBefore(c(".insert-marker",e))}),v(),u(),d(),y(),m(),c("#pys_event_pinterest_enabled").click(function(){v()}),c("#pys_event_pinterest_event_type").change(function(){u(),y()}),c("#pys_event_pinterest_params_enabled").click(function(){d()}),c("#pys_event_pinterest_params_currency").change(function(){m()}),c(".add-pinterest-parameter").click(function(){var e=c("#pinterest_params_panel"),t=c(".pinterest-custom-param",e),n=c(t[0]).clone(!0),a=c(t[t.length-1]).data("param_id")+1,s="pys[event][pinterest_custom_params]["+a+"]";n.data("param_id",a),c("input.custom-param-name",n).attr("name",s+"[name]"),c("input.custom-param-value",n).attr("name",s+"[value]"),n.css("display","flex"),n.insertBefore(c(".insert-marker",e))}),f(),h(),c("#pys_event_ga_enabled").click(function(){f()}),c("#pys_event_ga_event_action").change(function(){h()}),g(),c("#pys_event_bing_enabled").click(function(){g()})});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
jQuery(document).ready(function(c){function n(e){var t=c("#"+e.data("target"));e.val()===e.data("value")?t.removeClass("form-control-hidden"):t.addClass("form-control-hidden")}function e(){"price"===c('input[name="pys[core][woo_event_value]"]:checked').val()?c(".woo-event-value-option").hide():c(".woo-event-value-option").show()}function t(){"price"===c('input[name="pys[core][edd_event_value]"]:checked').val()?c(".edd-event-value-option").hide():c(".edd-event-value-option").show()}function a(){var e=c("#pys_event_trigger_type").val(),t="#"+e+"_panel";c(".event_triggers_panel").hide(),c(t).show(),"page_visit"===e?c("#url_filter_panel").hide():c("#url_filter_panel").show();var n=c(t),a=n.data("trigger_type");0===c(".event_trigger",n).length-1&&s(n,a)}function s(e,t){var n=c(".event_trigger",e),a=c(n[0]).clone(!0),s=c(n[n.length-1]).data("trigger_id")+1,i="pys[event]["+t+"_triggers]["+s+"]";a.data("trigger_id",s),c("select",a).attr("name",i+"[rule]"),c("input",a).attr("name",i+"[value]"),a.css("display","block"),a.insertBefore(c(".insert-marker",e))}function i(){"page_visit"===c("#pys_event_trigger_type").val()?c(".event-delay").css("visibility","visible"):c(".event-delay").css("visibility","hidden")}function o(){c("#pys_event_facebook_enabled").is(":checked")?c("#facebook_panel").show():c("#facebook_panel").hide()}function r(){"CustomEvent"===c("#pys_event_facebook_event_type").val()?c(".facebook-custom-event-type").css("visibility","visible"):c(".facebook-custom-event-type").css("visibility","hidden")}function p(){c("#pys_event_facebook_params_enabled").is(":checked")?c("#facebook_params_panel").show():c("#facebook_params_panel").hide()}function _(){var e=c("#pys_event_facebook_event_type").val();c("#facebook_params_panel").removeClass().addClass(e)}function l(){"custom"===c("#pys_event_facebook_params_currency").val()?c(".facebook-custom-currency").css("visibility","visible"):c(".facebook-custom-currency").css("visibility","hidden")}function v(){c("#pys_event_pinterest_enabled").is(":checked")?c("#pinterest_panel").show():c("#pinterest_panel").hide()}function u(){"CustomEvent"===c("#pys_event_pinterest_event_type").val()?c(".pinterest-custom-event-type").css("visibility","visible"):c(".pinterest-custom-event-type").css("visibility","hidden")}function d(){c("#pys_event_pinterest_params_enabled").is(":checked")?c("#pinterest_params_panel").show():c("#pinterest_params_panel").hide()}function y(){var e=c("#pys_event_pinterest_event_type").val();c("#pinterest_params_panel").removeClass().addClass(e)}function m(){"custom"===c("#pys_event_pinterest_params_currency").val()?c(".pinterest-custom-currency").css("visibility","visible"):c(".pinterest-custom-currency").css("visibility","hidden")}function f(){c("#pys_event_ga_enabled").is(":checked")?c("#analytics_panel").show():c("#analytics_panel").hide()}function h(){"_custom"===c("#pys_event_ga_event_action").val()?c("#ga-custom-action").css("visibility","visible"):c("#ga-custom-action").css("visibility","hidden")}function g(){c("#pys_event_bing_enabled").is(":checked")?c("#bing_panel").show():c("#bing_panel").hide()}c(function(){c('[data-toggle="pys-popover"]').popover({container:"#pys",html:!0,content:function(){return c("#pys-"+c(this).data("popover_id")).html()}})}),c(".pys-select2").select2(),c(".pys-tags-select2").select2({tags:!0,tokenSeparators:[","," "]}),c("select.controls-visibility").on("change",function(e){n(c(this))}).each(function(e,t){n(c(t))}),c(".card-collapse").click(function(){var e=c(this).closest(".card").find(".card-body");e.hasClass("show")?e.hide().removeClass("show"):e.show().addClass("show")}),c(".collapse-control .custom-switch-input").change(function(){var e=c(this),t=c("."+e.data("target"));0<t.length&&(e.prop("checked")?t.show():t.hide())}).trigger("change"),e(),c('input[name="pys[core][woo_event_value]"]').change(function(){e()}),t(),c('input[name="pys[core][edd_event_value]"]').change(function(){t()}),c("#pys_select_all_events").change(function(){c(this).prop("checked")?c(".pys-select-event").prop("checked","checked"):c(".pys-select-event").prop("checked",!1)}),i(),a(),c("#pys_event_trigger_type").change(function(){i(),a()}),c(".add-event-trigger").click(function(){var e=c(this).closest(".event_triggers_panel");s(e,e.data("trigger_type"))}),c(".remove-row").click(function(e){c(this).closest(".row.event_trigger, .row.facebook-custom-param, .row.pinterest-custom-param").remove()}),o(),r(),p(),_(),l(),c("#pys_event_facebook_enabled").click(function(){o()}),c("#pys_event_facebook_event_type").change(function(){r(),_()}),c("#pys_event_facebook_params_enabled").click(function(){p()}),c("#pys_event_facebook_params_currency").change(function(){l()}),c(".add-facebook-parameter").click(function(){var e=c("#facebook_params_panel"),t=c(".facebook-custom-param",e),n=c(t[0]).clone(!0),a=c(t[t.length-1]).data("param_id")+1,s="pys[event][facebook_custom_params]["+a+"]";n.data("param_id",a),c("input.custom-param-name",n).attr("name",s+"[name]"),c("input.custom-param-value",n).attr("name",s+"[value]"),n.css("display","flex"),n.insertBefore(c(".insert-marker",e))}),v(),u(),d(),y(),m(),c("#pys_event_pinterest_enabled").click(function(){v()}),c("#pys_event_pinterest_event_type").change(function(){u(),y()}),c("#pys_event_pinterest_params_enabled").click(function(){d()}),c("#pys_event_pinterest_params_currency").change(function(){m()}),c(".add-pinterest-parameter").click(function(){var e=c("#pinterest_params_panel"),t=c(".pinterest-custom-param",e),n=c(t[0]).clone(!0),a=c(t[t.length-1]).data("param_id")+1,s="pys[event][pinterest_custom_params]["+a+"]";n.data("param_id",a),c("input.custom-param-name",n).attr("name",s+"[name]"),c("input.custom-param-value",n).attr("name",s+"[value]"),n.css("display","flex"),n.insertBefore(c(".insert-marker",e))}),f(),h(),c("#pys_event_ga_enabled").click(function(){f()}),c("#pys_event_ga_event_action").change(function(){h()}),g(),c("#pys_event_bing_enabled").click(function(){g()})});
|
3 |
+
|
4 |
+
jQuery( document ).ready(function($) {
|
5 |
+
updateFDPValue($("#pys_facebook_fdp_purchase_event_fire"));
|
6 |
+
$("#pys_facebook_fdp_purchase_event_fire").change(function () {
|
7 |
+
|
8 |
+
updateFDPValue(this);
|
9 |
+
});
|
10 |
+
|
11 |
+
|
12 |
+
function updateFDPValue(input) {
|
13 |
+
if($(input).val() == "scroll_pos") {
|
14 |
+
$("#fdp_purchase_event_fire_scroll_block").show();
|
15 |
+
$("#pys_facebook_fdp_purchase_event_fire_css").hide()
|
16 |
+
} else if($(input).val() == "css_click") {
|
17 |
+
$("#fdp_purchase_event_fire_scroll_block").hide();
|
18 |
+
$("#pys_facebook_fdp_purchase_event_fire_css").show()
|
19 |
+
} else {
|
20 |
+
$("#fdp_purchase_event_fire_scroll_block").hide();
|
21 |
+
$("#pys_facebook_fdp_purchase_event_fire_css").hide()
|
22 |
+
}
|
23 |
+
}
|
24 |
+
});
|
25 |
+
|
dist/scripts/public.js
CHANGED
@@ -233,10 +233,128 @@ if (!Array.prototype.includes) {
|
|
233 |
return [];
|
234 |
},
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
/**
|
237 |
* Events
|
238 |
*/
|
239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
240 |
fireStaticEvents: function (pixel) {
|
241 |
|
242 |
if (options.staticEvents.hasOwnProperty(pixel)) {
|
@@ -1110,6 +1228,35 @@ if (!Array.prototype.includes) {
|
|
1110 |
|
1111 |
Utils.setupGdprCallbacks();
|
1112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1113 |
// setup WooCommerce events
|
1114 |
if (options.woo.enabled) {
|
1115 |
|
233 |
return [];
|
234 |
},
|
235 |
|
236 |
+
/**
|
237 |
+
* CUSTOM EVENTS
|
238 |
+
*/
|
239 |
+
|
240 |
+
setupMouseOverClickEvents: function (eventId, triggers) {
|
241 |
+
|
242 |
+
// Non-default binding used to avoid situations when some code in external js
|
243 |
+
// stopping events propagation, eg. returns false, and our handler will never called
|
244 |
+
$(document).onFirst('mouseover', triggers.join(','), function () {
|
245 |
+
|
246 |
+
// do not fire event multiple times
|
247 |
+
if ($(this).hasClass('pys-mouse-over-' + eventId)) {
|
248 |
+
return true;
|
249 |
+
} else {
|
250 |
+
$(this).addClass('pys-mouse-over-' + eventId);
|
251 |
+
}
|
252 |
+
|
253 |
+
Utils.fireDynamicEvent(eventId);
|
254 |
+
|
255 |
+
});
|
256 |
+
|
257 |
+
},
|
258 |
+
|
259 |
+
setupCSSClickEvents: function (eventId, triggers) {
|
260 |
+
|
261 |
+
// Non-default binding used to avoid situations when some code in external js
|
262 |
+
// stopping events propagation, eg. returns false, and our handler will never called
|
263 |
+
$(document).onFirst('click', triggers.join(','), function () {
|
264 |
+
Utils.fireDynamicEvent(eventId);
|
265 |
+
});
|
266 |
+
|
267 |
+
},
|
268 |
+
|
269 |
+
setupURLClickEvents: function () {
|
270 |
+
|
271 |
+
// Non-default binding used to avoid situations when some code in external js
|
272 |
+
// stopping events propagation, eg. returns false, and our handler will never called
|
273 |
+
$('a[data-pys-event-id]').onFirst('click', function (evt) {
|
274 |
+
|
275 |
+
$(this).attr('data-pys-event-id').split(',').forEach(function (eventId) {
|
276 |
+
|
277 |
+
eventId = parseInt(eventId);
|
278 |
+
|
279 |
+
if (isNaN(eventId) === false) {
|
280 |
+
Utils.fireDynamicEvent(eventId);
|
281 |
+
}
|
282 |
+
|
283 |
+
});
|
284 |
+
|
285 |
+
});
|
286 |
+
|
287 |
+
},
|
288 |
+
|
289 |
+
setupScrollPosEvents: function (eventId, triggers) {
|
290 |
+
|
291 |
+
var scrollPosThresholds = {},
|
292 |
+
docHeight = $(document).height() - $(window).height();
|
293 |
+
|
294 |
+
// convert % to absolute positions
|
295 |
+
$.each(triggers, function (index, scrollPos) {
|
296 |
+
|
297 |
+
// convert % to pixels
|
298 |
+
scrollPos = docHeight * scrollPos / 100;
|
299 |
+
scrollPos = Math.round(scrollPos);
|
300 |
+
|
301 |
+
scrollPosThresholds[scrollPos] = eventId;
|
302 |
+
|
303 |
+
});
|
304 |
+
|
305 |
+
$(document).scroll(function () {
|
306 |
+
|
307 |
+
var scrollPos = $(window).scrollTop();
|
308 |
+
|
309 |
+
$.each(scrollPosThresholds, function (threshold, eventId) {
|
310 |
+
|
311 |
+
// position has not reached yes
|
312 |
+
if (scrollPos <= threshold) {
|
313 |
+
return true;
|
314 |
+
}
|
315 |
+
|
316 |
+
// fire event only once
|
317 |
+
if (eventId === null) {
|
318 |
+
return true;
|
319 |
+
} else {
|
320 |
+
scrollPosThresholds[threshold] = null;
|
321 |
+
}
|
322 |
+
|
323 |
+
Utils.fireDynamicEvent(eventId);
|
324 |
+
|
325 |
+
});
|
326 |
+
|
327 |
+
});
|
328 |
+
|
329 |
+
},
|
330 |
+
setupCommentEvents : function (eventId,triggers) {
|
331 |
+
$('form.comment-form').submit(function () {
|
332 |
+
Utils.fireDynamicEvent(eventId);
|
333 |
+
});
|
334 |
+
},
|
335 |
+
|
336 |
/**
|
337 |
* Events
|
338 |
*/
|
339 |
|
340 |
+
fireDynamicEvent: function (eventId) {
|
341 |
+
|
342 |
+
if (!options.dynamicEventsParams.hasOwnProperty(eventId)) {
|
343 |
+
return;
|
344 |
+
}
|
345 |
+
|
346 |
+
var event = {};
|
347 |
+
|
348 |
+
if (options.dynamicEventsParams[eventId].hasOwnProperty('facebook')) {
|
349 |
+
|
350 |
+
event = Utils.copyProperties(options.dynamicEventsParams[eventId]['facebook'], {});
|
351 |
+
Facebook.fireEvent(event.name, { params: event.params });
|
352 |
+
}
|
353 |
+
|
354 |
+
|
355 |
+
|
356 |
+
},
|
357 |
+
|
358 |
fireStaticEvents: function (pixel) {
|
359 |
|
360 |
if (options.staticEvents.hasOwnProperty(pixel)) {
|
1228 |
|
1229 |
Utils.setupGdprCallbacks();
|
1230 |
|
1231 |
+
// setup Dynamic events
|
1232 |
+
$.each(options.dynamicEventsTriggers, function (triggerType, events) {
|
1233 |
+
|
1234 |
+
$.each(events, function (eventId, triggers) {
|
1235 |
+
|
1236 |
+
switch (triggerType) {
|
1237 |
+
case 'url_click':
|
1238 |
+
//@see: Utils.setupURLClickEvents()
|
1239 |
+
break;
|
1240 |
+
|
1241 |
+
case 'css_click':
|
1242 |
+
Utils.setupCSSClickEvents(eventId, triggers);
|
1243 |
+
break;
|
1244 |
+
|
1245 |
+
case 'css_mouseover':
|
1246 |
+
Utils.setupMouseOverClickEvents(eventId, triggers);
|
1247 |
+
break;
|
1248 |
+
|
1249 |
+
case 'scroll_pos':
|
1250 |
+
Utils.setupScrollPosEvents(eventId, triggers);
|
1251 |
+
break;
|
1252 |
+
case 'comment':
|
1253 |
+
Utils.setupCommentEvents(eventId, triggers);
|
1254 |
+
break;
|
1255 |
+
}
|
1256 |
+
|
1257 |
+
});
|
1258 |
+
|
1259 |
+
});
|
1260 |
// setup WooCommerce events
|
1261 |
if (options.woo.enabled) {
|
1262 |
|
facebook-pixel-master.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: PixelYourSite
|
5 |
* Plugin URI: http://www.pixelyoursite.com/
|
6 |
* Description: No codding <strong>Facebook Pixel</strong> and <strong>Google Analytics</strong> install. Track key actions with our Global Events, or configure your own events. WooCommerce and EDD fully supported, with Facebook Dynamic Ads Pixel set-up and Google Analytics Enhanced Ecommerce. Insert any custom script with our Head & Footer option. Add the <strong>Pinterest Tag</strong> with our free add-on. The PRO version adds support for the Google Ads tag plus a lot of extra stuff.
|
7 |
-
* Version: 7.1.
|
8 |
* Author: PixelYourSite
|
9 |
* Author URI: http://www.pixelyoursite.com
|
10 |
* License: GPLv3
|
@@ -13,7 +13,7 @@
|
|
13 |
* Tested up to: 5.3
|
14 |
*
|
15 |
* WC requires at least: 2.6.0
|
16 |
-
* WC tested up to:
|
17 |
*
|
18 |
* Text Domain: pys
|
19 |
*/
|
4 |
* Plugin Name: PixelYourSite
|
5 |
* Plugin URI: http://www.pixelyoursite.com/
|
6 |
* Description: No codding <strong>Facebook Pixel</strong> and <strong>Google Analytics</strong> install. Track key actions with our Global Events, or configure your own events. WooCommerce and EDD fully supported, with Facebook Dynamic Ads Pixel set-up and Google Analytics Enhanced Ecommerce. Insert any custom script with our Head & Footer option. Add the <strong>Pinterest Tag</strong> with our free add-on. The PRO version adds support for the Google Ads tag plus a lot of extra stuff.
|
7 |
+
* Version: 7.1.6
|
8 |
* Author: PixelYourSite
|
9 |
* Author URI: http://www.pixelyoursite.com
|
10 |
* License: GPLv3
|
13 |
* Tested up to: 5.3
|
14 |
*
|
15 |
* WC requires at least: 2.6.0
|
16 |
+
* WC tested up to: 4.0
|
17 |
*
|
18 |
* Text Domain: pys
|
19 |
*/
|
includes/class-events-manager.php
CHANGED
@@ -10,6 +10,8 @@ class EventsManager {
|
|
10 |
|
11 |
public $doingAMP = false;
|
12 |
|
|
|
|
|
13 |
private $staticEvents = array();
|
14 |
|
15 |
public function __construct() {
|
@@ -39,6 +41,8 @@ class EventsManager {
|
|
39 |
|
40 |
$data = array(
|
41 |
'staticEvents' => $this->staticEvents,
|
|
|
|
|
42 |
);
|
43 |
|
44 |
// collect options for configured pixel
|
@@ -140,6 +144,8 @@ class EventsManager {
|
|
140 |
$this->setupCustomEvents();
|
141 |
}
|
142 |
|
|
|
|
|
143 |
if ( isWooCommerceActive() && PYS()->getOption( 'woo_enabled' ) ) {
|
144 |
$this->setupWooCommerceEvents();
|
145 |
}
|
@@ -220,6 +226,63 @@ class EventsManager {
|
|
220 |
}
|
221 |
|
222 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
|
224 |
private function setupWooCommerceEvents() {
|
225 |
|
@@ -340,7 +403,9 @@ class EventsManager {
|
|
340 |
|
341 |
public function setupWooSingleProductData() {
|
342 |
global $product;
|
343 |
-
|
|
|
|
|
344 |
/** @var \WC_Product $product */
|
345 |
if ( isWooCommerceVersionGte( '2.6' ) ) {
|
346 |
$product_id = $product->get_id();
|
@@ -358,7 +423,7 @@ class EventsManager {
|
|
358 |
foreach ( $product->get_available_variations() as $variation ) {
|
359 |
|
360 |
$variation = wc_get_product( $variation['variation_id'] );
|
361 |
-
|
362 |
if ( isWooCommerceVersionGte( '2.6' ) ) {
|
363 |
$product_ids[] = $variation->get_id();
|
364 |
} else {
|
10 |
|
11 |
public $doingAMP = false;
|
12 |
|
13 |
+
private $dynamicEventsParams = array();
|
14 |
+
private $dynamicEventsTriggers = array();
|
15 |
private $staticEvents = array();
|
16 |
|
17 |
public function __construct() {
|
41 |
|
42 |
$data = array(
|
43 |
'staticEvents' => $this->staticEvents,
|
44 |
+
'dynamicEventsParams' => $this->dynamicEventsParams,
|
45 |
+
'dynamicEventsTriggers' => $this->dynamicEventsTriggers,
|
46 |
);
|
47 |
|
48 |
// collect options for configured pixel
|
144 |
$this->setupCustomEvents();
|
145 |
}
|
146 |
|
147 |
+
$this->setupFDPEvents();
|
148 |
+
|
149 |
if ( isWooCommerceActive() && PYS()->getOption( 'woo_enabled' ) ) {
|
150 |
$this->setupWooCommerceEvents();
|
151 |
}
|
226 |
}
|
227 |
|
228 |
}
|
229 |
+
/**
|
230 |
+
* @param FDPEvent $event
|
231 |
+
* @param $triggers
|
232 |
+
*/
|
233 |
+
|
234 |
+
private function addFDPDynamicEvent( $event ) {
|
235 |
+
|
236 |
+
foreach ( PYS()->getRegisteredPixels() as $pixel ) {
|
237 |
+
/** @var Pixel|Settings $pixel */
|
238 |
+
|
239 |
+
$eventData = $pixel->getEventData( 'fdp_event', $event );
|
240 |
+
if ( false === $eventData ) {
|
241 |
+
continue;
|
242 |
+
}
|
243 |
+
|
244 |
+
if ( $pixel->getSlug() == 'facebook' ) {
|
245 |
+
|
246 |
+
$this->dynamicEventsParams[ $event->event_name ]['facebook'] = array(
|
247 |
+
'name' => $eventData['name'],
|
248 |
+
'params' => sanitizeParams( $eventData['data'] ),
|
249 |
+
'hasTimeWindow' => $event->hasTimeWindow(),
|
250 |
+
'timeWindow' => $event->getTimeWindow(),
|
251 |
+
);
|
252 |
+
}
|
253 |
+
|
254 |
+
$this->dynamicEventsTriggers[ $event->trigger_type ][ $event->event_name ][] = $event->trigger_value;
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
private function setupFDPEvents() {
|
259 |
+
|
260 |
+
if(PYS()->getRegisteredPixels()['facebook'] == null ) return;
|
261 |
+
|
262 |
+
$pixel = PYS()->getRegisteredPixels()['facebook'];
|
263 |
+
|
264 |
+
foreach ( $pixel->getFDPEvents() as $event ) {
|
265 |
+
|
266 |
+
if ( 'fdp_view_content' == $event->event_name && is_single()&& get_post_type() == 'post' ) {
|
267 |
+
$this->addStaticEvent( 'fdp_event', $event );
|
268 |
+
}
|
269 |
+
|
270 |
+
if ( 'fdp_view_category' == $event->event_name && is_category() ) {
|
271 |
+
$this->addStaticEvent( 'fdp_event', $event );
|
272 |
+
}
|
273 |
+
|
274 |
+
if ( 'fdp_add_to_cart' == $event->event_name && is_single()&& get_post_type() == 'post' ) {
|
275 |
+
|
276 |
+
$this->addFDPDynamicEvent( $event );
|
277 |
+
}
|
278 |
+
|
279 |
+
if ( 'fdp_purchase' == $event->event_name && is_single()&& get_post_type() == 'post' ) {
|
280 |
+
|
281 |
+
$this->addFDPDynamicEvent( $event );
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
}
|
286 |
|
287 |
private function setupWooCommerceEvents() {
|
288 |
|
403 |
|
404 |
public function setupWooSingleProductData() {
|
405 |
global $product;
|
406 |
+
|
407 |
+
if($product == null) return;
|
408 |
+
|
409 |
/** @var \WC_Product $product */
|
410 |
if ( isWooCommerceVersionGte( '2.6' ) ) {
|
411 |
$product_id = $product->get_id();
|
423 |
foreach ( $product->get_available_variations() as $variation ) {
|
424 |
|
425 |
$variation = wc_get_product( $variation['variation_id'] );
|
426 |
+
if(!$variation) continue;
|
427 |
if ( isWooCommerceVersionGte( '2.6' ) ) {
|
428 |
$product_ids[] = $variation->get_id();
|
429 |
} else {
|
includes/class-pys.php
CHANGED
@@ -475,8 +475,6 @@ final class PYS extends Settings implements Plugin {
|
|
475 |
} else {
|
476 |
$core_options = array();
|
477 |
}
|
478 |
-
|
479 |
-
|
480 |
|
481 |
$gdpr_ajax_enabled = isset( $core_options['gdpr_ajax_enabled'] )
|
482 |
? $core_options['gdpr_ajax_enabled'] // value from form data
|
@@ -484,7 +482,14 @@ final class PYS extends Settings implements Plugin {
|
|
484 |
|
485 |
// allow 3rd party plugins to by-pass option value
|
486 |
$core_options['gdpr_ajax_enabled'] = apply_filters( 'pys_gdpr_ajax_enabled', $gdpr_ajax_enabled );
|
487 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
488 |
// update core options
|
489 |
$this->updateOptions( $core_options );
|
490 |
|
475 |
} else {
|
476 |
$core_options = array();
|
477 |
}
|
|
|
|
|
478 |
|
479 |
$gdpr_ajax_enabled = isset( $core_options['gdpr_ajax_enabled'] )
|
480 |
? $core_options['gdpr_ajax_enabled'] // value from form data
|
482 |
|
483 |
// allow 3rd party plugins to by-pass option value
|
484 |
$core_options['gdpr_ajax_enabled'] = apply_filters( 'pys_gdpr_ajax_enabled', $gdpr_ajax_enabled );
|
485 |
+
|
486 |
+
if (isPixelCogActive() ) {
|
487 |
+
if (isset($core_options['woo_purchase_value_option'])) update_option('woo_purchase_value_cog', $core_options['woo_purchase_value_option']);
|
488 |
+
if (isset($core_options['woo_view_content_value_option'])) update_option('woo_content_value_cog', $core_options['woo_view_content_value_option']);
|
489 |
+
if (isset($core_options['woo_add_to_cart_value_option'])) update_option('woo_add_to_cart_value_cog', $core_options['woo_add_to_cart_value_option']);
|
490 |
+
if (isset($core_options['woo_initiate_checkout_value_option'])) update_option('woo_initiate_checkout_value_cog', $core_options['woo_initiate_checkout_value_option']);
|
491 |
+
}
|
492 |
+
|
493 |
// update core options
|
494 |
$this->updateOptions( $core_options );
|
495 |
|
includes/class-settings.php
CHANGED
@@ -412,7 +412,7 @@ abstract class Settings {
|
|
412 |
* @param $label
|
413 |
* @param bool $disabled
|
414 |
*/
|
415 |
-
public function render_radio_input( $key, $value, $label, $disabled = false ) {
|
416 |
|
417 |
$attr_name = "pys[$this->slug][$key]";
|
418 |
|
@@ -424,6 +424,9 @@ abstract class Settings {
|
|
424 |
value="<?php esc_attr_e( $value ); ?>">
|
425 |
<span class="custom-control-indicator"></span>
|
426 |
<span class="custom-control-description"><?php echo wp_kses_post( $label ); ?></span>
|
|
|
|
|
|
|
427 |
</label>
|
428 |
|
429 |
<?php
|
412 |
* @param $label
|
413 |
* @param bool $disabled
|
414 |
*/
|
415 |
+
public function render_radio_input( $key, $value, $label, $disabled = false, $with_pro_badge = false ) {
|
416 |
|
417 |
$attr_name = "pys[$this->slug][$key]";
|
418 |
|
424 |
value="<?php esc_attr_e( $value ); ?>">
|
425 |
<span class="custom-control-indicator"></span>
|
426 |
<span class="custom-control-description"><?php echo wp_kses_post( $label ); ?></span>
|
427 |
+
<?php if ( $with_pro_badge ) {
|
428 |
+
renderCogBadge();
|
429 |
+
} ?>
|
430 |
</label>
|
431 |
|
432 |
<?php
|
includes/functions-admin.php
CHANGED
@@ -141,6 +141,75 @@ function manageAdminPermissions() {
|
|
141 |
}
|
142 |
|
143 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
}
|
146 |
|
@@ -687,6 +756,13 @@ function renderProBadge( $url = null,$label = "Pro Feature" ) {
|
|
687 |
echo ' <a href="' . esc_url( $url ) . '" target="_blank" class="badge badge-pill badge-pro">'.$label.' <i class="fa fa-external-link" aria-hidden="true"></i></a>';
|
688 |
}
|
689 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
690 |
function renderSpBadge() {
|
691 |
echo ' <a href="https://www.pixelyoursite.com/super-pack?utm_source=pixelyoursite-free-plugin&utm_medium=plugin&utm_campaign=free-plugin-super-pack" target="_blank" class="badge badge-pill badge-pro">Pro Feature <i class="fa fa-external-link" aria-hidden="true"></i></a>';
|
692 |
}
|
141 |
}
|
142 |
|
143 |
}
|
144 |
+
|
145 |
+
if (!isPixelCogActive() ) {
|
146 |
+
|
147 |
+
$event_purchase = get_option('woo_purchase_value_cog');
|
148 |
+
$content_value = get_option('woo_content_value_cog');
|
149 |
+
$add_to_cart_value = get_option('woo_add_to_cart_value_cog');
|
150 |
+
$initiate_checkout_value = get_option('woo_initiate_checkout_value_cog');
|
151 |
+
|
152 |
+
$event_purchase_old = get_option('woo_purchase_value_option');
|
153 |
+
$content_value_old = get_option('woo_view_content_value_option');
|
154 |
+
$add_to_cart_value_old = get_option('woo_add_to_cart_value_option');
|
155 |
+
$initiate_checkout_value_old = get_option('woo_initiate_checkout_value_option');
|
156 |
+
|
157 |
+
if (!$event_purchase) add_option('woo_purchase_value_cog', $event_purchase_old);
|
158 |
+
if (!$content_value) add_option('woo_content_value_cog', $content_value_old);
|
159 |
+
if (!$add_to_cart_value) add_option('woo_add_to_cart_value_cog', $add_to_cart_value_old);
|
160 |
+
if (!$initiate_checkout_value) add_option('woo_initiate_checkout_value_cog', $initiate_checkout_value_old);
|
161 |
+
|
162 |
+
$PixelCogDeActive = array(
|
163 |
+
'woo_view_content_value_option' => 'price',
|
164 |
+
'woo_add_to_cart_value_option' => 'price',
|
165 |
+
'woo_initiate_checkout_value_option' => 'price',
|
166 |
+
'woo_purchase_value_option' => 'price'
|
167 |
+
);
|
168 |
+
// update settings
|
169 |
+
PYS()->updateOptions( $PixelCogDeActive );
|
170 |
+
PYS()->reloadOptions();
|
171 |
+
} else {
|
172 |
+
$event_purchase = get_option('woo_purchase_value_cog');
|
173 |
+
$content_value = get_option('woo_content_value_cog');
|
174 |
+
$add_to_cart_value = get_option('woo_add_to_cart_value_cog');
|
175 |
+
$initiate_checkout_value = get_option('woo_initiate_checkout_value_cog');
|
176 |
+
|
177 |
+
if ($initiate_checkout_value == 'cog') {
|
178 |
+
$PixelCogDeActive = array(
|
179 |
+
'woo_initiate_checkout_value_option' => 'cog'
|
180 |
+
);
|
181 |
+
// update settings
|
182 |
+
PYS()->updateOptions( $PixelCogDeActive );
|
183 |
+
PYS()->reloadOptions();
|
184 |
+
}
|
185 |
+
|
186 |
+
if ($add_to_cart_value == 'cog') {
|
187 |
+
$PixelCogDeActive = array(
|
188 |
+
'woo_add_to_cart_value_option' => 'cog'
|
189 |
+
);
|
190 |
+
// update settings
|
191 |
+
PYS()->updateOptions( $PixelCogDeActive );
|
192 |
+
PYS()->reloadOptions();
|
193 |
+
}
|
194 |
+
|
195 |
+
if ($content_value == 'cog') {
|
196 |
+
$PixelCogDeActive = array(
|
197 |
+
'woo_view_content_value_option' => 'cog',
|
198 |
+
);
|
199 |
+
// update settings
|
200 |
+
PYS()->updateOptions( $PixelCogDeActive );
|
201 |
+
PYS()->reloadOptions();
|
202 |
+
}
|
203 |
+
|
204 |
+
if ($event_purchase == 'cog') {
|
205 |
+
$PixelCogDeActive = array(
|
206 |
+
'woo_purchase_value_option' => 'cog',
|
207 |
+
);
|
208 |
+
// update settings
|
209 |
+
PYS()->updateOptions( $PixelCogDeActive );
|
210 |
+
PYS()->reloadOptions();
|
211 |
+
}
|
212 |
+
}
|
213 |
|
214 |
}
|
215 |
|
756 |
echo ' <a href="' . esc_url( $url ) . '" target="_blank" class="badge badge-pill badge-pro">'.$label.' <i class="fa fa-external-link" aria-hidden="true"></i></a>';
|
757 |
}
|
758 |
|
759 |
+
function renderCogBadge( $label = "You need this plugin" ) {
|
760 |
+
|
761 |
+
$url = 'https://www.pixelyoursite.com/woocommerce-cost-of-goods';
|
762 |
+
|
763 |
+
echo ' <a href="' . esc_url( $url ) . '" target="_blank" class="badge badge-pill badge-pro">'.$label.' <i class="fa fa-external-link" aria-hidden="true"></i></a>';
|
764 |
+
}
|
765 |
+
|
766 |
function renderSpBadge() {
|
767 |
echo ' <a href="https://www.pixelyoursite.com/super-pack?utm_source=pixelyoursite-free-plugin&utm_medium=plugin&utm_campaign=free-plugin-super-pack" target="_blank" class="badge badge-pill badge-pro">Pro Feature <i class="fa fa-external-link" aria-hidden="true"></i></a>';
|
768 |
}
|
includes/functions-common.php
CHANGED
@@ -138,6 +138,21 @@ function isBoostActive() {
|
|
138 |
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
/**
|
142 |
* Check if Smart OpenGraph plugin installed and activated.
|
143 |
*
|
@@ -184,6 +199,194 @@ function getAvailableUserRoles() {
|
|
184 |
|
185 |
}
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
function isDisabledForCurrentRole() {
|
188 |
|
189 |
$user = wp_get_current_user();
|
@@ -562,6 +765,10 @@ function compareURLs( $url, $base = '', $rule = 'match' ) {
|
|
562 |
if ( $base == $url ) {
|
563 |
return true;
|
564 |
}
|
|
|
|
|
|
|
|
|
565 |
|
566 |
if ( strpos( $base, $url ) !== false ) {
|
567 |
return true;
|
138 |
|
139 |
}
|
140 |
|
141 |
+
/**
|
142 |
+
* Check if Pixel Cost of goods plugin installed and activated.
|
143 |
+
*
|
144 |
+
* @return bool
|
145 |
+
*/
|
146 |
+
function isPixelCogActive() {
|
147 |
+
|
148 |
+
if ( ! function_exists( 'is_plugin_active' ) ) {
|
149 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
150 |
+
}
|
151 |
+
|
152 |
+
return is_plugin_active( 'pixel-cost-of-goods/pixel-cost-of-goods.php' );
|
153 |
+
|
154 |
+
}
|
155 |
+
|
156 |
/**
|
157 |
* Check if Smart OpenGraph plugin installed and activated.
|
158 |
*
|
199 |
|
200 |
}
|
201 |
|
202 |
+
function getAvailableProductCog($product_id) {
|
203 |
+
|
204 |
+
$cog_product_val = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_val', true );
|
205 |
+
$cog_term_val = get_product_cost_by_cat( $product_id );
|
206 |
+
|
207 |
+
if ($cog_product_val) {
|
208 |
+
$cog = array(
|
209 |
+
'type' => get_post_meta( $product_id, '_pixel_cost_of_goods_cost_type', true ),
|
210 |
+
'val' => $cog_product_val
|
211 |
+
);
|
212 |
+
} elseif ($cog_term_val) {
|
213 |
+
$cog = array(
|
214 |
+
'type' => get_product_type_by_cat( $product_id ),
|
215 |
+
'val' => $cog_term_val
|
216 |
+
);
|
217 |
+
} else {
|
218 |
+
$cog = array(
|
219 |
+
'type' => get_option( '_pixel_cost_of_goods_cost_type'),
|
220 |
+
'val' => get_option( '_pixel_cost_of_goods_cost_val')
|
221 |
+
);
|
222 |
+
}
|
223 |
+
|
224 |
+
return $cog;
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
function getAvailableProductCogOrder($order_id) {
|
229 |
+
$order = wc_get_order( $order_id );
|
230 |
+
$orderData = $order->get_data();
|
231 |
+
$order_shipping_total = $orderData['shipping_total'];
|
232 |
+
$order_total = $order->get_total();
|
233 |
+
$cost = 0;
|
234 |
+
$notice = '';
|
235 |
+
$custom_total = 0;
|
236 |
+
$cat_isset = 0;
|
237 |
+
foreach ( $order->get_items() as $item_id => $item ) {
|
238 |
+
$product_id = ( isset( $item['variation_id'] ) && 0 != $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
|
239 |
+
$cost_type = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_type', true );
|
240 |
+
$product_cost = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_val', true );
|
241 |
+
$price = get_post_meta($product_id, '_regular_price', true);
|
242 |
+
$qlt = $item['quantity'];
|
243 |
+
if ($product_cost) {
|
244 |
+
$cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
|
245 |
+
$custom_total = $custom_total + ($price * $qlt);
|
246 |
+
} else {
|
247 |
+
$product_cost = get_product_cost_by_cat( $product_id );
|
248 |
+
$cost_type = get_product_type_by_cat( $product_id );
|
249 |
+
if ($product_cost) {
|
250 |
+
$cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
|
251 |
+
$custom_total = $custom_total + ($price * $qlt);
|
252 |
+
$notice = "Category Cost of Goods was used for some products.";
|
253 |
+
$cat_isset = 1;
|
254 |
+
} else {
|
255 |
+
$product_cost = get_option( '_pixel_cost_of_goods_cost_val');
|
256 |
+
$cost_type = get_option( '_pixel_cost_of_goods_cost_type' );
|
257 |
+
if ($product_cost) {
|
258 |
+
$cost = ($cost_type == 'percent') ? (float) $cost + ((float) $price * ((float) $product_cost / 100) * $qlt) : (float) $cost + ((float) $product_cost * $qlt);
|
259 |
+
$custom_total = $custom_total + ($price * $qlt);
|
260 |
+
if ($cat_isset == 1) {
|
261 |
+
$notice = "Global and Category Cost of Goods was used for some products.";
|
262 |
+
} else {
|
263 |
+
$notice = "Global Cost of Goods was used for some products.";
|
264 |
+
}
|
265 |
+
} else {
|
266 |
+
$notice = "Some products don't have Cost of Goods.";
|
267 |
+
}
|
268 |
+
}
|
269 |
+
}
|
270 |
+
}
|
271 |
+
if (($order_total - $cost - $order_shipping_total) > 0) {
|
272 |
+
$profit = $order_total - $cost - $order_shipping_total;
|
273 |
+
} else {
|
274 |
+
$profit = '';
|
275 |
+
}
|
276 |
+
if ('' !== $notice) {
|
277 |
+
if (($custom_total - $cost) > 0) {
|
278 |
+
$profit = $custom_total - $cost;
|
279 |
+
} else {
|
280 |
+
$profit = '';
|
281 |
+
}
|
282 |
+
}
|
283 |
+
|
284 |
+
return $profit;
|
285 |
+
|
286 |
+
}
|
287 |
+
|
288 |
+
function getAvailableProductCogCart($amount) {
|
289 |
+
$cart_total = $amount;
|
290 |
+
$cost = 0;
|
291 |
+
$notice = '';
|
292 |
+
$custom_total = 0;
|
293 |
+
$cat_isset = 0;
|
294 |
+
foreach ( WC()->cart->cart_contents as $cart_item_key => $item ) {
|
295 |
+
$product_id = ( isset( $item['variation_id'] ) && 0 != $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );
|
296 |
+
$cost_type = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_type', true );
|
297 |
+
$product_cost = get_post_meta( $product_id, '_pixel_cost_of_goods_cost_val', true );
|
298 |
+
$price = get_post_meta($product_id, '_regular_price', true);
|
299 |
+
$qlt = $item['quantity'];
|
300 |
+
if ($product_cost) {
|
301 |
+
$cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
|
302 |
+
$custom_total = $custom_total + ($price * $qlt);
|
303 |
+
} else {
|
304 |
+
$product_cost = get_product_cost_by_cat( $product_id );
|
305 |
+
$cost_type = get_product_type_by_cat( $product_id );
|
306 |
+
if ($product_cost) {
|
307 |
+
$cost = ($cost_type == 'percent') ? $cost + ($price * ($product_cost / 100) * $qlt) : $cost + ($product_cost * $qlt);
|
308 |
+
$custom_total = $custom_total + ($price * $qlt);
|
309 |
+
$notice = "Category Cost of Goods was used for some products.";
|
310 |
+
$cat_isset = 1;
|
311 |
+
} else {
|
312 |
+
$product_cost = get_option( '_pixel_cost_of_goods_cost_val');
|
313 |
+
$cost_type = get_option( '_pixel_cost_of_goods_cost_type' );
|
314 |
+
if ($product_cost) {
|
315 |
+
$cost = ($cost_type == 'percent') ? $cost + ((float) $price * ((float) $product_cost / 100) * $qlt) : (float) $cost + ((float) $product_cost * $qlt);
|
316 |
+
$custom_total = $custom_total + ($price * $qlt);
|
317 |
+
if ($cat_isset == 1) {
|
318 |
+
$notice = "Global and Category Cost of Goods was used for some products.";
|
319 |
+
} else {
|
320 |
+
$notice = "Global Cost of Goods was used for some products.";
|
321 |
+
}
|
322 |
+
} else {
|
323 |
+
$notice = "Some products don't have Cost of Goods.";
|
324 |
+
}
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
if (($cart_total - $cost) > 0) {
|
329 |
+
$profit = $cart_total - $cost;
|
330 |
+
} else {
|
331 |
+
$profit = '';
|
332 |
+
}
|
333 |
+
if ('' !== $notice) {
|
334 |
+
if (($custom_total - $cost) > 0) {
|
335 |
+
$profit = $custom_total - $cost;
|
336 |
+
} else {
|
337 |
+
$profit = '';
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
return $profit;
|
342 |
+
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* get_product_type_by_cat.
|
347 |
+
*
|
348 |
+
* @version 1.0.0
|
349 |
+
* @since 1.0.0
|
350 |
+
*/
|
351 |
+
function get_product_type_by_cat( $product_id ) {
|
352 |
+
$term_list = wp_get_post_terms($product_id,'product_cat',array('fields'=>'ids'));
|
353 |
+
$cost = array();
|
354 |
+
foreach ($term_list as $term_id) {
|
355 |
+
$cost[$term_id] = array(
|
356 |
+
get_term_meta( $term_id, '_pixel_cost_of_goods_cost_val', true ),
|
357 |
+
get_term_meta( $term_id, '_pixel_cost_of_goods_cost_type', true )
|
358 |
+
);
|
359 |
+
}
|
360 |
+
if ( empty( $cost ) ) {
|
361 |
+
return '';
|
362 |
+
} else {
|
363 |
+
asort( $cost );
|
364 |
+
$max = end( $cost );
|
365 |
+
return $max[1];
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* get_product_cost_by_cat.
|
371 |
+
*
|
372 |
+
* @version 1.0.0
|
373 |
+
* @since 1.0.0
|
374 |
+
*/
|
375 |
+
function get_product_cost_by_cat( $product_id ) {
|
376 |
+
$term_list = wp_get_post_terms($product_id,'product_cat',array('fields'=>'ids'));
|
377 |
+
$cost = array();
|
378 |
+
foreach ($term_list as $term_id) {
|
379 |
+
$cost[$term_id] = get_term_meta( $term_id, '_pixel_cost_of_goods_cost_val', true );
|
380 |
+
}
|
381 |
+
if ( empty( $cost ) ) {
|
382 |
+
return '';
|
383 |
+
} else {
|
384 |
+
asort( $cost );
|
385 |
+
$max = end( $cost );
|
386 |
+
return $max;
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
function isDisabledForCurrentRole() {
|
391 |
|
392 |
$user = wp_get_current_user();
|
765 |
if ( $base == $url ) {
|
766 |
return true;
|
767 |
}
|
768 |
+
|
769 |
+
if(empty($base) || empty($url)) {
|
770 |
+
return false;
|
771 |
+
}
|
772 |
|
773 |
if ( strpos( $base, $url ) !== false ) {
|
774 |
return true;
|
includes/functions-custom-event.php
CHANGED
@@ -75,11 +75,12 @@ function renderNumberInput( &$event, $key, $placeholder = null ) {
|
|
75 |
|
76 |
/**
|
77 |
* @param CustomEvent $event
|
78 |
-
* @param string
|
|
|
79 |
*/
|
80 |
-
function renderSwitcherInput( &$event, $key ) {
|
|
|
81 |
|
82 |
-
$disabled = false;
|
83 |
|
84 |
$attr_name = "pys[event][$key]";
|
85 |
$attr_id = 'pys_event_' . $key;
|
75 |
|
76 |
/**
|
77 |
* @param CustomEvent $event
|
78 |
+
* @param string $key
|
79 |
+
* @param bool $disabled
|
80 |
*/
|
81 |
+
function renderSwitcherInput( &$event, $key,$disabled = false ) {
|
82 |
+
|
83 |
|
|
|
84 |
|
85 |
$attr_name = "pys[event][$key]";
|
86 |
$attr_id = 'pys_event_' . $key;
|
includes/functions-woo.php
CHANGED
@@ -80,13 +80,83 @@ function getWooCartSubtotal() {
|
|
80 |
|
81 |
}
|
82 |
|
83 |
-
function getWooEventValue( $valueOption, $amount, $global, $percent = 100 ) {
|
84 |
|
85 |
switch ( $valueOption ) {
|
86 |
case 'global':
|
87 |
$value = (float) $global;
|
88 |
break;
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
case 'percent':
|
91 |
$percents = (float) $percent;
|
92 |
$percents = str_replace( '%', null, $percents );
|
80 |
|
81 |
}
|
82 |
|
83 |
+
function getWooEventValue( $valueOption, $amount, $global, $product_id = null, $percent = 100 ) {
|
84 |
|
85 |
switch ( $valueOption ) {
|
86 |
case 'global':
|
87 |
$value = (float) $global;
|
88 |
break;
|
89 |
|
90 |
+
case 'cog':
|
91 |
+
$cog = getAvailableProductCog($product_id);
|
92 |
+
if ($cog['val']){
|
93 |
+
if ($cog['type'] == 'fix') {
|
94 |
+
$value = round((float) $amount - (float) $cog['val'], 2);
|
95 |
+
} else {
|
96 |
+
$value = round((float) $amount - ( (float) $amount * (float) $cog['val'] / 100 ), 2);
|
97 |
+
}
|
98 |
+
} else {
|
99 |
+
$value = (float) $amount;
|
100 |
+
}
|
101 |
+
if ( !isPixelCogActive() ) $value = (float) $amount;
|
102 |
+
break;
|
103 |
+
|
104 |
+
case 'percent':
|
105 |
+
$percents = (float) $percent;
|
106 |
+
$percents = str_replace( '%', null, $percents );
|
107 |
+
$percents = (float) $percents / 100;
|
108 |
+
$value = (float) $amount * $percents;
|
109 |
+
break;
|
110 |
+
|
111 |
+
default: // "price" option
|
112 |
+
$value = (float) $amount;
|
113 |
+
}
|
114 |
+
|
115 |
+
return $value;
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
function getWooEventValueOrder( $valueOption, $amount, $global, $order_id, $content_ids, $percent = 100 ) {
|
120 |
+
|
121 |
+
switch ( $valueOption ) {
|
122 |
+
case 'global':
|
123 |
+
$value = (float) $global;
|
124 |
+
break;
|
125 |
+
|
126 |
+
case 'cog':
|
127 |
+
$cog_value = getAvailableProductCogOrder($order_id);
|
128 |
+
($cog_value !== '') ? $value = (float) round($cog_value, 2) : $value = (float) $amount;
|
129 |
+
if ( !isPixelCogActive() ) $value = (float) $amount;
|
130 |
+
break;
|
131 |
+
|
132 |
+
case 'percent':
|
133 |
+
$percents = (float) $percent;
|
134 |
+
$percents = str_replace( '%', null, $percents );
|
135 |
+
$percents = (float) $percents / 100;
|
136 |
+
$value = (float) $amount * $percents;
|
137 |
+
break;
|
138 |
+
|
139 |
+
default: // "price" option
|
140 |
+
$value = (float) $amount;
|
141 |
+
}
|
142 |
+
|
143 |
+
return $value;
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
function getWooEventValueCart( $valueOption, $amount, $global, $percent = 100 ) {
|
148 |
+
|
149 |
+
switch ( $valueOption ) {
|
150 |
+
case 'global':
|
151 |
+
$value = (float) $global;
|
152 |
+
break;
|
153 |
+
|
154 |
+
case 'cog':
|
155 |
+
$cog_value = getAvailableProductCogCart($amount);
|
156 |
+
($cog_value !== '') ? $value = (float) round($cog_value, 2) : $value = (float) $amount;
|
157 |
+
if ( !isPixelCogActive() ) $value = (float) $amount;
|
158 |
+
break;
|
159 |
+
|
160 |
case 'percent':
|
161 |
$percents = (float) $percent;
|
162 |
$percents = str_replace( '%', null, $percents );
|
includes/views/html-main-events-edit.php
CHANGED
@@ -59,7 +59,7 @@ if(isset( $_REQUEST['id'] )) {
|
|
59 |
Event Trigger
|
60 |
</div>
|
61 |
<div class="card-body">
|
62 |
-
<div class="row">
|
63 |
<div class="col form-inline">
|
64 |
<label>Fire event when</label>
|
65 |
<?php Events\renderTriggerTypeInput( $event, 'trigger_type' ); ?>
|
@@ -71,6 +71,16 @@ if(isset( $_REQUEST['id'] )) {
|
|
71 |
</div>
|
72 |
</div>
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
<div id="page_visit_panel" class="event_triggers_panel" data-trigger_type="page_visit" style="display: none;">
|
75 |
<div class="row mt-3 event_trigger" data-trigger_id="0" style="display: none;">
|
76 |
<div class="col">
|
59 |
Event Trigger
|
60 |
</div>
|
61 |
<div class="card-body">
|
62 |
+
<div class="row mb-3">
|
63 |
<div class="col form-inline">
|
64 |
<label>Fire event when</label>
|
65 |
<?php Events\renderTriggerTypeInput( $event, 'trigger_type' ); ?>
|
71 |
</div>
|
72 |
</div>
|
73 |
|
74 |
+
<div class="row">
|
75 |
+
<div class="col form-inline">
|
76 |
+
<?php Events\renderSwitcherInput( $event, 'enable_time_window',true ); ?>
|
77 |
+
<label>Fire this event only once in</label>
|
78 |
+
<?php Events\renderNumberInput( $event, 'time_window', '24' ); ?>
|
79 |
+
<label>hours</label>
|
80 |
+
<?php renderProBadge( 'https://www.pixelyoursite.com/?utm_source=pys-free-plugin&utm_medium=pro-badge&utm_campaign=pro-feature' ); ?>
|
81 |
+
</div>
|
82 |
+
</div>
|
83 |
+
|
84 |
<div id="page_visit_panel" class="event_triggers_panel" data-trigger_type="page_visit" style="display: none;">
|
85 |
<div class="row mt-3 event_trigger" data-trigger_id="0" style="display: none;">
|
86 |
<div class="col">
|
includes/views/html-main-general.php
CHANGED
@@ -85,6 +85,92 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
85 |
</div>
|
86 |
</div>
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
<h2 class="section-title">Global Events</h2>
|
89 |
|
90 |
<!-- GeneralEvent -->
|
85 |
</div>
|
86 |
</div>
|
87 |
|
88 |
+
<div class="card">
|
89 |
+
<div class="card-header">
|
90 |
+
Dynamic Ads for Blog Setup <?php cardCollapseBtn(); ?>
|
91 |
+
</div>
|
92 |
+
<div class="card-body">
|
93 |
+
<div class="row mt-3">
|
94 |
+
<div class="col-11">
|
95 |
+
This setup will help you to run Facebook Dynamic Product Ads for your blog content.
|
96 |
+
</div>
|
97 |
+
</div>
|
98 |
+
<div class="row mt-3">
|
99 |
+
<div class="col">
|
100 |
+
<a href="https://www.pixelyoursite.com/facebook-dynamic-product-ads-for-wordpress" target="_blank">Click here to learn how to do it</a>
|
101 |
+
</div>
|
102 |
+
</div>
|
103 |
+
<?php if ( Facebook()->enabled() ) : ?>
|
104 |
+
|
105 |
+
<div class="row mt-3">
|
106 |
+
<div class="col">
|
107 |
+
<label>Content_type</label><?php
|
108 |
+
$options = array(
|
109 |
+
'product' => 'Product',
|
110 |
+
'' => 'Empty'
|
111 |
+
);
|
112 |
+
Facebook()->render_select_input( 'fdp_content_type',$options ); ?>
|
113 |
+
</div>
|
114 |
+
</div>
|
115 |
+
|
116 |
+
<div class="row mt-3">
|
117 |
+
<div class="col">
|
118 |
+
<?php Facebook()->render_switcher_input( 'fdp_view_content_enabled' ); ?>
|
119 |
+
<h4 class="switcher-label">Enable the ViewContent on every blog page</h4>
|
120 |
+
</div>
|
121 |
+
</div>
|
122 |
+
<div class="row mt-3">
|
123 |
+
<div class="col">
|
124 |
+
<?php Facebook()->render_switcher_input( 'fdp_view_category_enabled' ); ?>
|
125 |
+
<h4 class="switcher-label">Enable the ViewCategory on every blog categories page</h4>
|
126 |
+
</div>
|
127 |
+
</div>
|
128 |
+
<div class="row mt-3">
|
129 |
+
<div class="col-11">
|
130 |
+
<?php Facebook()->render_switcher_input( 'fdp_add_to_cart_enabled' ); ?>
|
131 |
+
<h4 class="switcher-label">Enable the AddToCart event on every blog page</h4>
|
132 |
+
</div>
|
133 |
+
|
134 |
+
<div class="col-11 form-inline col-offset-left">
|
135 |
+
<label>Fire the AddToCart when scroll to</label>
|
136 |
+
<?php Facebook()->render_number_input( 'fdp_add_to_cart_event_fire_scroll',50 ); ?>
|
137 |
+
<label>%</label>
|
138 |
+
</div>
|
139 |
+
</div>
|
140 |
+
<div class="row mt-3">
|
141 |
+
<div class="col-11">
|
142 |
+
<?php Facebook()->render_switcher_input( 'fdp_purchase_enabled' ); ?>
|
143 |
+
<h4 class="switcher-label">Enable the Purchase event on every blog page</h4>
|
144 |
+
</div>
|
145 |
+
|
146 |
+
<div class="col-11 form-inline col-offset-left">
|
147 |
+
<label>Fire the Purchase event</label>
|
148 |
+
|
149 |
+
<?php
|
150 |
+
$options = array(
|
151 |
+
'scroll_pos' => 'Page Scroll',
|
152 |
+
'comment' => 'User commented',
|
153 |
+
'css_click' => 'Click on CSS selector',
|
154 |
+
//Default event fires
|
155 |
+
);
|
156 |
+
Facebook()->render_select_input( 'fdp_purchase_event_fire',$options ); ?>
|
157 |
+
<span id="fdp_purchase_event_fire_scroll_block">
|
158 |
+
<?php Facebook()->render_number_input( 'fdp_purchase_event_fire_scroll',50 ); ?> <span>%</span>
|
159 |
+
</span>
|
160 |
+
|
161 |
+
<?php Facebook()->render_text_input( 'fdp_purchase_event_fire_css',"CSS selector"); ?>
|
162 |
+
</div>
|
163 |
+
</div>
|
164 |
+
<div class="row mt-5">
|
165 |
+
<div class="col">
|
166 |
+
<strong>You need to upload your blog posts into a Facebook Product Catalog.</strong> You can do this with our dedicated plugin:
|
167 |
+
<a href="https://www.pixelyoursite.com/wordpress-feed-facebook-dpa" target="_blank">Click Here</a>
|
168 |
+
</div>
|
169 |
+
</div>
|
170 |
+
<?php endif; ?>
|
171 |
+
</div>
|
172 |
+
</div>
|
173 |
+
|
174 |
<h2 class="section-title">Global Events</h2>
|
175 |
|
176 |
<!-- GeneralEvent -->
|
includes/views/html-main-woo.php
CHANGED
@@ -480,6 +480,13 @@ e&utm_campaign=pro-feature' ); ?>
|
|
480 |
<div class="custom-controls-stacked">
|
481 |
<?php PYS()->render_radio_input( 'woo_purchase_value_option', 'price',
|
482 |
'Products price (subtotal)' ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
<?php renderDummyRadioInput( 'Percent of products value (subtotal)' ); ?>
|
484 |
<div class="form-inline">
|
485 |
<?php renderDummyTextInput( 0 ); ?>
|
@@ -583,6 +590,13 @@ e&utm_campaign=pro-feature' ); ?>
|
|
583 |
<div class="custom-controls-stacked">
|
584 |
<?php PYS()->render_radio_input( 'woo_initiate_checkout_value_option', 'price',
|
585 |
'Products price (subtotal)' ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
586 |
<?php renderDummyRadioInput( 'Percent of products value (subtotal)' ); ?>
|
587 |
<div class="form-inline">
|
588 |
<?php renderDummyTextInput( 0 ); ?>
|
@@ -740,6 +754,13 @@ e&utm_campaign=pro-feature' ); ?>
|
|
740 |
<div class="custom-controls-stacked">
|
741 |
<?php PYS()->render_radio_input( 'woo_add_to_cart_value_option', 'price',
|
742 |
'Products price (subtotal)' ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
743 |
<?php renderDummyRadioInput( 'Percent of products value (subtotal)' ) ?>
|
744 |
<div class="form-inline">
|
745 |
<?php renderDummyTextInput( 0 ); ?>
|
@@ -842,6 +863,13 @@ e&utm_campaign=pro-feature' ); ?>
|
|
842 |
<div class="custom-controls-stacked">
|
843 |
<?php PYS()->render_radio_input( 'woo_view_content_value_option', 'price',
|
844 |
'Product price' ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
845 |
<?php renderDummyRadioInput( 'Percent of product price' ); ?>
|
846 |
<div class="form-inline">
|
847 |
<?php renderDummyTextInput( 0 ); ?>
|
@@ -947,6 +975,38 @@ e&utm_campaign=pro-feature' ); ?>
|
|
947 |
</div>
|
948 |
</div>
|
949 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
950 |
<h2 class="section-title">PRO Events</h2>
|
951 |
|
952 |
<h2 class="section-title">Advanced Marketing Events</h2>
|
480 |
<div class="custom-controls-stacked">
|
481 |
<?php PYS()->render_radio_input( 'woo_purchase_value_option', 'price',
|
482 |
'Products price (subtotal)' ); ?>
|
483 |
+
<?php if ( !isPixelCogActive() ) { ?>
|
484 |
+
<?php PYS()->render_radio_input( 'woo_purchase_value_option', 'cog',
|
485 |
+
'Price minus Cost of Goods', true, true ); ?>
|
486 |
+
<?php } else { ?>
|
487 |
+
<?php PYS()->render_radio_input( 'woo_purchase_value_option', 'cog',
|
488 |
+
'Price minus Cost of Goods', false ); ?>
|
489 |
+
<?php } ?>
|
490 |
<?php renderDummyRadioInput( 'Percent of products value (subtotal)' ); ?>
|
491 |
<div class="form-inline">
|
492 |
<?php renderDummyTextInput( 0 ); ?>
|
590 |
<div class="custom-controls-stacked">
|
591 |
<?php PYS()->render_radio_input( 'woo_initiate_checkout_value_option', 'price',
|
592 |
'Products price (subtotal)' ); ?>
|
593 |
+
<?php if ( !isPixelCogActive() ) { ?>
|
594 |
+
<?php PYS()->render_radio_input( 'woo_initiate_checkout_value_option', 'cog',
|
595 |
+
'Price minus Cost of Goods', true, true ); ?>
|
596 |
+
<?php } else { ?>
|
597 |
+
<?php PYS()->render_radio_input( 'woo_initiate_checkout_value_option', 'cog',
|
598 |
+
'Price minus Cost of Goods', false ); ?>
|
599 |
+
<?php } ?>
|
600 |
<?php renderDummyRadioInput( 'Percent of products value (subtotal)' ); ?>
|
601 |
<div class="form-inline">
|
602 |
<?php renderDummyTextInput( 0 ); ?>
|
754 |
<div class="custom-controls-stacked">
|
755 |
<?php PYS()->render_radio_input( 'woo_add_to_cart_value_option', 'price',
|
756 |
'Products price (subtotal)' ); ?>
|
757 |
+
<?php if ( !isPixelCogActive() ) { ?>
|
758 |
+
<?php PYS()->render_radio_input( 'woo_add_to_cart_value_option', 'cog',
|
759 |
+
'Price minus Cost of Goods', true, true ); ?>
|
760 |
+
<?php } else { ?>
|
761 |
+
<?php PYS()->render_radio_input( 'woo_add_to_cart_value_option', 'cog',
|
762 |
+
'Price minus Cost of Goods', false ); ?>
|
763 |
+
<?php } ?>
|
764 |
<?php renderDummyRadioInput( 'Percent of products value (subtotal)' ) ?>
|
765 |
<div class="form-inline">
|
766 |
<?php renderDummyTextInput( 0 ); ?>
|
863 |
<div class="custom-controls-stacked">
|
864 |
<?php PYS()->render_radio_input( 'woo_view_content_value_option', 'price',
|
865 |
'Product price' ); ?>
|
866 |
+
<?php if ( !isPixelCogActive() ) { ?>
|
867 |
+
<?php PYS()->render_radio_input( 'woo_view_content_value_option', 'cog',
|
868 |
+
'Price minus Cost of Goods', true, true ); ?>
|
869 |
+
<?php } else { ?>
|
870 |
+
<?php PYS()->render_radio_input( 'woo_view_content_value_option', 'cog',
|
871 |
+
'Price minus Cost of Goods', false ); ?>
|
872 |
+
<?php } ?>
|
873 |
<?php renderDummyRadioInput( 'Percent of product price' ); ?>
|
874 |
<div class="form-inline">
|
875 |
<?php renderDummyTextInput( 0 ); ?>
|
975 |
</div>
|
976 |
</div>
|
977 |
|
978 |
+
|
979 |
+
|
980 |
+
<div class="card">
|
981 |
+
<div class="card-header">
|
982 |
+
Track product list performance on Google Analytics
|
983 |
+
<?php renderProBadge( 'https://www.pixelyoursite.com/google-analytics?utm_source=pys-free-plugin&utm_medium=pro-badge&utm_campaign=pro-feature' ); ?>
|
984 |
+
<?php cardCollapseBtn(); ?>
|
985 |
+
</div>
|
986 |
+
<div class="card-body">
|
987 |
+
<?php if ( GA()->enabled() ) : ?>
|
988 |
+
<div class="row mb-1">
|
989 |
+
<div class="col">
|
990 |
+
<?php GA()->render_switcher_input( 'woo_view_category_enabled_tmp',false,true ); ?>
|
991 |
+
<h4 class="switcher-label">Enable the view_item_list event on Google Analytics(categories, related products, search, shortcodes)</h4>
|
992 |
+
</div>
|
993 |
+
</div>
|
994 |
+
<div class="row mb-2">
|
995 |
+
<div class="col col-offset-left">
|
996 |
+
<?php GA()->render_checkbox_input( 'woo_view_category_non_interactive_tmp', 'Non-interactive event',true ); ?>
|
997 |
+
</div>
|
998 |
+
</div>
|
999 |
+
<div class="row mb-1">
|
1000 |
+
<div class="col">
|
1001 |
+
<?php GA()->render_switcher_input( 'woo_select_content_enabled_tmp',false,true ); ?>
|
1002 |
+
<h4 class="switcher-label">Enable the select_content event on Google Analytics(when a product is clicked on categories, related products, search, shortcodes)</h4>
|
1003 |
+
</div>
|
1004 |
+
</div>
|
1005 |
+
<?php endif; ?>
|
1006 |
+
</div>
|
1007 |
+
</div>
|
1008 |
+
|
1009 |
+
|
1010 |
<h2 class="section-title">PRO Events</h2>
|
1011 |
|
1012 |
<h2 class="section-title">Advanced Marketing Events</h2>
|
modules/facebook/FDPEvent.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
namespace PixelYourSite;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class FDPEvent
|
8 |
+
* @property string event_name
|
9 |
+
* @property string content_type
|
10 |
+
* @property string trigger_type
|
11 |
+
* @property string trigger_value
|
12 |
+
* */
|
13 |
+
class FDPEvent
|
14 |
+
{
|
15 |
+
private $data = array();
|
16 |
+
|
17 |
+
public function __get( $key ) {
|
18 |
+
if(isset($this->data[$key])) return $this->data[$key];
|
19 |
+
return "";
|
20 |
+
}
|
21 |
+
|
22 |
+
public function __set( $key,$value ){
|
23 |
+
$this->data[$key] = $value;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function hasTimeWindow() {
|
27 |
+
return false;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getTimeWindow() {
|
31 |
+
return 0;
|
32 |
+
}
|
33 |
+
}
|
modules/facebook/facebook.php
CHANGED
@@ -8,6 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
8 |
|
9 |
/** @noinspection PhpIncludeInspection */
|
10 |
require_once PYS_FREE_PATH . '/modules/facebook/function-helpers.php';
|
|
|
11 |
|
12 |
use PixelYourSite\Facebook\Helpers;
|
13 |
|
@@ -104,6 +105,9 @@ class Facebook extends Settings implements Pixel {
|
|
104 |
case 'custom_event':
|
105 |
return $this->getCustomEventParams( $args );
|
106 |
|
|
|
|
|
|
|
107 |
case 'woo_view_content':
|
108 |
return $this->getWooViewContentEventParams();
|
109 |
|
@@ -258,6 +262,88 @@ class Facebook extends Settings implements Pixel {
|
|
258 |
|
259 |
}
|
260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
private function getWooViewContentEventParams() {
|
262 |
global $post;
|
263 |
|
@@ -294,8 +380,10 @@ class Facebook extends Settings implements Pixel {
|
|
294 |
|
295 |
$value_option = PYS()->getOption( 'woo_view_content_value_option' );
|
296 |
$global_value = PYS()->getOption( 'woo_view_content_value_global', 0 );
|
297 |
-
|
298 |
-
|
|
|
|
|
299 |
$params['currency'] = get_woocommerce_currency();
|
300 |
|
301 |
}
|
@@ -515,8 +603,10 @@ class Facebook extends Settings implements Pixel {
|
|
515 |
$amount = $order->get_total();
|
516 |
$value_option = PYS()->getOption( 'woo_purchase_value_option' );
|
517 |
$global_value = PYS()->getOption( 'woo_purchase_value_global', 0 );
|
518 |
-
|
519 |
-
|
|
|
|
|
520 |
$params['currency'] = get_woocommerce_currency();
|
521 |
$params['transaction_id'] = $order_id;
|
522 |
|
8 |
|
9 |
/** @noinspection PhpIncludeInspection */
|
10 |
require_once PYS_FREE_PATH . '/modules/facebook/function-helpers.php';
|
11 |
+
require_once PYS_FREE_PATH . '/modules/facebook/FDPEvent.php';
|
12 |
|
13 |
use PixelYourSite\Facebook\Helpers;
|
14 |
|
105 |
case 'custom_event':
|
106 |
return $this->getCustomEventParams( $args );
|
107 |
|
108 |
+
case 'fdp_event':
|
109 |
+
return $this->getFDPEventParams( $args );
|
110 |
+
|
111 |
case 'woo_view_content':
|
112 |
return $this->getWooViewContentEventParams();
|
113 |
|
262 |
|
263 |
}
|
264 |
|
265 |
+
public function getFDPEvents() {
|
266 |
+
$events = array();
|
267 |
+
$contentType = $this->getOption("fdp_content_type");
|
268 |
+
if($this->getOption("fdp_view_content_enabled")) {
|
269 |
+
$event = new FDPEvent();
|
270 |
+
$event->event_name = "fdp_view_content";
|
271 |
+
$event->content_type = $contentType;
|
272 |
+
$events[] = $event;
|
273 |
+
}
|
274 |
+
if($this->getOption("fdp_view_category_enabled")) {
|
275 |
+
$event = new FDPEvent();
|
276 |
+
$event->event_name = "fdp_view_category";
|
277 |
+
$event->content_type = $contentType;
|
278 |
+
$events[] = $event;
|
279 |
+
}
|
280 |
+
if($this->getOption("fdp_add_to_cart_enabled")) {
|
281 |
+
$event = new FDPEvent();
|
282 |
+
$event->event_name = "fdp_add_to_cart";
|
283 |
+
$event->content_type = $contentType;
|
284 |
+
$event->trigger_type = "scroll_pos";
|
285 |
+
$event->trigger_value = $this->getOption("fdp_add_to_cart_event_fire_scroll");
|
286 |
+
$events[] = $event;
|
287 |
+
}
|
288 |
+
if($this->getOption("fdp_purchase_enabled")) {
|
289 |
+
$event = new FDPEvent();
|
290 |
+
$event->event_name = "fdp_purchase";
|
291 |
+
$event->content_type = $contentType;
|
292 |
+
$event->trigger_type = $this->getOption("fdp_purchase_event_fire");
|
293 |
+
if($event->trigger_type == "scroll_pos") {
|
294 |
+
$event->trigger_value = $this->getOption("fdp_purchase_event_fire_scroll");
|
295 |
+
}
|
296 |
+
if($event->trigger_type == "css_click") {
|
297 |
+
$event->trigger_value = $this->getOption("fdp_purchase_event_fire_css");
|
298 |
+
}
|
299 |
+
|
300 |
+
$events[] = $event;
|
301 |
+
}
|
302 |
+
return $events;
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* @param FDPEvent $event
|
307 |
+
* @return array
|
308 |
+
*/
|
309 |
+
|
310 |
+
private function getFDPEventParams($event){
|
311 |
+
|
312 |
+
$name = "";
|
313 |
+
$params = "";
|
314 |
+
|
315 |
+
if($event->event_name == "fdp_view_content") {
|
316 |
+
$name = "ViewContent";
|
317 |
+
$params = Helpers\getFDPViewContentEventParams();
|
318 |
+
}
|
319 |
+
|
320 |
+
if($event->event_name == "fdp_view_category") {
|
321 |
+
$name = "ViewCategory";
|
322 |
+
$params = Helpers\getFDPViewCategoryEventParams();
|
323 |
+
}
|
324 |
+
|
325 |
+
if($event->event_name == "fdp_add_to_cart") {
|
326 |
+
$name = "AddToCart";
|
327 |
+
$params = Helpers\getFDPAddToCartEventParams();
|
328 |
+
}
|
329 |
+
|
330 |
+
if($event->event_name == "fdp_purchase") {
|
331 |
+
$name = "Purchase";
|
332 |
+
$params = Helpers\getFDPPurchaseEventParams();
|
333 |
+
}
|
334 |
+
|
335 |
+
|
336 |
+
if($event->content_type) {
|
337 |
+
$params["content_type"] = $event->content_type;
|
338 |
+
}
|
339 |
+
|
340 |
+
return array(
|
341 |
+
'name' => $name,
|
342 |
+
'data' => $params,
|
343 |
+
'delay' => 0,
|
344 |
+
);
|
345 |
+
}
|
346 |
+
|
347 |
private function getWooViewContentEventParams() {
|
348 |
global $post;
|
349 |
|
380 |
|
381 |
$value_option = PYS()->getOption( 'woo_view_content_value_option' );
|
382 |
$global_value = PYS()->getOption( 'woo_view_content_value_global', 0 );
|
383 |
+
|
384 |
+
update_option('woo_content_value_cog', $value_option);
|
385 |
+
|
386 |
+
$params['value'] = getWooEventValue( $value_option, $amount, $global_value, $post->ID );
|
387 |
$params['currency'] = get_woocommerce_currency();
|
388 |
|
389 |
}
|
603 |
$amount = $order->get_total();
|
604 |
$value_option = PYS()->getOption( 'woo_purchase_value_option' );
|
605 |
$global_value = PYS()->getOption( 'woo_purchase_value_global', 0 );
|
606 |
+
|
607 |
+
update_option('woo_purchase_value_cog', $value_option);
|
608 |
+
|
609 |
+
$params['value'] = getWooEventValueOrder( $value_option, $amount, $global_value, $order_id, $content_ids );
|
610 |
$params['currency'] = get_woocommerce_currency();
|
611 |
$params['transaction_id'] = $order_id;
|
612 |
|
modules/facebook/function-helpers.php
CHANGED
@@ -295,7 +295,9 @@ function getWooSingleAddToCartParams( $product_id, $qty = 1 ) {
|
|
295 |
$value_option = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_option' );
|
296 |
$global_value = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_global', 0 );
|
297 |
|
298 |
-
|
|
|
|
|
299 |
$params['currency'] = get_woocommerce_currency();
|
300 |
|
301 |
}
|
@@ -396,7 +398,9 @@ function getWooCartParams( $context = 'cart' ) {
|
|
396 |
$value_option = PixelYourSite\PYS()->getOption( $value_option_option );
|
397 |
$global_value = PixelYourSite\PYS()->getOption( $value_global_option, 0 );
|
398 |
|
399 |
-
|
|
|
|
|
400 |
$params['currency'] = get_woocommerce_currency();
|
401 |
|
402 |
}
|
@@ -453,4 +457,103 @@ function getEddCustomAudiencesOptimizationParams( $post_id ) {
|
|
453 |
|
454 |
return $params;
|
455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
}
|
295 |
$value_option = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_option' );
|
296 |
$global_value = PixelYourSite\PYS()->getOption( 'woo_add_to_cart_value_global', 0 );
|
297 |
|
298 |
+
update_option('woo_add_to_cart_value_cog', $value_option);
|
299 |
+
|
300 |
+
$params['value'] = PixelYourSite\getWooEventValue( $value_option, $amount, $global_value, $product_id );
|
301 |
$params['currency'] = get_woocommerce_currency();
|
302 |
|
303 |
}
|
398 |
$value_option = PixelYourSite\PYS()->getOption( $value_option_option );
|
399 |
$global_value = PixelYourSite\PYS()->getOption( $value_global_option, 0 );
|
400 |
|
401 |
+
update_option('woo_initiate_checkout_value_cog', $value_option);
|
402 |
+
|
403 |
+
$params['value'] = PixelYourSite\getWooEventValueCart( $value_option, $amount, $global_value );
|
404 |
$params['currency'] = get_woocommerce_currency();
|
405 |
|
406 |
}
|
457 |
|
458 |
return $params;
|
459 |
|
460 |
+
}
|
461 |
+
|
462 |
+
function getFDPViewContentEventParams() {
|
463 |
+
$tagsArray = wp_get_post_tags();
|
464 |
+
$catArray = get_the_category();
|
465 |
+
|
466 |
+
$tags = "";
|
467 |
+
if(is_array($tagsArray)) {
|
468 |
+
$tags = implode(", ",$tagsArray);
|
469 |
+
}
|
470 |
+
|
471 |
+
$func = function($value) {
|
472 |
+
return $value->cat_name;
|
473 |
+
};
|
474 |
+
$catArray = array_map($func,$catArray);
|
475 |
+
$categories = implode(", ",$catArray);
|
476 |
+
|
477 |
+
|
478 |
+
$params = array(
|
479 |
+
'content_name' => get_the_title(),
|
480 |
+
'content_ids' => get_the_ID(),
|
481 |
+
'tags' => $tags,
|
482 |
+
'categories' => $categories
|
483 |
+
);
|
484 |
+
|
485 |
+
|
486 |
+
return $params;
|
487 |
+
}
|
488 |
+
|
489 |
+
function getFDPViewCategoryEventParams() {
|
490 |
+
global $wp_query;
|
491 |
+
$func = function($value) {
|
492 |
+
return $value->ID;
|
493 |
+
};
|
494 |
+
$ids = array_map($func,$wp_query->posts);
|
495 |
+
|
496 |
+
|
497 |
+
$params = array(
|
498 |
+
'content_name' => single_term_title('', 0),
|
499 |
+
'content_ids' => json_encode($ids)
|
500 |
+
);
|
501 |
+
|
502 |
+
return $params;
|
503 |
+
}
|
504 |
+
|
505 |
+
function getFDPAddToCartEventParams() {
|
506 |
+
$tagsArray = wp_get_post_tags();
|
507 |
+
$catArray = get_the_category();
|
508 |
+
|
509 |
+
$tags = "";
|
510 |
+
if(is_array($tagsArray)) {
|
511 |
+
$tags = implode(", ",$tagsArray);
|
512 |
+
}
|
513 |
+
|
514 |
+
$func = function($value) {
|
515 |
+
return $value->cat_name;
|
516 |
+
};
|
517 |
+
$catArray = array_map($func,$catArray);
|
518 |
+
$categories = implode(", ",$catArray);
|
519 |
+
|
520 |
+
|
521 |
+
$params = array(
|
522 |
+
'content_name' => get_the_title(),
|
523 |
+
'content_ids' => get_the_ID(),
|
524 |
+
'tags' => $tags,
|
525 |
+
'categories' => $categories,
|
526 |
+
'value' => 0
|
527 |
+
);
|
528 |
+
|
529 |
+
|
530 |
+
return $params;
|
531 |
+
}
|
532 |
+
|
533 |
+
function getFDPPurchaseEventParams() {
|
534 |
+
$tagsArray = wp_get_post_tags();
|
535 |
+
$catArray = get_the_category();
|
536 |
+
|
537 |
+
$tags = "";
|
538 |
+
if(is_array($tagsArray)) {
|
539 |
+
$tags = implode(", ",$tagsArray);
|
540 |
+
}
|
541 |
+
|
542 |
+
$func = function($value) {
|
543 |
+
return $value->cat_name;
|
544 |
+
};
|
545 |
+
$catArray = array_map($func,$catArray);
|
546 |
+
$categories = implode(", ",$catArray);
|
547 |
+
|
548 |
+
|
549 |
+
$params = array(
|
550 |
+
'content_name' => get_the_title(),
|
551 |
+
'content_ids' => get_the_ID(),
|
552 |
+
'tags' => $tags,
|
553 |
+
'categories' => $categories,
|
554 |
+
'value' => 0
|
555 |
+
);
|
556 |
+
|
557 |
+
|
558 |
+
return $params;
|
559 |
}
|
modules/facebook/options_defaults.json
CHANGED
@@ -30,5 +30,16 @@
|
|
30 |
"edd_remove_from_cart_enabled": true,
|
31 |
"edd_add_to_cart_enabled": true,
|
32 |
"edd_view_content_enabled": true,
|
33 |
-
"edd_view_category_enabled": true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
30 |
"edd_remove_from_cart_enabled": true,
|
31 |
"edd_add_to_cart_enabled": true,
|
32 |
"edd_view_content_enabled": true,
|
33 |
+
"edd_view_category_enabled": true,
|
34 |
+
|
35 |
+
|
36 |
+
"fdp_content_type" : "product",
|
37 |
+
"fdp_view_content_enabled": false,
|
38 |
+
"fdp_view_category_enabled": false,
|
39 |
+
"fdp_add_to_cart_enabled": false,
|
40 |
+
"fdp_add_to_cart_event_fire_scroll": "50",
|
41 |
+
"fdp_purchase_enabled": false,
|
42 |
+
"fdp_purchase_event_fire" : "scroll_pos",
|
43 |
+
"fdp_purchase_event_fire_scroll": "90",
|
44 |
+
"fdp_purchase_event_fire_css": ""
|
45 |
}
|
modules/facebook/options_fields.json
CHANGED
@@ -30,5 +30,15 @@
|
|
30 |
"edd_remove_from_cart_enabled": "checkbox",
|
31 |
"edd_add_to_cart_enabled": "checkbox",
|
32 |
"edd_view_content_enabled": "checkbox",
|
33 |
-
"edd_view_category_enabled": "checkbox"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
30 |
"edd_remove_from_cart_enabled": "checkbox",
|
31 |
"edd_add_to_cart_enabled": "checkbox",
|
32 |
"edd_view_content_enabled": "checkbox",
|
33 |
+
"edd_view_category_enabled": "checkbox",
|
34 |
+
|
35 |
+
"fdp_content_type" : "select",
|
36 |
+
"fdp_view_content_enabled": "checkbox",
|
37 |
+
"fdp_view_category_enabled": "checkbox",
|
38 |
+
"fdp_add_to_cart_enabled": "checkbox",
|
39 |
+
"fdp_add_to_cart_event_fire_scroll": "text",
|
40 |
+
"fdp_purchase_enabled": "checkbox",
|
41 |
+
"fdp_purchase_event_fire" : "select",
|
42 |
+
"fdp_purchase_event_fire_scroll": "text",
|
43 |
+
"fdp_purchase_event_fire_css": "text"
|
44 |
}
|
modules/google_analytics/ga.php
CHANGED
@@ -379,18 +379,28 @@ class GA extends Settings implements Pixel {
|
|
379 |
return false;
|
380 |
}
|
381 |
$content_id = GA\Helpers\getWooProductContentId($product_id);
|
382 |
-
$product =
|
383 |
$price = getWooProductPriceToDisplay( $product_id, 1 );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
|
385 |
$params = array(
|
386 |
'event_category' => 'ecommerce',
|
387 |
'items' => array(
|
388 |
array(
|
389 |
'id' => $content_id,
|
390 |
-
'name' => $
|
391 |
-
'category' =>
|
392 |
'quantity' => 1,
|
393 |
'price' => $price,
|
|
|
394 |
),
|
395 |
),
|
396 |
'non_interaction' => $this->getOption( 'woo_add_to_cart_non_interactive' ),
|
@@ -426,13 +436,23 @@ class GA extends Settings implements Pixel {
|
|
426 |
|
427 |
$product_id = $cart_item['product_id'];
|
428 |
|
429 |
-
$product =
|
|
|
|
|
|
|
430 |
|
431 |
if ( ! empty( $cart_item['variation_id'] ) ) {
|
432 |
-
$variation =
|
433 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
} else {
|
435 |
$variation_name = null;
|
|
|
436 |
}
|
437 |
|
438 |
return array(
|
@@ -442,8 +462,8 @@ class GA extends Settings implements Pixel {
|
|
442 |
'items' => array(
|
443 |
array(
|
444 |
'id' => $product_id,
|
445 |
-
'name' => $
|
446 |
-
'category' =>
|
447 |
'quantity' => $cart_item['quantity'],
|
448 |
'price' => getWooProductPriceToDisplay( $product_id, $cart_item['quantity'] ),
|
449 |
'variant' => $variation_name,
|
@@ -489,14 +509,21 @@ class GA extends Settings implements Pixel {
|
|
489 |
$product_id = GA\Helpers\getWooCartItemId( $line_item );
|
490 |
$content_id = GA\Helpers\getWooProductContentId( $product_id );
|
491 |
|
492 |
-
$post = get_post( $product_id );
|
493 |
$product = wc_get_product( $product_id );
|
|
|
494 |
|
495 |
if ( $line_item['variation_id'] ) {
|
496 |
-
$variation
|
497 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
498 |
} else {
|
499 |
$variation_name = null;
|
|
|
500 |
}
|
501 |
|
502 |
/**
|
@@ -532,8 +559,8 @@ class GA extends Settings implements Pixel {
|
|
532 |
|
533 |
$item = array(
|
534 |
'id' => $content_id,
|
535 |
-
'name' => $
|
536 |
-
'category' =>
|
537 |
'quantity' => $qty,
|
538 |
'price' => $price,
|
539 |
'variant' => $variation_name,
|
@@ -572,19 +599,27 @@ class GA extends Settings implements Pixel {
|
|
572 |
$product_id = GA\Helpers\getWooCartItemId( $cart_item );
|
573 |
$content_id = GA\Helpers\getWooProductContentId( $product_id );
|
574 |
|
575 |
-
$product =
|
|
|
576 |
|
577 |
if ( $cart_item['variation_id'] ) {
|
578 |
-
$variation =
|
579 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
} else {
|
581 |
$variation_name = null;
|
|
|
582 |
}
|
583 |
|
584 |
$item = array(
|
585 |
'id' => $content_id,
|
586 |
-
'name' => $
|
587 |
-
'category' =>
|
588 |
'quantity' => $cart_item['quantity'],
|
589 |
'price' => getWooProductPriceToDisplay( $product_id ),
|
590 |
'variant' => $variation_name,
|
379 |
return false;
|
380 |
}
|
381 |
$content_id = GA\Helpers\getWooProductContentId($product_id);
|
382 |
+
$product = wc_get_product( $product_id );
|
383 |
$price = getWooProductPriceToDisplay( $product_id, 1 );
|
384 |
+
$name = $product->get_title();
|
385 |
+
|
386 |
+
if ( $product->get_type() == 'variation' ) {
|
387 |
+
$variation_name = implode("/", $product->get_variation_attributes());
|
388 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $product->get_parent_id() ) );
|
389 |
+
} else {
|
390 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $product_id ) );
|
391 |
+
$variation_name = null;
|
392 |
+
}
|
393 |
|
394 |
$params = array(
|
395 |
'event_category' => 'ecommerce',
|
396 |
'items' => array(
|
397 |
array(
|
398 |
'id' => $content_id,
|
399 |
+
'name' => $name,
|
400 |
+
'category' => $categories,
|
401 |
'quantity' => 1,
|
402 |
'price' => $price,
|
403 |
+
'variant' => $variation_name,
|
404 |
),
|
405 |
),
|
406 |
'non_interaction' => $this->getOption( 'woo_add_to_cart_non_interactive' ),
|
436 |
|
437 |
$product_id = $cart_item['product_id'];
|
438 |
|
439 |
+
$product = wc_get_product( $product_id );
|
440 |
+
if(!$product) return false;
|
441 |
+
|
442 |
+
$name = $product->get_title();
|
443 |
|
444 |
if ( ! empty( $cart_item['variation_id'] ) ) {
|
445 |
+
$variation = wc_get_product( (int) $cart_item['variation_id'] );
|
446 |
+
if($variation && $variation->get_type() == 'variation') {
|
447 |
+
$variation_name = implode("/", $variation->get_variation_attributes());
|
448 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $variation->get_parent_id() ) );
|
449 |
+
} else {
|
450 |
+
$variation_name = null;
|
451 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $product_id ) );
|
452 |
+
}
|
453 |
} else {
|
454 |
$variation_name = null;
|
455 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $product_id ) );
|
456 |
}
|
457 |
|
458 |
return array(
|
462 |
'items' => array(
|
463 |
array(
|
464 |
'id' => $product_id,
|
465 |
+
'name' => $name,
|
466 |
+
'category' => $categories,
|
467 |
'quantity' => $cart_item['quantity'],
|
468 |
'price' => getWooProductPriceToDisplay( $product_id, $cart_item['quantity'] ),
|
469 |
'variant' => $variation_name,
|
509 |
$product_id = GA\Helpers\getWooCartItemId( $line_item );
|
510 |
$content_id = GA\Helpers\getWooProductContentId( $product_id );
|
511 |
|
|
|
512 |
$product = wc_get_product( $product_id );
|
513 |
+
$name = $product->get_title();
|
514 |
|
515 |
if ( $line_item['variation_id'] ) {
|
516 |
+
$variation = wc_get_product( $line_item['variation_id'] );
|
517 |
+
if($variation && $variation->get_type() == 'variation') {
|
518 |
+
$variation_name = implode("/", $variation->get_variation_attributes());
|
519 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $variation->get_parent_id() ) );
|
520 |
+
} else {
|
521 |
+
$variation_name = null;
|
522 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $product_id ) );
|
523 |
+
}
|
524 |
} else {
|
525 |
$variation_name = null;
|
526 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $product_id ) );
|
527 |
}
|
528 |
|
529 |
/**
|
559 |
|
560 |
$item = array(
|
561 |
'id' => $content_id,
|
562 |
+
'name' => $name,
|
563 |
+
'category' => $categories,
|
564 |
'quantity' => $qty,
|
565 |
'price' => $price,
|
566 |
'variant' => $variation_name,
|
599 |
$product_id = GA\Helpers\getWooCartItemId( $cart_item );
|
600 |
$content_id = GA\Helpers\getWooProductContentId( $product_id );
|
601 |
|
602 |
+
$product = wc_get_product( $product_id );
|
603 |
+
$name = $product->get_title();
|
604 |
|
605 |
if ( $cart_item['variation_id'] ) {
|
606 |
+
$variation = wc_get_product( $cart_item['variation_id'] );
|
607 |
+
if ( $variation && $variation->get_type() == 'variation' ) {
|
608 |
+
$variation_name = implode("/", $variation->get_variation_attributes());
|
609 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $variation->get_parent_id() ) );
|
610 |
+
} else {
|
611 |
+
$variation_name = null;
|
612 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $product_id ) );
|
613 |
+
}
|
614 |
} else {
|
615 |
$variation_name = null;
|
616 |
+
$categories = implode( '/', getObjectTerms( 'product_cat', $product_id ) );
|
617 |
}
|
618 |
|
619 |
$item = array(
|
620 |
'id' => $content_id,
|
621 |
+
'name' => $name,
|
622 |
+
'category' => $categories,
|
623 |
'quantity' => $cart_item['quantity'],
|
624 |
'price' => getWooProductPriceToDisplay( $product_id ),
|
625 |
'variant' => $variation_name,
|
modules/head_footer/head_footer.php
CHANGED
@@ -81,7 +81,7 @@ class HeadFooter extends Settings {
|
|
81 |
}
|
82 |
|
83 |
if ( ! isset( $_POST['pys_head_footer'] ) ) {
|
84 |
-
|
85 |
return;
|
86 |
}
|
87 |
|
81 |
}
|
82 |
|
83 |
if ( ! isset( $_POST['pys_head_footer'] ) ) {
|
84 |
+
// delete_post_meta( $post_id, '_pys_head_footer' );
|
85 |
return;
|
86 |
}
|
87 |
|
pixelyoursite.php
CHANGED
@@ -4,28 +4,28 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
4 |
exit; // Exit if accessed directly.
|
5 |
}
|
6 |
|
7 |
-
define( 'PYS_FREE_VERSION', '7.1.
|
8 |
define( 'PYS_FREE_PINTEREST_MIN_VERSION', '2.0.6' );
|
9 |
define( 'PYS_FREE_BING_MIN_VERSION', '1.0.0' );
|
10 |
define( 'PYS_FREE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
|
11 |
define( 'PYS_FREE_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
|
12 |
|
13 |
-
require_once 'vendor/autoload.php';
|
14 |
-
require_once 'includes/functions-common.php';
|
15 |
-
require_once 'includes/functions-admin.php';
|
16 |
-
require_once 'includes/functions-custom-event.php';
|
17 |
-
require_once 'includes/functions-woo.php';
|
18 |
-
require_once 'includes/functions-edd.php';
|
19 |
-
require_once 'includes/functions-system-report.php';
|
20 |
-
require_once 'includes/functions-license.php';
|
21 |
-
require_once 'includes/functions-update-plugin.php';
|
22 |
-
require_once 'includes/functions-gdpr.php';
|
23 |
-
require_once 'includes/functions-migrate.php';
|
24 |
-
require_once 'includes/functions-optin.php';
|
25 |
-
require_once 'includes/functions-promo-notices.php';
|
26 |
-
require_once 'includes/class-pixel.php';
|
27 |
-
require_once 'includes/class-settings.php';
|
28 |
-
require_once 'includes/class-plugin.php';
|
29 |
|
30 |
register_activation_hook( __FILE__, 'pysFreeActivation' );
|
31 |
function pysFreeActivation() {
|
@@ -44,13 +44,13 @@ if ( PixelYourSite\isPysProActive() ) {
|
|
44 |
return; // exit early when PYS PRO is active
|
45 |
}
|
46 |
|
47 |
-
require_once 'includes/class-pys.php';
|
48 |
-
require_once 'includes/class-events-manager.php';
|
49 |
-
require_once 'includes/class-custom-event.php';
|
50 |
-
require_once 'includes/class-custom-event-factory.php';
|
51 |
-
require_once 'modules/facebook/facebook.php';
|
52 |
-
require_once 'modules/google_analytics/ga.php';
|
53 |
-
require_once 'modules/head_footer/head_footer.php';
|
54 |
|
55 |
// here we go...
|
56 |
PixelYourSite\PYS();
|
4 |
exit; // Exit if accessed directly.
|
5 |
}
|
6 |
|
7 |
+
define( 'PYS_FREE_VERSION', '7.1.6' );
|
8 |
define( 'PYS_FREE_PINTEREST_MIN_VERSION', '2.0.6' );
|
9 |
define( 'PYS_FREE_BING_MIN_VERSION', '1.0.0' );
|
10 |
define( 'PYS_FREE_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
|
11 |
define( 'PYS_FREE_URL', untrailingslashit( plugin_dir_url( __FILE__ ) ) );
|
12 |
|
13 |
+
require_once PYS_FREE_PATH.'/vendor/autoload.php';
|
14 |
+
require_once PYS_FREE_PATH.'/includes/functions-common.php';
|
15 |
+
require_once PYS_FREE_PATH.'/includes/functions-admin.php';
|
16 |
+
require_once PYS_FREE_PATH.'/includes/functions-custom-event.php';
|
17 |
+
require_once PYS_FREE_PATH.'/includes/functions-woo.php';
|
18 |
+
require_once PYS_FREE_PATH.'/includes/functions-edd.php';
|
19 |
+
require_once PYS_FREE_PATH.'/includes/functions-system-report.php';
|
20 |
+
require_once PYS_FREE_PATH.'/includes/functions-license.php';
|
21 |
+
require_once PYS_FREE_PATH.'/includes/functions-update-plugin.php';
|
22 |
+
require_once PYS_FREE_PATH.'/includes/functions-gdpr.php';
|
23 |
+
require_once PYS_FREE_PATH.'/includes/functions-migrate.php';
|
24 |
+
require_once PYS_FREE_PATH.'/includes/functions-optin.php';
|
25 |
+
require_once PYS_FREE_PATH.'/includes/functions-promo-notices.php';
|
26 |
+
require_once PYS_FREE_PATH.'/includes/class-pixel.php';
|
27 |
+
require_once PYS_FREE_PATH.'/includes/class-settings.php';
|
28 |
+
require_once PYS_FREE_PATH.'/includes/class-plugin.php';
|
29 |
|
30 |
register_activation_hook( __FILE__, 'pysFreeActivation' );
|
31 |
function pysFreeActivation() {
|
44 |
return; // exit early when PYS PRO is active
|
45 |
}
|
46 |
|
47 |
+
require_once PYS_FREE_PATH.'/includes/class-pys.php';
|
48 |
+
require_once PYS_FREE_PATH.'/includes/class-events-manager.php';
|
49 |
+
require_once PYS_FREE_PATH.'/includes/class-custom-event.php';
|
50 |
+
require_once PYS_FREE_PATH.'/includes/class-custom-event-factory.php';
|
51 |
+
require_once PYS_FREE_PATH.'/modules/facebook/facebook.php';
|
52 |
+
require_once PYS_FREE_PATH.'/modules/google_analytics/ga.php';
|
53 |
+
require_once PYS_FREE_PATH.'/modules/head_footer/head_footer.php';
|
54 |
|
55 |
// here we go...
|
56 |
PixelYourSite\PYS();
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: Facebook Pixel, New Facebook Pixel, Facebook Conversion Pixel, Facebook Pi
|
|
4 |
Requires at least: 3.0.1
|
5 |
Requires PHP: 5.4
|
6 |
Tested up to: 5.4
|
7 |
-
Stable tag: 7.1.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -345,7 +345,7 @@ There's a strange solution: it appears that if you have the Yoast plugin install
|
|
345 |
|
346 |
Yes, there are, and we will explain them here:
|
347 |
|
348 |
-
*We offer you the possibility to voluntarily subscribe to our newsletter and get valuable tips. We manage our newsletter using ActiveCampaing. When you subscribe, we will call our server that intermediates the API connection, and then the data is sent to ActiveCampaign. The information that is passed: the name you provide and the email. If you check the "I use WooCommerce" checkbox, we will add this information as a tag, to give you better tips in the future.
|
349 |
|
350 |
*Add-on updates: the plugin works with free or paid add-ons (for Pinterest, Bing, etc) that we provide and host on our server. When you install such an add-on, we will do checks for updates. If you have a valid license for the add-on, we will automatically download the latest version of the add-on from our servers. The core plugin (PixelYourSite itself) updates are provided using WordPress own servers.
|
351 |
|
@@ -355,7 +355,7 @@ Yes, there are, and we will explain them here:
|
|
355 |
|
356 |
**Do you record data about the websites' traffic**
|
357 |
|
358 |
-
NO, absolutely not! We don't track any type of data about your website. We simply implement the pixel/tag code.
|
359 |
|
360 |
|
361 |
|
@@ -388,6 +388,29 @@ NO, absolutely not! We don't track any type of data about your website. We simpl
|
|
388 |
|
389 |
== Changelog ==
|
390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
= PixelYourSite 7.1.4 =
|
392 |
|
393 |
* Minor code changes to declare compatibility with WordPress 5.3 and WooCommerce 3.8.
|
@@ -417,7 +440,7 @@ Recommendation: if you have manually added events using the On-Page trigger, tes
|
|
417 |
|
418 |
* Compatibility with WooCommerce 3.7
|
419 |
|
420 |
-
* New structure for the Form and Comment events. It will help you better identify what actions have fired the events.
|
421 |
|
422 |
Form Event for the Facebook Pixel and the Pinterest Tag:
|
423 |
|
4 |
Requires at least: 3.0.1
|
5 |
Requires PHP: 5.4
|
6 |
Tested up to: 5.4
|
7 |
+
Stable tag: 7.1.6
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
345 |
|
346 |
Yes, there are, and we will explain them here:
|
347 |
|
348 |
+
*We offer you the possibility to voluntarily subscribe to our newsletter and get valuable tips. We manage our newsletter using ActiveCampaing. When you subscribe, we will call our server that intermediates the API connection, and then the data is sent to ActiveCampaign. The information that is passed: the name you provide and the email. If you check the "I use WooCommerce" checkbox, we will add this information as a tag, to give you better tips in the future.
|
349 |
|
350 |
*Add-on updates: the plugin works with free or paid add-ons (for Pinterest, Bing, etc) that we provide and host on our server. When you install such an add-on, we will do checks for updates. If you have a valid license for the add-on, we will automatically download the latest version of the add-on from our servers. The core plugin (PixelYourSite itself) updates are provided using WordPress own servers.
|
351 |
|
355 |
|
356 |
**Do you record data about the websites' traffic**
|
357 |
|
358 |
+
NO, absolutely not! We don't track any type of data about your website. We simply implement the pixel/tag code.
|
359 |
|
360 |
|
361 |
|
388 |
|
389 |
== Changelog ==
|
390 |
|
391 |
+
= PixelYourSite 7.1.6 =
|
392 |
+
|
393 |
+
* Small code update to declare WooCommerce 4.0 compatibility.
|
394 |
+
|
395 |
+
* Fixes for some issues related to file paths. In some environments this was causing error on Elementor or WooCommerce admin pages.
|
396 |
+
|
397 |
+
* A new option to use PROFIT as value for your Facebook Pixel WooCommerce events. It works with the [WooCommerce Cost of Goods plugin by PixelYourSite](https://www.pixelyoursite.com/woocommerce-cost-of-goods)
|
398 |
+
|
399 |
+
= PixelYourSite 7.1.5 =
|
400 |
+
|
401 |
+
* New features: Facebook Dynamic Ads events for blog posts. Simulate the DPA required events on normal blog posts. We will soon release a dedicated plugin that will help you import your blog content into a Facebook Product Catalog.
|
402 |
+
|
403 |
+
* Google Analytics Enhanced Ecommerce: we removed the variation name from the product title and we added it as a separate parameter.
|
404 |
+
|
405 |
+
* Google Analytics Enhanced Ecommerce: we fixed an error with variable products category.
|
406 |
+
|
407 |
+
* Elementor: we fixed an error that was deleting Head & Footer scripts when a page was saved using Elementor.
|
408 |
+
|
409 |
+
* UI updates to reflect new paid features: fire custom events once in X hours; Google Analytics list performance tracking.
|
410 |
+
|
411 |
+
* Small code change to declare WooCommerce 3.9 compatibility.
|
412 |
+
|
413 |
+
|
414 |
= PixelYourSite 7.1.4 =
|
415 |
|
416 |
* Minor code changes to declare compatibility with WordPress 5.3 and WooCommerce 3.8.
|
440 |
|
441 |
* Compatibility with WooCommerce 3.7
|
442 |
|
443 |
+
* New structure for the Form and Comment events. It will help you better identify what actions have fired the events.
|
444 |
|
445 |
Form Event for the Facebook Pixel and the Pinterest Tag:
|
446 |
|