Facebook for WooCommerce - Version 1.10.0

Version Description

Download this release

Release Info

Developer SkyVerge
Plugin Icon Facebook for WooCommerce
Version 1.10.0
Comparing to
See all releases

Code changes from version 1.9.15 to 1.10.0

Files changed (74) hide show
  1. assets/css/admin/facebook-for-woocommerce-products-admin.css +37 -0
  2. assets/css/facebook.css +36 -0
  3. assets/js/admin/facebook-for-woocommerce-products-admin.js +264 -0
  4. assets/js/admin/facebook-for-woocommerce-products-admin.min.js +1 -0
  5. assets/js/admin/facebook-for-woocommerce-settings-sync.js +184 -0
  6. assets/js/admin/facebook-for-woocommerce-settings-sync.min.js +1 -0
  7. assets/js/facebook-for-woocommerce-modal.js +44 -0
  8. assets/js/facebook-for-woocommerce-modal.min.js +1 -0
  9. assets/js/facebook-infobanner.min.js +1 -0
  10. assets/js/facebook-metabox.min.js +1 -0
  11. assets/js/facebook-products.js +0 -84
  12. assets/js/facebook-settings.js +132 -175
  13. assets/js/facebook-settings.min.js +1 -0
  14. changelog.txt +425 -415
  15. class-wc-facebookcommerce.php +381 -0
  16. composer.json +0 -16
  17. facebook-commerce-events-tracker.php +274 -129
  18. facebook-commerce-messenger-chat.php +236 -47
  19. facebook-commerce-pixel-event.php +93 -37
  20. facebook-commerce.php +2461 -1192
  21. facebook-for-woocommerce.php +344 -79
  22. i18n/languages/facebook-for-woocommerce.pot +531 -0
  23. includes/AJAX.php +494 -0
  24. includes/Admin.php +878 -0
  25. includes/Lifecycle.php +156 -0
  26. includes/Products.php +254 -0
  27. includes/fbgraph.php +37 -3
  28. includes/fbinfobanner.php +20 -13
  29. includes/fbproduct.php +55 -49
  30. includes/fbproductfeed.php +14 -2
  31. includes/fbutils.php +2 -1
  32. includes/fbwpml.php +71 -53
  33. includes/test/facebook-integration-test.php +4 -3
  34. readme.txt +76 -66
  35. vendor/skyverge/wc-plugin-framework/license.txt +694 -0
  36. vendor/skyverge/wc-plugin-framework/woocommerce/Addresses/Address.php +292 -0
  37. vendor/skyverge/wc-plugin-framework/woocommerce/Addresses/Customer_Address.php +150 -0
  38. vendor/skyverge/wc-plugin-framework/woocommerce/Country_Helper.php +661 -0
  39. vendor/skyverge/wc-plugin-framework/woocommerce/Lifecycle.php +667 -0
  40. vendor/skyverge/wc-plugin-framework/woocommerce/admin/abstract-sv-wc-plugin-admin-setup-wizard.php +1300 -0
  41. vendor/skyverge/wc-plugin-framework/woocommerce/api/abstract-sv-wc-api-json-request.php +135 -0
  42. vendor/skyverge/wc-plugin-framework/woocommerce/api/abstract-sv-wc-api-json-response.php +105 -0
  43. vendor/skyverge/wc-plugin-framework/woocommerce/api/abstract-sv-wc-api-xml-request.php +216 -0
  44. vendor/skyverge/wc-plugin-framework/woocommerce/api/abstract-sv-wc-api-xml-response.php +138 -0
  45. vendor/skyverge/wc-plugin-framework/woocommerce/api/class-sv-wc-api-base.php +836 -0
  46. vendor/skyverge/wc-plugin-framework/woocommerce/api/class-sv-wc-api-exception.php +38 -0
  47. vendor/skyverge/wc-plugin-framework/woocommerce/api/interface-sv-wc-api-request.php +97 -0
  48. vendor/skyverge/wc-plugin-framework/woocommerce/api/interface-sv-wc-api-response.php +59 -0
  49. vendor/skyverge/wc-plugin-framework/woocommerce/assets/css/admin/sv-wc-plugin-admin-setup-wizard.min.css +1 -0
  50. vendor/skyverge/wc-plugin-framework/woocommerce/assets/images/ajax-loader.gif +0 -0
  51. vendor/skyverge/wc-plugin-framework/woocommerce/assets/js/admin/sv-wc-plugin-admin-setup-wizard.min.js +1 -0
  52. vendor/skyverge/wc-plugin-framework/woocommerce/assets/js/admin/sv-wp-admin-job-batch-handler.min.js +1 -0
  53. vendor/skyverge/wc-plugin-framework/woocommerce/changelog.txt +331 -0
  54. vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-admin-notice-handler.php +433 -0
  55. vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-framework-bootstrap.php +407 -0
  56. vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-helper.php +1024 -0
  57. vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-hook-deprecator.php +199 -0
  58. vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin-compatibility.php +483 -0
  59. vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin-dependencies.php +468 -0
  60. vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin-exception.php +38 -0
  61. vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wc-plugin.php +1457 -0
  62. vendor/skyverge/wc-plugin-framework/woocommerce/class-sv-wp-admin-message-handler.php +438 -0
  63. vendor/skyverge/wc-plugin-framework/woocommerce/compatibility/abstract-sv-wc-data-compatibility.php +169 -0
  64. vendor/skyverge/wc-plugin-framework/woocommerce/compatibility/class-sv-wc-datetime.php +146 -0
  65. vendor/skyverge/wc-plugin-framework/woocommerce/compatibility/class-sv-wc-order-compatibility.php +528 -0
  66. vendor/skyverge/wc-plugin-framework/woocommerce/compatibility/class-sv-wc-product-compatibility.php +242 -0
  67. vendor/skyverge/wc-plugin-framework/woocommerce/i18n/languages/woocommerce-plugin-framework-et.mo +0 -0
  68. vendor/skyverge/wc-plugin-framework/woocommerce/i18n/languages/woocommerce-plugin-framework-et.po +2176 -0
  69. vendor/skyverge/wc-plugin-framework/woocommerce/i18n/languages/woocommerce-plugin-framework.pot +1939 -0
  70. vendor/skyverge/wc-plugin-framework/woocommerce/index.php +29 -0
  71. vendor/skyverge/wc-plugin-framework/woocommerce/rest-api/class-sv-wc-plugin-rest-api.php +157 -0
  72. vendor/skyverge/wc-plugin-framework/woocommerce/utilities/class-sv-wp-async-request.php +192 -0
  73. vendor/skyverge/wc-plugin-framework/woocommerce/utilities/class-sv-wp-background-job-handler.php +1121 -0
  74. vendor/skyverge/wc-plugin-framework/woocommerce/utilities/class-sv-wp-job-batch-handler.php +310 -0
assets/css/admin/facebook-for-woocommerce-products-admin.css ADDED
@@ -0,0 +1,37 @@
1
+ /* added #woocommerce-product-data to increase selector specificity */
2
+ #woocommerce-product-data .fb-product-image-source-field .wc-radios li {
3
+ margin-bottom: 0;
4
+ }
5
+ #woocommerce-product-data .fb-product-image-source-field .wc-radios li:last-child {
6
+ padding-bottom: 0;
7
+ }
8
+
9
+ /* add padding-top for first radio button in variation fields */
10
+ #woocommerce-product-data .woocommerce_variation .fb-product-image-source-field .wc-radios li:first-child {
11
+ padding-top: 10px;
12
+ }
13
+
14
+ .woocommerce_variation .fb-sync-enabled-field .checkbox {
15
+ margin-top: 2px !important;
16
+ margin-right: 5px !important;
17
+ }
18
+
19
+ .woocommerce_variation .fb-product-image-source-field {
20
+ margin: 1em 0;
21
+ }
22
+
23
+ .woocommerce_variation .fb-product-image-source-field legend {
24
+ float: left;
25
+ padding-inline-start: 0;
26
+ padding-inline-end: 0;
27
+ }
28
+
29
+ .woocommerce_variation .fb-product-image-source-field .woocommerce-help-tip {
30
+ float: left;
31
+ margin-left: 4px;
32
+ vertical-align: top;
33
+ }
34
+
35
+ .woocommerce_variation .fb-product-image-source-field .wc-radios {
36
+ clear: both;
37
+ }
assets/css/facebook.css CHANGED
@@ -272,3 +272,39 @@
272
font-size: 12px;
273
height: 18px;
274
}
272
font-size: 12px;
273
height: 18px;
274
}
275
+
276
+ #sync_progress {
277
+ font-size: 0.9em;
278
+ font-weight: normal;
279
+ margin-left: 10px;
280
+ }
281
+
282
+ #sync_progress .spinner {
283
+ float: none;
284
+ margin-top: 0;
285
+ }
286
+
287
+ /* hide Save changes button if integration settings are hidden */
288
+ #integration-settings[style="display: none"] + p.submit {
289
+ display: none;
290
+ }
291
+
292
+ #integration-settings .resync-schedule-fieldset {
293
+ display: inline-block;
294
+ vertical-align: middle !important;
295
+ }
296
+
297
+ #integration-settings .resync-schedule-fieldset input {
298
+ vertical-align: middle !important;
299
+ }
300
+
301
+ #integration-settings .resync-schedule-fieldset input[type="number"] {
302
+ max-width: 50px;
303
+ margin: 5px;
304
+ }
305
+
306
+ #integration-settings .resync-schedule-fieldset select {
307
+ max-width: 75px !important;
308
+ vertical-align: middle !important;
309
+ line-height: 28px !important;
310
+ }
assets/js/admin/facebook-for-woocommerce-products-admin.js ADDED
@@ -0,0 +1,264 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+ *
4
+ * This source code is licensed under the license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @package FacebookCommerce
8
+ */
9
+
10
+ jQuery( document ).ready( function( $ ) {
11
+
12
+ const pagenow = window.pagenow.length ? window.pagenow : '',
13
+ typenow = window.typenow.length ? window.typenow : '';
14
+
15
+
16
+ // products list edit screen
17
+ if ( 'edit-product' === pagenow ) {
18
+
19
+
20
+ let visibilityToggles = $( '.facebook-for-woocommerce-product-visibility-toggle' );
21
+
22
+ // init visibility toggles tooltips
23
+ visibilityToggles.tipTip( {
24
+ attribute: 'title',
25
+ edgeOffset: 5,
26
+ fadeIn: 50,
27
+ fadeOut: 50,
28
+ delay: 200
29
+ } );
30
+
31
+ // handle FB Catalog Visibility buttons
32
+ visibilityToggles.on( 'click', function( e ) {
33
+ e.preventDefault();
34
+
35
+ let action = $( this ).data( 'action' ),
36
+ visibility = 'show' === action ? 'yes' : 'no',
37
+ productID = parseInt( $( this ).data( 'product-id' ), 10 );
38
+
39
+ if ( 'show' === action ) {
40
+ $( this ).hide().next( 'button' ).show();
41
+ } else if ( 'hide' === action ) {
42
+ $( this ).hide().prev( 'button' ).show();
43
+ }
44
+
45
+ $.post( facebook_for_woocommerce_products_admin.ajax_url, {
46
+ action: 'facebook_for_woocommerce_set_products_visibility',
47
+ security: facebook_for_woocommerce_products_admin.set_product_visibility_nonce,
48
+ products: [
49
+ {
50
+ product_id: productID,
51
+ visibility: visibility
52
+ }
53
+ ]
54
+ } );
55
+ } );
56
+
57
+
58
+ // handle bulk actions
59
+ let submitProductBulkAction = false;
60
+
61
+ $( 'input#doaction, input#doaction2' ).on( 'click', function( e ) {
62
+
63
+ if ( ! submitProductBulkAction ) {
64
+ e.preventDefault();
65
+ } else {
66
+ return true;
67
+ }
68
+
69
+ let $submitButton = $( this ),
70
+ chosenBulkAction = $submitButton.prev( 'select' ).val();
71
+
72
+ if ( 'facebook_exclude' === chosenBulkAction || 'facebook_include' === chosenBulkAction ) {
73
+
74
+ let products = [];
75
+
76
+ $.each( $( 'input[name="post[]"]:checked' ), function() {
77
+ products.push( parseInt( $( this ).val(), 10 ) );
78
+ } );
79
+
80
+ $.post( facebook_for_woocommerce_products_admin.ajax_url, {
81
+ action: 'facebook_for_woocommerce_set_product_sync_bulk_action_prompt',
82
+ security: facebook_for_woocommerce_products_admin.set_product_sync_bulk_action_prompt_nonce,
83
+ toggle: chosenBulkAction,
84
+ products: products
85
+ }, function( response ) {
86
+
87
+ if ( response && ! response.success ) {
88
+
89
+ // close existing modals
90
+ $( '#wc-backbone-modal-dialog .modal-close' ).trigger( 'click' );
91
+
92
+ // open new modal, populate template with AJAX response data
93
+ new $.WCBackboneModal.View( {
94
+ target: 'facebook-for-woocommerce-modal',
95
+ string: response.data
96
+ } );
97
+
98
+ // exclude from sync: offer to handle product visibility
99
+ $( '.facebook-for-woocommerce-toggle-product-visibility' ).on( 'click', function( e) {
100
+
101
+ blockModal();
102
+
103
+ if ( $( this ).hasClass( 'hide-products' ) ) {
104
+
105
+ $.each( products, function() {
106
+
107
+ let $toggle = $( '#post-' + this ).find( 'td.facebook_catalog_visibility button.facebook-for-woocommerce-product-visibility-hide' );
108
+
109
+ if ( $toggle.is( ':visible' ) ) {
110
+ $toggle.trigger( 'click' );
111
+ }
112
+ } );
113
+ }
114
+
115
+ // submit form after modal prompt action
116
+ submitProductBulkAction = true;
117
+ $submitButton.trigger( 'click' );
118
+ } );
119
+
120
+ } else {
121
+
122
+ // no modal displayed: submit form as normal
123
+ submitProductBulkAction = true;
124
+ $submitButton.trigger( 'click' );
125
+ }
126
+ } );
127
+
128
+ } else {
129
+
130
+ // no modal displayed: submit form as normal
131
+ submitProductBulkAction = true;
132
+ $submitButton.trigger( 'click' );
133
+ }
134
+ } );
135
+ }
136
+
137
+
138
+ // individual product edit screen
139
+ if ( 'product' === pagenow ) {
140
+
141
+ /**
142
+ * Toggles (enables/disables) Facebook setting fields.
143
+ *
144
+ * @since 1.10.0
145
+ *
146
+ * @param {boolean} enabled whether the settings fields should be enabled or not
147
+ * @param {jQuery} $container a common ancestor of all the elements that can be enabled/disabled
148
+ */
149
+ function toggleFacebookSettings( enabled, $container ) {
150
+
151
+ $container.find( '.enable-if-sync-enabled' ).prop( 'disabled', ! enabled );
152
+ }
153
+
154
+
155
+ // toggle Facebook settings fields for simple products
156
+ const syncEnabledCheckbox = $( '#fb_sync_enabled' );
157
+ const facebookSettingsPanel = syncEnabledCheckbox.closest( '.woocommerce_options_panel' );
158
+
159
+ syncEnabledCheckbox.on( 'click', function() {
160
+ toggleFacebookSettings( $( this ).prop( 'checked' ), facebookSettingsPanel );
161
+ } );
162
+
163
+ toggleFacebookSettings( syncEnabledCheckbox.prop( 'checked' ), facebookSettingsPanel );
164
+
165
+ // toggle Facebook settings fields for variations
166
+ $( '.woocommerce_variations' ).on( 'change', '.js-variable-fb-sync-toggle', function() {
167
+ toggleFacebookSettings( $( this ).prop( 'checked' ), $( this ).closest( '.wc-metabox-content' ) );
168
+ } );
169
+
170
+ // show/hide Custom Image URL setting
171
+ $( '#woocommerce-product-data' ).on( 'change', '.js-fb-product-image-source', function() {
172
+
173
+ let $container = $( this ).closest( '.woocommerce_options_panel, .wc-metabox-content' );
174
+ let imageSource = $( this ).val();
175
+
176
+ $container.find( '.product-image-source-field' ).closest( '.form-field' ).hide();
177
+ $container.find( `.show-if-product-image-source-${imageSource}` ).closest( '.form-field' ).show();
178
+ } );
179
+
180
+ $( '.js-fb-product-image-source:checked' ).trigger( 'change' );
181
+
182
+ // trigger settings fields modifiers when variations are loaded
183
+ $( '#woocommerce-product-data' ).on( 'woocommerce_variations_loaded', function() {
184
+ $( '.js-variable-fb-sync-toggle' ).trigger( 'change' );
185
+ $( '.js-fb-product-image-source:checked' ).trigger( 'change' );
186
+ } );
187
+
188
+ let submitProductSave = false;
189
+
190
+ $( 'form#post input[type="submit"]' ).on( 'click', function( e ) {
191
+
192
+ if ( ! submitProductSave ) {
193
+ e.preventDefault();
194
+ } else {
195
+ return true;
196
+ }
197
+
198
+ let $submitButton = $( this ),
199
+ $visibleCheckbox = $( 'input[name="fb_visibility"]' ),
200
+ productID = parseInt( $( 'input#post_ID' ).val(), 10 ),
201
+ productCat = [],
202
+ productTag = $( 'textarea[name="tax_input[product_tag]"]' ).val().split( ',' ),
203
+ syncEnabled = $( 'input#fb_sync_enabled' ).prop( 'checked' );
204
+
205
+ $( '#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked' ).each( function() {
206
+ productCat.push( parseInt( $( this ).val(), 10 ) );
207
+ } );
208
+
209
+ if ( productID > 0 ) {
210
+
211
+ $.post( facebook_for_woocommerce_products_admin.ajax_url, {
212
+ action: 'facebook_for_woocommerce_set_product_sync_prompt',
213
+ security: facebook_for_woocommerce_products_admin.set_product_sync_prompt_nonce,
214
+ sync_enabled: syncEnabled ? 'enabled' : 'disabled',
215
+ product: productID,
216
+ categories: productCat,
217
+ tags: productTag
218
+ }, function( response ) {
219
+
220
+ // open modal if visibility checkbox is checked or if there are conflicting terms set for sync exclusion
221
+ if ( response && ! response.success && ( syncEnabled || ( ! syncEnabled && $visibleCheckbox.length && $visibleCheckbox.is( ':checked' ) ) ) ) {
222
+
223
+ // close existing modals
224
+ $( '#wc-backbone-modal-dialog .modal-close' ).trigger( 'click' );
225
+
226
+ // open new modal, populate template with AJAX response data
227
+ new $.WCBackboneModal.View( {
228
+ target: 'facebook-for-woocommerce-modal',
229
+ string: response.data
230
+ } );
231
+
232
+ // exclude from sync: offer to handle product visibility
233
+ $( '.facebook-for-woocommerce-toggle-product-visibility' ).on( 'click', function( e) {
234
+
235
+ blockModal();
236
+
237
+ if ( $( this ).hasClass( 'hide-products' ) ) {
238
+ $visibleCheckbox.prop( 'checked', false );
239
+ }
240
+
241
+ // no modal displayed: submit form as normal
242
+ submitProductSave = true;
243
+ $submitButton.trigger( 'click' );
244
+ } );
245
+
246
+ } else {
247
+
248
+ // no modal displayed: submit form as normal
249
+ submitProductSave = true;
250
+ $submitButton.trigger( 'click' );
251
+ }
252
+ } );
253
+
254
+ } else {
255
+
256
+ // no modal displayed: submit form as normal
257
+ submitProductSave = true;
258
+ $submitButton.trigger( 'click' );
259
+ }
260
+
261
+ } );
262
+ }
263
+
264
+ } );
assets/js/admin/facebook-for-woocommerce-products-admin.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";jQuery(document).ready(function(n){var o=window.pagenow.length?window.pagenow:"";window.typenow.length&&window.typenow;if("edit-product"===o){var e=n(".facebook-for-woocommerce-product-visibility-toggle");e.tipTip({attribute:"title",edgeOffset:5,fadeIn:50,fadeOut:50,delay:200}),e.on("click",function(o){o.preventDefault();var e=n(this).data("action"),c="show"===e?"yes":"no",t=parseInt(n(this).data("product-id"),10);"show"===e?n(this).hide().next("button").show():"hide"===e&&n(this).hide().prev("button").show(),n.post(facebook_for_woocommerce_products_admin.ajax_url,{action:"facebook_for_woocommerce_set_products_visibility",security:facebook_for_woocommerce_products_admin.set_product_visibility_nonce,products:[{product_id:t,visibility:c}]})});var i=!1;n("input#doaction, input#doaction2").on("click",function(o){if(i)return!0;o.preventDefault();var e=n(this),c=e.prev("select").val();if("facebook_exclude"===c||"facebook_include"===c){var t=[];n.each(n('input[name="post[]"]:checked'),function(){t.push(parseInt(n(this).val(),10))}),n.post(facebook_for_woocommerce_products_admin.ajax_url,{action:"facebook_for_woocommerce_set_product_sync_bulk_action_prompt",security:facebook_for_woocommerce_products_admin.set_product_sync_bulk_action_prompt_nonce,toggle:c,products:t},function(o){o&&!o.success?(n("#wc-backbone-modal-dialog .modal-close").trigger("click"),new n.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:o.data}),n(".facebook-for-woocommerce-toggle-product-visibility").on("click",function(o){blockModal(),n(this).hasClass("hide-products")&&n.each(t,function(){var o=n("#post-"+this).find("td.facebook_catalog_visibility button.facebook-for-woocommerce-product-visibility-hide");o.is(":visible")&&o.trigger("click")}),i=!0,e.trigger("click")})):(i=!0,e.trigger("click"))})}else i=!0,e.trigger("click")})}if("product"===o){var c=function(o,e){e.find(".enable-if-sync-enabled").prop("disabled",!o)},t=n("#fb_sync_enabled"),r=t.closest(".woocommerce_options_panel");t.on("click",function(){c(n(this).prop("checked"),r)}),c(t.prop("checked"),r),n(".woocommerce_variations").on("change",".js-variable-fb-sync-toggle",function(){c(n(this).prop("checked"),n(this).closest(".wc-metabox-content"))}),n("#woocommerce-product-data").on("change",".js-fb-product-image-source",function(){var o=n(this).closest(".woocommerce_options_panel, .wc-metabox-content"),e=n(this).val();o.find(".product-image-source-field").closest(".form-field").hide(),o.find(".show-if-product-image-source-"+e).closest(".form-field").show()}),n(".js-fb-product-image-source:checked").trigger("change"),n("#woocommerce-product-data").on("woocommerce_variations_loaded",function(){n(".js-variable-fb-sync-toggle").trigger("change"),n(".js-fb-product-image-source:checked").trigger("change")});var s=!1;n('form#post input[type="submit"]').on("click",function(o){if(s)return!0;o.preventDefault();var e=n(this),c=n('input[name="fb_visibility"]'),t=parseInt(n("input#post_ID").val(),10),i=[],r=n('textarea[name="tax_input[product_tag]"]').val().split(","),a=n("input#fb_sync_enabled").prop("checked");n('#taxonomy-product_cat input[name="tax_input[product_cat][]"]:checked').each(function(){i.push(parseInt(n(this).val(),10))}),0<t?n.post(facebook_for_woocommerce_products_admin.ajax_url,{action:"facebook_for_woocommerce_set_product_sync_prompt",security:facebook_for_woocommerce_products_admin.set_product_sync_prompt_nonce,sync_enabled:a?"enabled":"disabled",product:t,categories:i,tags:r},function(o){o&&!o.success&&(a||!a&&c.length&&c.is(":checked"))?(n("#wc-backbone-modal-dialog .modal-close").trigger("click"),new n.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:o.data}),n(".facebook-for-woocommerce-toggle-product-visibility").on("click",function(o){blockModal(),n(this).hasClass("hide-products")&&c.prop("checked",!1),s=!0,e.trigger("click")})):(s=!0,e.trigger("click"))}):(s=!0,e.trigger("click"))})}});
assets/js/admin/facebook-for-woocommerce-settings-sync.js ADDED
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+ *
4
+ * This source code is licensed under the license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @package FacebookCommerce
8
+ */
9
+
10
+ jQuery( document ).ready( function( $ ) {
11
+
12
+
13
+ // run script only on Facebook Settings page
14
+ if ( 'woocommerce_page_wc-settings' === window.pagenow.length ? window.pagenow : '' ) {
15
+ return;
16
+ }
17
+
18
+
19
+ /**
20
+ * Gets any new excluded categories being added.
21
+ *
22
+ * @return {string[]}
23
+ */
24
+ function getExcludedCategoriesAdded() {
25
+
26
+ const newCategoryIDs = $( '#woocommerce_facebookcommerce_fb_sync_exclude_categories' ).val();
27
+ let oldCategoryIDs = [];
28
+
29
+ if ( window.facebookAdsToolboxConfig && window.facebookAdsToolboxConfig.excludedCategoryIDs ) {
30
+ oldCategoryIDs = window.facebookAdsToolboxConfig.excludedCategoryIDs;
31
+ }
32
+
33
+ // return IDs that are in the new value that were not in the saved value
34
+ return $( newCategoryIDs ).not( oldCategoryIDs ).get();
35
+ }
36
+
37
+
38
+ /**
39
+ * Gets any new excluded tags being added.
40
+ *
41
+ * @return {string[]}
42
+ */
43
+ function getExcludedTagsAdded() {
44
+
45
+ const newTagIDs = $( '#woocommerce_facebookcommerce_fb_sync_exclude_tags' ).val();
46
+ let oldTagIDs = [];
47
+
48
+ if ( window.facebookAdsToolboxConfig && window.facebookAdsToolboxConfig.excludedTagIDs ) {
49
+ oldTagIDs = window.facebookAdsToolboxConfig.excludedTagIDs;
50
+ }
51
+
52
+ // return IDs that are in the new value that were not in the saved value
53
+ return $( newTagIDs ).not( oldTagIDs ).get();
54
+ }
55
+
56
+
57
+ /**
58
+ * Toggles availability of input in setting groups.
59
+ *
60
+ * @param {Object[]} $elements group of jQuery elements (fields or buttons) to toggle
61
+ * @param {boolean} enable whether fields in this group should be enabled or not
62
+ */
63
+ function toggleSettingOptions( $elements, enable ) {
64
+
65
+ $( $elements ).each( function() {
66
+
67
+ let $element = $( this );
68
+
69
+ if ( $( this ).hasClass( 'wc-enhanced-select' ) ) {
70
+ $element = $( this ).next( 'span.select2-container' );
71
+ }
72
+
73
+ if ( enable ) {
74
+ $element.css( 'pointer-events', 'all' ).css( 'opacity', '1.0' );
75
+ } else {
76
+ $element.css( 'pointer-events', 'none' ).css( 'opacity', '0.4' );
77
+ }
78
+ } );
79
+ }
80
+
81
+
82
+ // toggle availability of options withing field groups
83
+ $( 'input[type="checkbox"].toggle-fields-group' ).on( 'change', function ( e ) {
84
+ if ( $( this ).hasClass( 'product-sync-field' ) ) {
85
+ toggleSettingOptions( $( '.product-sync-field' ).not( '.toggle-fields-group' ), $( this ).is( ':checked' ) );
86
+ } else if ( $( this ).hasClass( 'messenger-field' ) ) {
87
+ toggleSettingOptions( $( '.messenger-field' ).not( '.toggle-fields-group' ), $( this ).is( ':checked' ) );
88
+ } else if ( $( this ).hasClass( 'resync-schedule-field' ) ) {
89
+ toggleSettingOptions( $( '.resync-schedule-field' ).not( '.toggle-fields-group' ), $( this ).is( ':checked' ) );
90
+ }
91
+ } ).trigger( 'change' );
92
+
93
+
94
+ // adds a leading zero to time picker fields
95
+ $( '#woocommerce_facebookcommerce_scheduled_resync_hours, #woocommerce_facebookcommerce_scheduled_resync_minutes' ).on( 'input change keyup keydown keypress click', function() {
96
+
97
+ let value = $( this ).val();
98
+
99
+ if ( ! isNaN( value ) && 1 === value.length && value < 10 ) {
100
+ $( this ).val( value.padStart( 2, '0' ) );
101
+ }
102
+
103
+ } ).trigger( 'change' );
104
+
105
+
106
+ // adds a character counter on the Messenger greeting textarea
107
+ $( 'textarea#woocommerce_facebookcommerce_messenger_greeting' ).on( 'focus change keyup keydown keypress', function() {
108
+
109
+ const maxChars = parseInt( window.facebookAdsToolboxConfig.messengerGreetingMaxCharacters, 10 );
110
+ let chars = $( this ).val().length,
111
+ $counter = $( 'span.characters-counter' ),
112
+ $warning = $counter.find( 'span' );
113
+
114
+ $counter.html( chars + ' / ' + maxChars + '<br/>' ).append( $warning ).css( 'display', 'block' );
115
+
116
+ if ( chars > maxChars ) {
117
+ $counter.css( 'color', '#DC3232' ).find( 'span' ).show();
118
+ } else {
119
+ $counter.css( 'color', '#999999' ).find( 'span' ).hide();
120
+ }
121
+ } );
122
+
123
+
124
+ let submitSettingsSave = false;
125
+
126
+ $( '.woocommerce-save-button' ).on( 'click', function ( e ) {
127
+
128
+ if ( ! submitSettingsSave ) {
129
+ e.preventDefault();
130
+ } else {
131
+ return true;
132
+ }
133
+
134
+ const $submitButton = $( this ),
135
+ categoriesAdded = getExcludedCategoriesAdded(),
136
+ tagsAdded = getExcludedTagsAdded();
137
+
138
+
139
+ if ( categoriesAdded.length > 0 || tagsAdded.length > 0 ) {
140
+
141
+ $.post( facebook_for_woocommerce_settings_sync.ajax_url, {
142
+ action: 'facebook_for_woocommerce_set_excluded_terms_prompt',
143
+ security: facebook_for_woocommerce_settings_sync.set_excluded_terms_prompt_nonce,
144
+ categories: categoriesAdded,
145
+ tags: tagsAdded,
146
+ }, function ( response ) {
147
+
148
+ if ( response && ! response.success ) {
149
+
150
+ // close existing modals
151
+ $( '#wc-backbone-modal-dialog .modal-close' ).trigger( 'click' );
152
+
153
+ // open new modal, populate template with AJAX response data
154
+ new $.WCBackboneModal.View( {
155
+ target: 'facebook-for-woocommerce-modal',
156
+ string: response.data,
157
+ } );
158
+
159
+ // exclude products: submit form as normal
160
+ $( '#facebook-for-woocommerce-confirm-settings-change' ).on( 'click', function () {
161
+
162
+ blockModal();
163
+
164
+ submitSettingsSave = true;
165
+ $submitButton.trigger( 'click' );
166
+ } );
167
+
168
+ } else {
169
+
170
+ // no modal displayed: submit form as normal
171
+ submitSettingsSave = true;
172
+ $submitButton.trigger( 'click' );
173
+ }
174
+ } );
175
+
176
+ } else {
177
+
178
+ // no terms added: submit form as normal
179
+ submitSettingsSave = true;
180
+ $submitButton.trigger( 'click' );
181
+ }
182
+ } );
183
+
184
+ } );
assets/js/admin/facebook-for-woocommerce-settings-sync.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";jQuery(document).ready(function(r){if("woocommerce_page_wc-settings"!==window.pagenow.length||!window.pagenow){r('input[type="checkbox"].toggle-fields-group').on("change",function(e){r(this).hasClass("product-sync-field")?o(r(".product-sync-field").not(".toggle-fields-group"),r(this).is(":checked")):r(this).hasClass("messenger-field")?o(r(".messenger-field").not(".toggle-fields-group"),r(this).is(":checked")):r(this).hasClass("resync-schedule-field")&&o(r(".resync-schedule-field").not(".toggle-fields-group"),r(this).is(":checked"))}).trigger("change"),r("#woocommerce_facebookcommerce_scheduled_resync_hours, #woocommerce_facebookcommerce_scheduled_resync_minutes").on("input change keyup keydown keypress click",function(){var e=r(this).val();!isNaN(e)&&1===e.length&&e<10&&r(this).val(e.padStart(2,"0"))}).trigger("change"),r("textarea#woocommerce_facebookcommerce_messenger_greeting").on("focus change keyup keydown keypress",function(){var e=parseInt(window.facebookAdsToolboxConfig.messengerGreetingMaxCharacters,10),o=r(this).val().length,c=r("span.characters-counter"),s=c.find("span");c.html(o+" / "+e+"<br/>").append(s).css("display","block"),e<o?c.css("color","#DC3232").find("span").show():c.css("color","#999999").find("span").hide()});var l=!1;r(".woocommerce-save-button").on("click",function(e){if(l)return!0;e.preventDefault();var o,c,s,n,t=r(this),i=(s=r("#woocommerce_facebookcommerce_fb_sync_exclude_categories").val(),n=[],window.facebookAdsToolboxConfig&&window.facebookAdsToolboxConfig.excludedCategoryIDs&&(n=window.facebookAdsToolboxConfig.excludedCategoryIDs),r(s).not(n).get()),a=(o=r("#woocommerce_facebookcommerce_fb_sync_exclude_tags").val(),c=[],window.facebookAdsToolboxConfig&&window.facebookAdsToolboxConfig.excludedTagIDs&&(c=window.facebookAdsToolboxConfig.excludedTagIDs),r(o).not(c).get());0<i.length||0<a.length?r.post(facebook_for_woocommerce_settings_sync.ajax_url,{action:"facebook_for_woocommerce_set_excluded_terms_prompt",security:facebook_for_woocommerce_settings_sync.set_excluded_terms_prompt_nonce,categories:i,tags:a},function(e){e&&!e.success?(r("#wc-backbone-modal-dialog .modal-close").trigger("click"),new r.WCBackboneModal.View({target:"facebook-for-woocommerce-modal",string:e.data}),r("#facebook-for-woocommerce-confirm-settings-change").on("click",function(){blockModal(),l=!0,t.trigger("click")})):(l=!0,t.trigger("click"))}):(l=!0,t.trigger("click"))})}function o(e,o){r(e).each(function(){var e=r(this);r(this).hasClass("wc-enhanced-select")&&(e=r(this).next("span.select2-container")),o?e.css("pointer-events","all").css("opacity","1.0"):e.css("pointer-events","none").css("opacity","0.4")})}});
assets/js/facebook-for-woocommerce-modal.js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+ *
4
+ * This source code is licensed under the license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @package FacebookCommerce
8
+ */
9
+
10
+ $ = jQuery;
11
+
12
+ /**
13
+ * Determines if the current modal is blocked.
14
+ *
15
+ * @returns {boolean}
16
+ */
17
+ function isModalBlocked() {
18
+ let $modal = $( '.wc-backbone-modal-content' );
19
+ return $modal.is( '.processing') || $modal.parents( '.processing' ).length;
20
+ }
21
+
22
+
23
+ /**
24
+ * Blocks the current modal.
25
+ */
26
+ function blockModal() {
27
+ if ( ! isModalBlocked() ) {
28
+ return $( '.wc-backbone-modal-content' ).addClass( 'processing' ).block( {
29
+ message: null,
30
+ overlayCSS: {
31
+ background: '#fff',
32
+ opacity: 0.6
33
+ }
34
+ } );
35
+ }
36
+ }
37
+
38
+
39
+ /**
40
+ * Unblocks the current modal.
41
+ */
42
+ function unBlockModal() {
43
+ $( '.wc-backbone-modal-content' ).removeClass( 'processing' ).unblock();
44
+ }
assets/js/facebook-for-woocommerce-modal.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";function isModalBlocked(){var o=$(".wc-backbone-modal-content");return o.is(".processing")||o.parents(".processing").length}function blockModal(){if(!isModalBlocked())return $(".wc-backbone-modal-content").addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}function unBlockModal(){$(".wc-backbone-modal-content").removeClass("processing").unblock()}$=jQuery;
assets/js/facebook-infobanner.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";function ajax(n){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,t=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,_=Object.assign({},{action:n},o);jQuery.post(ajaxurl,_,function(n){a&&a(n)}).fail(function(n){t&&t(n)})}function fb_woo_infobanner_post_click(){return console.log("Woo infobanner post tip click!"),ajax("ajax_woo_infobanner_post_click",{_ajax_nonce:wc_facebook_infobanner_jsx.nonce})}function fb_woo_infobanner_post_xout(){return console.log("Woo infobanner post tip xout!"),ajax("ajax_woo_infobanner_post_xout",{_ajax_nonce:wc_facebook_infobanner_jsx.nonce})}
assets/js/facebook-metabox.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";function ajax(e){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,a=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,n=Object.assign({},{action:e},o);jQuery.post(ajaxurl,n,function(e){t&&t(e)}).fail(function(e){a&&a(e)})}function fb_reset_product(e){if(confirm("Resetting Facebook metadata will not remove this product from your shop. If you have duplicated another product and are trying to publish a new Facebook product, click OK to proceed. Otherwise, Facebook metadata will be restored when this product is updated again.")){var o=document.querySelector("#fb_metadata");return o&&(o.innerHTML="<b>This product is not yet synced to Facebook.</b>"),ajax("ajax_reset_single_fb_product",{wp_id:e,_ajax_nonce:wc_facebook_metabox_jsx.nonce})}}function fb_delete_product(e){if(confirm('Are you sure you want to delete this product on Facebook? If you only want to "hide" the product, uncheck the "Visible" checkbox and hit "Update". If you delete a product on Facebook and hit "Update" after, this product will be recreated. To permanently remove this product from Facebook, hit "OK" and close the window.This will not delete the product from WooCommerce.')){var o=document.querySelector("#fb_metadata");return o&&(o.innerHTML="<b>This product is not yet synced to Facebook.</b>"),ajax("ajax_delete_fb_product",{wp_id:e,_ajax_nonce:wc_facebook_metabox_jsx.nonce})}}
assets/js/facebook-products.js DELETED
@@ -1,84 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
- *
4
- * This source code is licensed under the license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- * @package FacebookCommerce
8
- */
9
-
10
- /*
11
- * Ajax helper function.
12
- * Takes optional payload for POST and optional callback.
13
- */
14
- function ajax(action, payload = null, cb = null, failcb = null) {
15
- var data = Object.assign( {},
16
- {
17
- 'action': action,
18
- }, payload
19
- );
20
-
21
- // Since Wordpress 2.8 ajaxurl is always defined in admin header and
22
- // points to admin-ajax.php
23
- jQuery.post(
24
- ajaxurl,
25
- data,
26
- function(response) {
27
- if (cb) {
28
- cb( response );
29
- }
30
- }
31
- ).fail(
32
- function(errorResponse){
33
- if (failcb) {
34
- failcb( errorResponse );
35
- }
36
- }
37
- );
38
- }
39
-
40
- function fb_toggle_visibility(wp_id, published) {
41
- var buttonId = document.querySelector( "#viz_" + wp_id );
42
- var tooltip = document.querySelector( "#tip_" + wp_id );
43
-
44
- if (published) {
45
- tooltip.setAttribute(
46
- 'data-tip',
47
- 'Product is synced and published (visible) on Facebook.'
48
- );
49
- buttonId.setAttribute( 'onclick','fb_toggle_visibility(' + wp_id + ', false)' );
50
- buttonId.innerHTML = 'Hide';
51
- buttonId.setAttribute( 'class', 'button' );
52
- } else {
53
- tooltip.setAttribute(
54
- 'data-tip',
55
- 'Product is synced but not marked as published (visible) on Facebook.'
56
- );
57
- buttonId.setAttribute( 'onclick','fb_toggle_visibility(' + wp_id + ', true)' );
58
- buttonId.innerHTML = 'Show';
59
- buttonId.setAttribute( 'class', 'button button-primary button-large' );
60
- }
61
-
62
- // Reset tooltip
63
- jQuery(
64
- function($) {
65
- $( '.tips' ).tipTip(
66
- {
67
- 'attribute': 'data-tip',
68
- 'fadeIn': 50,
69
- 'fadeOut': 50,
70
- 'delay': 200
71
- }
72
- );
73
- }
74
- );
75
-
76
- return ajax(
77
- 'ajax_fb_toggle_visibility',
78
- {
79
- 'wp_id': wp_id,
80
- 'published': published,
81
- "_ajax_nonce": wc_facebook_product_jsx.nonce
82
- }
83
- );
84
- }
assets/js/facebook-settings.js CHANGED
@@ -59,25 +59,40 @@ function prepend_protocol(url) {
59
return url;
60
}
61
62
- function get_product_catalog_id_box() {
63
- return document.querySelector( '#woocommerce_facebookcommerce_fb_product_catalog_id' ) || null;
64
- }
65
function get_pixel_id_box() {
66
- return document.querySelector( '#woocommerce_facebookcommerce_fb_pixel_id' ) || null;
67
}
68
function get_pixel_use_pii_id_box() {
69
- return document.querySelector( '#woocommerce_facebookcommerce_fb_pixel_use_pii' ) || null;
70
- }
71
- function get_api_key_box() {
72
- return document.querySelector( '#woocommerce_facebookcommerce_fb_api_key' ) || null;
73
}
74
function get_page_id_box() {
75
- return document.querySelector( '#woocommerce_facebookcommerce_fb_page_id' ) || null;
76
- }
77
- function get_ems_id_box() {
78
- return document.querySelector( '#woocommerce_facebookcommerce_fb_external_merchant_settings_id' ) || null;
79
}
80
81
/*
82
* Ajax helper function.
83
* Takes optional payload for POST and optional callback.
@@ -142,7 +157,7 @@ function sync_confirm(verbose = null) {
142
break;
143
default:
144
msg = 'Facebook for WooCommerce automatically syncs your products on ' +
145
- 'create/update. Are you sure you want to force product resync? ' +
146
'This will query all published products and may take some time. ' +
147
'You only need to do this if your products are out of sync ' +
148
'or some of your products did not sync.';
@@ -166,13 +181,7 @@ if (window.location.href.includes( "fb_force_resync" )) {
166
}
167
168
function sync_all_products($using_feed = false, $is_test = false) {
169
- if (get_product_catalog_id_box() && ! get_product_catalog_id_box().value) {
170
- return;
171
- }
172
- if (get_api_key_box() && ! get_api_key_box().value) {
173
- return;
174
- }
175
- console.log( 'Syncing all products!' );
176
window.fb_connected = true;
177
sync_in_progress();
178
if ($using_feed) {
@@ -187,6 +196,9 @@ function sync_all_products($using_feed = false, $is_test = false) {
187
},
188
);
189
} else {
190
return ajax(
191
'ajax_sync_all_fb_products',
192
{
@@ -198,31 +210,24 @@ function sync_all_products($using_feed = false, $is_test = false) {
198
199
// Reset all state
200
function delete_all_settings(callback = null, failcallback = null) {
201
- if (get_product_catalog_id_box()) {
202
- get_product_catalog_id_box().value = '';
203
- }
204
if (get_pixel_id_box()) {
205
get_pixel_id_box().value = '';
206
}
207
if (get_pixel_use_pii_id_box()) {
208
get_pixel_use_pii_id_box().checked = false;
209
}
210
- if (get_api_key_box()) {
211
- get_api_key_box().value = '';
212
- }
213
if (get_page_id_box()) {
214
get_page_id_box().value = '';
215
}
216
- if (get_ems_id_box()) {
217
- get_ems_id_box().value = '';
218
- }
219
220
window.facebookAdsToolboxConfig.pixel.pixelId = '';
221
window.facebookAdsToolboxConfig.diaSettingId = '';
222
-
223
- reset_buttons();
224
window.fb_connected = false;
225
226
console.log( 'Deleting all settings and removing all FBIDs!' );
227
return ajax(
228
'ajax_delete_fb_settings',
@@ -308,70 +313,23 @@ function save_settings_and_sync(message) {
308
}
309
}
310
311
- // Reset buttons to brand new setup state
312
- function reset_buttons(){
313
- if (document.querySelector( '#settings' )) {
314
- document.querySelector( '#settings' ).style.display = 'none';
315
- }
316
- if (document.querySelector( '#cta_button' )) {
317
- var cta_element = document.querySelector( '#cta_button' );
318
- cta_element.innerHTML = 'Get Started';
319
- cta_element.style['font-size'] = '13px';
320
- cta_element.style.width = '80px';
321
- cta_element.href = '#';
322
- cta_element.onclick = function() { facebookConfig(); };
323
- }
324
- if (document.querySelector( '#learnmore_button' )) {
325
- document.querySelector( '#learnmore_button' ).style.display = 'none';
326
- }
327
- if (document.querySelector( '#setup_h1' )) {
328
- document.querySelector( '#setup_h1' ).innerHTML =
329
- 'Grow your business on Facebook';
330
- }
331
- if (document.querySelector( '#setup_l1' )) {
332
- document.querySelector( '#setup_l1' ).innerHTML =
333
- 'Easily install a tracking pixel';
334
- }
335
- if (document.querySelector( '#setup_l2' )) {
336
- document.querySelector( '#setup_l2' ).innerHTML =
337
- 'Upload your products and create a shop';
338
- }
339
- if (document.querySelector( '#setup_l3' )) {
340
- document.querySelector( '#setup_l3' ).innerHTML =
341
- 'Create dynamic ads with your products and pixel';
342
- }
343
- }
344
345
- // Remove reset/settings buttons during product sync
346
- function sync_in_progress(){
347
- if (document.querySelector( '#settings' )) {
348
- document.querySelector( '#settings' ).style.display = '';
349
- }
350
- if (document.querySelector( '#connection_status' )) {
351
- document.querySelector( '#connection_status' ).style.display = '';
352
- }
353
- if (document.querySelector( '#sync_complete' )) {
354
- document.querySelector( '#sync_complete' ).style.display = 'none';
355
- }
356
- // Get rid of all the buttons
357
- if (document.querySelector( '#setting_button' )) {
358
- document.querySelector( '#setting_button' ).style['pointer-events'] = 'none';
359
- }
360
- if (document.querySelector( '#resync_products' )) {
361
- document.querySelector( '#resync_products' ).style['pointer-events'] = 'none';
362
- }
363
- if (document.querySelector( '#test_product_sync' )) {
364
- document.querySelector( '#test_product_sync' ).style.display = 'none';
365
- }
366
- // Set a product sync status
367
- if (document.querySelector( '#sync_progress' )) {
368
- document.querySelector( '#sync_progress' ).innerHTML =
369
- 'Syncing... Keep this browser open <br/>' +
370
- 'Until sync is complete<br/>' +
371
- '<div class="loader"></div>';
372
}
373
}
374
375
function sync_not_in_progress(){
376
// Reset to pre-setup state.
377
if (document.querySelector( '#cta_button' )) {
@@ -413,39 +371,28 @@ function sync_not_in_progress(){
413
document.querySelector( '#setup_l3' ).innerHTML =
414
'Get reporting on sales and revenue';
415
}
416
- if (document.querySelector( '#settings' )) {
417
- document.querySelector( '#settings' ).style.display = '';
418
- }
419
- // Enable buttons.
420
- if (document.querySelector( '#setting_button' )) {
421
- document.querySelector( '#setting_button' ).style['pointer-events'] = 'auto';
422
- }
423
- if (document.querySelector( '#resync_products' )) {
424
- document.querySelector( '#resync_products' ).style ['pointer-events'] = 'auto';
425
- }
426
// Remove sync progress.
427
if (document.querySelector( '#sync_progress' )) {
428
document.querySelector( '#sync_progress' ).innerHTML = '';
429
}
430
}
431
432
- function not_connected(){
433
- if (document.querySelector( '#connection_status' )) {
434
- document.querySelector( '#connection_status' ).style.display = 'none';
435
- }
436
437
- if (document.querySelector( '#setting_button' )) {
438
- document.querySelector( '#setting_button' ).style['pointer-events'] = 'auto';
439
- }
440
- if (document.querySelector( '#resync_products' )) {
441
- document.querySelector( '#resync_products' ).style['pointer-events'] = 'none';
442
- }
443
- if (document.querySelector( '#sync_complete' )) {
444
- document.querySelector( '#sync_complete' ).style.display = 'none';
445
- }
446
- if (document.querySelector( '#sync_progress' )) {
447
- document.querySelector( '#sync_progress' ).innerHTML = '';
448
- }
449
}
450
451
function addAnEventListener(obj,evt,func) {
@@ -462,9 +409,6 @@ function setMerchantSettings(message) {
462
window.sendToFacebook( 'fail set merchant settings', message.params );
463
return;
464
}
465
- if (get_ems_id_box()) {
466
- get_ems_id_box().value = message.params.setting_id;
467
- }
468
469
settings.external_merchant_settings_id = message.params.setting_id;
470
@@ -479,9 +423,6 @@ function setCatalog(message) {
479
window.sendToFacebook( 'fail set catalog', message.params );
480
return;
481
}
482
- if (get_api_key_box()) {
483
- get_product_catalog_id_box().value = message.params.catalog_id;
484
- }
485
486
settings.product_catalog_id = message.params.catalog_id;
487
@@ -538,13 +479,6 @@ function setAccessTokenAndPageId(message) {
538
window.sendToFacebook( 'fail set page access token', message.params );
539
return;
540
}
541
- /*
542
- Set page_token here
543
- */
544
-
545
- if (get_api_key_box()) {
546
- get_api_key_box().value = message.params.page_token;
547
- }
548
549
if (get_page_id_box()) {
550
get_page_id_box().value = message.params.page_id;
@@ -555,10 +489,13 @@ function setAccessTokenAndPageId(message) {
555
// Ack token in "save_settings_and_sync" for final ack
556
557
window.facebookAdsToolboxConfig.tokenExpired = false;
558
- if (document.querySelector( '#token_text' )) {
559
- document.querySelector( '#token_text' ).innerHTML =
560
- ` < strong > Your API key has been updated.<br / >
561
- Please refresh the page.< / strong > `;
562
}
563
}
564
@@ -636,11 +573,18 @@ function iFrameListener(event) {
636
case 'gen feed':
637
genFeed();
638
break;
639
case 'set page access token':
640
- // Should be last message received
641
setAccessTokenAndPageId( event.data );
642
save_settings_and_sync( event.data );
643
break;
644
case 'set msger chat':
645
setMsgerChatSetup( event.data.params );
646
save_settings_for_plugin(
@@ -674,19 +618,32 @@ function parseURL(url) {
674
return parser;
675
}
676
677
- // Only do pings for supporting older (pre 1.8) setups.
678
- window.fb_pings =
679
- (window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload) ?
680
- null :
681
- setInterval(
682
- function(){
683
- console.log( "Pinging queue..." );
684
- check_queues();
685
- },
686
- 10000
687
- );
688
689
function ping_feed_status_queue(count = 0) {
690
window.fb_feed_pings = setInterval(
691
function() {
692
console.log( 'Pinging feed uploading queue...' );
@@ -697,16 +654,19 @@ function ping_feed_status_queue(count = 0) {
697
}
698
699
function product_sync_complete(sync_progress_element) {
700
sync_not_in_progress();
701
- if (document.querySelector( '#sync_complete' )) {
702
- document.querySelector( '#sync_complete' ).style.display = '';
703
- }
704
if (sync_progress_element) {
705
sync_progress_element.innerHTML = '';
706
}
707
clearInterval( window.fb_pings );
708
}
709
710
function check_queues() {
711
ajax(
712
'ajax_fb_background_check_queue',
@@ -739,9 +699,7 @@ function check_queues() {
739
var remaining = res.remaining;
740
if ( processing ) {
741
if ( sync_progress_element ) {
742
- sync_progress_element.innerHTML =
743
- '<strong>Progress:</strong> ' + remaining + ' item' +
744
- ( remaining > 1 ? 's' : '' ) + ' remaining.';
745
}
746
if ( remaining === 0 ) {
747
product_sync_complete( sync_progress_element );
@@ -789,7 +747,9 @@ function check_feed_upload_queue(check_num) {
789
function(response) {
790
var sync_progress_element = document.querySelector( '#sync_progress' );
791
var res = parse_response_check_connection( response );
792
clearInterval( window.fb_feed_pings );
793
if (res) {
794
var status = res.status;
795
switch (status) {
@@ -803,15 +763,16 @@ function check_feed_upload_queue(check_num) {
803
break;
804
case 'in progress':
805
if (sync_progress_element) {
806
- sync_progress_element.innerHTML =
807
- 'Syncing... Keep this browser open <br/>' +
808
- 'Until sync is complete<br/>';
809
}
810
ping_feed_status_queue( check_num + 1 );
811
break;
812
default:
813
- sync_progress_element.innerHTML =
814
- '<strong>Something wrong when uploading, please try again.</strong>';
815
window.feed_upload = false;
816
if (window.is_test) {
817
display_test_result();
@@ -947,24 +908,6 @@ function saveAutoSyncSchedule() {
947
);
948
}
949
950
- function onSetDisableSyncOnDevEnvironment() {
951
- var isChecked = document.getElementsByClassName( 'disableOnDevEnvironment' )[0].checked;
952
- ajax(
953
- 'ajax_update_fb_option',
954
- {
955
- "option": "fb_disable_sync_on_dev_environment",
956
- "option_value": isChecked ? 1 : 0,
957
- "_ajax_nonce": wc_facebook_settings_jsx.nonce,
958
- },
959
- null,
960
- function onSetDisableSyncOnDevEnvironmentFailCallback(error) {
961
- document.getElementsByClassName(
962
- 'onSetDisableSyncOnDevEnvironment'
963
- )[0].checked = ! isChecked;
964
- console.log( 'Failed to disable sync on dev environment' );
965
- }
966
- );
967
- }
968
969
function syncShortDescription() {
970
var isChecked = document.getElementsByClassName( 'syncShortDescription' )[0].checked;
@@ -982,3 +925,17 @@ function syncShortDescription() {
982
}
983
);
984
}
59
return url;
60
}
61
62
+
63
+ /**
64
+ * Gets the input Element that holds the value for the Pixel ID setting.
65
+ *
66
+ * @returns {(Element|null)}
67
+ */
68
function get_pixel_id_box() {
69
+
70
+ return document.querySelector( '#woocommerce_facebookcommerce_facebook_pixel_id' );
71
}
72
+
73
+
74
+ /**
75
+ * Gets the input Element that holds the value for the Use Advanced Matching setting.
76
+ *
77
+ * @returns {(Element|null)}
78
+ */
79
function get_pixel_use_pii_id_box() {
80
+
81
+ return document.querySelector( '#woocommerce_facebookcommerce_enable_advanced_matching' );
82
}
83
+
84
+
85
+ /**
86
+ * Gets the input Element that holds the value for the Facebook page setting.
87
+ *
88
+ * @return {(Element|null)}
89
+ */
90
function get_page_id_box() {
91
+
92
+ return document.querySelector( '#woocommerce_facebookcommerce_facebook_page_id' );
93
}
94
95
+
96
/*
97
* Ajax helper function.
98
* Takes optional payload for POST and optional callback.
157
break;
158
default:
159
msg = 'Facebook for WooCommerce automatically syncs your products on ' +
160
+ 'create/update. Are you sure you want to force product resync?\n\n' +
161
'This will query all published products and may take some time. ' +
162
'You only need to do this if your products are out of sync ' +
163
'or some of your products did not sync.';
181
}
182
183
function sync_all_products($using_feed = false, $is_test = false) {
184
+
185
window.fb_connected = true;
186
sync_in_progress();
187
if ($using_feed) {
196
},
197
);
198
} else {
199
+
200
+ check_background_processor_status();
201
+
202
return ajax(
203
'ajax_sync_all_fb_products',
204
{
210
211
// Reset all state
212
function delete_all_settings(callback = null, failcallback = null) {
213
+
214
if (get_pixel_id_box()) {
215
get_pixel_id_box().value = '';
216
}
217
if (get_pixel_use_pii_id_box()) {
218
get_pixel_use_pii_id_box().checked = false;
219
}
220
+
221
if (get_page_id_box()) {
222
get_page_id_box().value = '';
223
}
224
225
window.facebookAdsToolboxConfig.pixel.pixelId = '';
226
window.facebookAdsToolboxConfig.diaSettingId = '';
227
window.fb_connected = false;
228
229
+ not_connected();
230
+
231
console.log( 'Deleting all settings and removing all FBIDs!' );
232
return ajax(
233
'ajax_delete_fb_settings',
313
}
314
}
315
316
317
+ /**
318
+ * Prepares UI for product sync.
319
+ */
320
+ function sync_in_progress() {
321
+
322
+ // temporarily disable Manage connection and Sync products buttons
323
+ jQuery( '#woocommerce-facebook-settings-manage-connection' ).css( 'pointer-events', 'none' );
324
+ jQuery( '#woocommerce-facebook-settings-sync-products' ).css( 'pointer-events', 'none' );
325
+
326
+ // set products sync status
327
+ if ( document.querySelector( '#sync_progress' ) ) {
328
+ document.querySelector( '#sync_progress' ).innerHTML = 'Syncing... Keep this browser open until sync is complete.<span class="spinner is-active"></span>';
329
}
330
}
331
332
+
333
function sync_not_in_progress(){
334
// Reset to pre-setup state.
335
if (document.querySelector( '#cta_button' )) {
371
document.querySelector( '#setup_l3' ).innerHTML =
372
'Get reporting on sales and revenue';
373
}
374
+
375
+ // enable Manage connection and Sync products buttons when sync is complete
376
+ jQuery( '#woocommerce-facebook-settings-manage-connection' ).css( 'pointer-events', 'auto' );
377
+ jQuery( '#woocommerce-facebook-settings-sync-products' ).css( 'pointer-events', 'auto' );
378
+
379
// Remove sync progress.
380
if (document.querySelector( '#sync_progress' )) {
381
document.querySelector( '#sync_progress' ).innerHTML = '';
382
}
383
}
384
385
386
+ /**
387
+ * Shows Facebook fancy box if the store is still not connected to Facebook.
388
+ *
389
+ * Also hides the integration settings fields.
390
+ */
391
+ function not_connected() {
392
+
393
+ jQuery( '#fbsetup' ).show();
394
+ jQuery( '#integration-settings' ).hide();
395
+ jQuery( '.woocommerce-save-button' ).hide();
396
}
397
398
function addAnEventListener(obj,evt,func) {
409
window.sendToFacebook( 'fail set merchant settings', message.params );
410
return;
411
}
412
413
settings.external_merchant_settings_id = message.params.setting_id;
414
423
window.sendToFacebook( 'fail set catalog', message.params );
424
return;
425
}
426
427
settings.product_catalog_id = message.params.catalog_id;
428
479
window.sendToFacebook( 'fail set page access token', message.params );
480
return;
481
}
482
483
if (get_page_id_box()) {
484
get_page_id_box().value = message.params.page_id;
489
// Ack token in "save_settings_and_sync" for final ack
490
491
window.facebookAdsToolboxConfig.tokenExpired = false;
492
+
493
+ if ( document.querySelector( '#connection-message-invalid' ) ) {
494
+ document.querySelector( '#connection-message-invalid' ).style.display = 'none';
495
+ }
496
+
497
+ if ( document.querySelector( '#connection-message-refresh' ) ) {
498
+ document.querySelector( '#connection-message-refresh' ).style.display = 'block';
499
}
500
}
501
573
case 'gen feed':
574
genFeed();
575
break;
576
+
577
case 'set page access token':
578
+ // should be last message received
579
setAccessTokenAndPageId( event.data );
580
save_settings_and_sync( event.data );
581
+
582
+ // hide Facebook fancy box and show integration settings
583
+ jQuery( '#fbsetup' ).hide();
584
+ jQuery( '#integration-settings' ).show();
585
+ jQuery( '.woocommerce-save-button' ).show();
586
break;
587
+
588
case 'set msger chat':
589
setMsgerChatSetup( event.data.params );
590
save_settings_for_plugin(
618
return parser;
619
}
620
621
+
622
+ /**
623
+ * Setups an interval to check the status a product sync being executed in the background.
624
+ *
625
+ * @since 1.10.0
626
+ */
627
+ function check_background_processor_status() {
628
+
629
+ if ( ! window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload ) {
630
+
631
+ // sanity check to remove any running intervals
632
+ clearInterval( window.fb_pings );
633
+
634
+ window.fb_pings = setInterval( function() {
635
+ console.log( "Pinging queue..." );
636
+ check_queues();
637
+ }, 10000 );
638
+ }
639
+ }
640
+
641
642
function ping_feed_status_queue(count = 0) {
643
+
644
+ // sanity check to remove any running intervals
645
+ clearInterval( window.fb_feed_pings );
646
+
647
window.fb_feed_pings = setInterval(
648
function() {
649
console.log( 'Pinging feed uploading queue...' );
654
}
655
656
function product_sync_complete(sync_progress_element) {
657
+
658
sync_not_in_progress();
659
+
660
if (sync_progress_element) {
661
sync_progress_element.innerHTML = '';
662
}
663
clearInterval( window.fb_pings );
664
}
665
666
+
667
+ /**
668
+ * Checks the status a product sync being executed in the background.
669
+ */
670
function check_queues() {
671
ajax(
672
'ajax_fb_background_check_queue',
699
var remaining = res.remaining;
700
if ( processing ) {
701
if ( sync_progress_element ) {
702
+ sync_progress_element.innerHTML = '<strong>Progress:</strong> ' + remaining + ' item' + ( remaining > 1 ? 's' : '' ) + ' remaining.<span class="spinner is-active"></span>';
703
}
704
if ( remaining === 0 ) {
705
product_sync_complete( sync_progress_element );
747
function(response) {
748
var sync_progress_element = document.querySelector( '#sync_progress' );
749
var res = parse_response_check_connection( response );
750
+
751
clearInterval( window.fb_feed_pings );
752
+
753
if (res) {
754
var status = res.status;
755
switch (status) {
763
break;
764
case 'in progress':
765
if (sync_progress_element) {
766
+ sync_progress_element.innerHTML = 'Syncing... Keep this browser open until sync is complete.<span class="spinner is-active"></span>';
767
}
768
ping_feed_status_queue( check_num + 1 );
769
break;
770
+
771
default:
772
+ if ( sync_progress_element ) {
773
+ sync_progress_element.innerHTML = '<strong>Something wrong when uploading, please try again.</strong>';
774
+ }
775
+
776
window.feed_upload = false;
777
if (window.is_test) {
778
display_test_result();
908
);
909
}
910
911
912
function syncShortDescription() {
913
var isChecked = document.getElementsByClassName( 'syncShortDescription' )[0].checked;
925
}
926
);
927
}
928
+
929
+
930
+ jQuery( document ).ready( function( $ ) {
931
+
932
+ // check background processor status in case products are being synced in the background when the page loads
933
+ check_background_processor_status();
934
+
935
+ $( '#woocommerce-facebook-settings-sync-products' ).click( function( event ) {
936
+
937
+ event.preventDefault();
938
+
939
+ sync_confirm();
940
+ } );
941
+ } );
assets/js/facebook-settings.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var fb_sync_no_response_count=0,fb_show_advanced_options=!1;function toggleAdvancedOptions(){var e=document.getElementById("fbAdvancedOptions");fb_show_advanced_options?(e.style.display="none",document.getElementById("fbAdvancedOptionsText").innerHTML="Show Advanced Settings"):(e.style.display="block",document.getElementById("fbAdvancedOptionsText").innerHTML="Hide Advanced Settings"),fb_show_advanced_options=!fb_show_advanced_options}function openPopup(){var e,o=screen.height/2-404,n=screen.width/2-576.5;window.originParam=window.location.protocol+"//"+window.location.host,window.facebookAdsToolboxConfig.popupOrigin.includes("staticxx")&&(window.facebookAdsToolboxConfig.popupOrigin="https://www.facebook.com/"),window.facebookAdsToolboxConfig.popupOrigin=prepend_protocol(window.facebookAdsToolboxConfig.popupOrigin),e=window.facebookAdsToolboxConfig.popupOrigin;var t=window.open(e+"/login.php?display=popup&next="+encodeURIComponent(e+"/ads/dia?origin="+window.originParam+" &merchant_settings_id="+window.facebookAdsToolboxConfig.diaSettingId),"DiaWizard",["toolbar=no","location=no","directories=no","status=no","menubar=no","scrollbars=no","resizable=no","copyhistory=no","width=1153","height=808","top="+o,"left="+n].join(","));return function(e,o){t.postMessage({type:e,params:o},window.facebookAdsToolboxConfig.popupOrigin)}}function prepend_protocol(e){return 0===e.indexOf("//www.")&&(e="https:"+e),e}function get_pixel_id_box(){return document.querySelector("#woocommerce_facebookcommerce_facebook_pixel_id")}function get_pixel_use_pii_id_box(){return document.querySelector("#woocommerce_facebookcommerce_enable_advanced_matching")}function get_page_id_box(){return document.querySelector("#woocommerce_facebookcommerce_facebook_page_id")}function ajax(e){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,t=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null,s=Object.assign({},{action:e},o);jQuery.post(ajaxurl,s,function(e){n&&n(e)}).fail(function(e){t&&t(e)})}var settings={facebook_for_woocommerce:1},pixel_settings={facebook_for_woocommerce:1};function facebookConfig(){window.sendToFacebook=openPopup(),window.diaConfig={clientSetup:window.facebookAdsToolboxConfig}}function fb_flush(){return console.log("Removing all FBIDs from all products!"),ajax("ajax_reset_all_fb_products",{_ajax_nonce:wc_facebook_settings_jsx.nonce},null,function(){console.log("Failed to reset all FB products")})}function sync_confirm(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,o="";switch(e){case"fb_force_resync":o="Your products will now be resynced with Facebook, this may take some time.";break;case"fb_test_product_sync":o="Launch Test?";break;default:o="Facebook for WooCommerce automatically syncs your products on create/update. Are you sure you want to force product resync?\n\nThis will query all published products and may take some time. You only need to do this if your products are out of sync or some of your products did not sync."}confirm(o)&&(sync_all_products(window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload,"fb_test_product_sync"==e),window.fb_sync_start_time=(new Date).getTime())}function sync_all_products(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],o=1<arguments.length&&void 0!==arguments[1]&&arguments[1];return window.fb_connected=!0,sync_in_progress(),e?(window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload=!0,window.feed_upload=!0,ping_feed_status_queue(),o?ajax("ajax_test_sync_products_using_feed"):ajax("ajax_sync_all_fb_products_using_feed",{_ajax_nonce:wc_facebook_settings_jsx.nonce})):(check_background_processor_status(),ajax("ajax_sync_all_fb_products",{_ajax_nonce:wc_facebook_settings_jsx.nonce}))}function delete_all_settings(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;return get_pixel_id_box()&&(get_pixel_id_box().value=""),get_pixel_use_pii_id_box()&&(get_pixel_use_pii_id_box().checked=!1),get_page_id_box()&&(get_page_id_box().value=""),window.facebookAdsToolboxConfig.pixel.pixelId="",window.facebookAdsToolboxConfig.diaSettingId="",window.fb_connected=!1,not_connected(),console.log("Deleting all settings and removing all FBIDs!"),ajax("ajax_delete_fb_settings",{_ajax_nonce:wc_facebook_settings_jsx.nonce},e,o)}function save_settings(){var o=0<arguments.length&&void 0!==arguments[0]?arguments[0]:null,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;(e=e||settings)._ajax_nonce=wc_facebook_settings_jsx.nonce,ajax("ajax_save_fb_settings",e,function(e){o&&o(e)},function(e){n&&n(e)})}function save_settings_for_plugin(o,n){save_settings(function(e){e&&e.includes("settings_saved")?(console.log(e),o(e)):(console.log("Fail response on save_settings_and_sync"),n(e))},function(e){console.log("Ajax error while saving settings:"+JSON.stringify(e)),n(e)})}function save_settings_and_sync(o){"api_key"in settings&&save_settings(function(e){e&&e.includes("settings_saved")?(console.log(e),window.sendToFacebook("ack set pixel",o.params),window.sendToFacebook("ack set page access token",o.params),window.sendToFacebook("ack set merchant settings",o.params),sync_all_products(!0)):(window.sendToFacebook("fail save_settings",e),console.log("Fail response on save_settings_and_sync"))},function(e){console.log("Ajax error while saving settings:"+JSON.stringify(e)),window.sendToFacebook("fail save_settings_ajax",JSON.stringify(e))})}function sync_in_progress(){jQuery("#woocommerce-facebook-settings-manage-connection").css("pointer-events","none"),jQuery("#woocommerce-facebook-settings-sync-products").css("pointer-events","none"),document.querySelector("#sync_progress")&&(document.querySelector("#sync_progress").innerHTML='Syncing... Keep this browser open until sync is complete.<span class="spinner is-active"></span>')}function sync_not_in_progress(){if(document.querySelector("#cta_button")){var e=document.querySelector("#cta_button");e.innerHTML="Create Ad",e.style["font-size"]="12px",e.style.width="60px",window.facebookAdsToolboxConfig.diaSettingId?e.onclick=function(){window.open("https://www.facebook.com/ads/dia/redirect/?settings_id="+window.facebookAdsToolboxConfig.diaSettingId+"&version=2&entry_point=admin_panel")}:e.style["pointer-events"]="none"}if(document.querySelector("#learnmore_button")){var o=document.querySelector("#learnmore_button");window.facebookAdsToolboxConfig.diaSettingId&&(o.style.display="")}document.querySelector("#setup_h1")&&(document.querySelector("#setup_h1").innerHTML="Reach the right people and sell more products"),document.querySelector("#setup_l1")&&(document.querySelector("#setup_l1").innerHTML="Create an ad in a few steps"),document.querySelector("#setup_l2")&&(document.querySelector("#setup_l2").innerHTML="Use built-in best practice for online sales"),document.querySelector("#setup_l3")&&(document.querySelector("#setup_l3").innerHTML="Get reporting on sales and revenue"),jQuery("#woocommerce-facebook-settings-manage-connection").css("pointer-events","auto"),jQuery("#woocommerce-facebook-settings-sync-products").css("pointer-events","auto"),document.querySelector("#sync_progress")&&(document.querySelector("#sync_progress").innerHTML="")}function not_connected(){jQuery("#fbsetup").show(),jQuery("#integration-settings").hide(),jQuery(".woocommerce-save-button").hide()}function addAnEventListener(e,o,n){"addEventListener"in e?e.addEventListener(o,n,!1):"attachEvent"in e&&e.attachEvent("on"+o,n)}function setMerchantSettings(e){if(!e.params.setting_id)return console.error("Facebook Extension Error: got no setting_id",e.params),void window.sendToFacebook("fail set merchant settings",e.params);settings.external_merchant_settings_id=e.params.setting_id,window.facebookAdsToolboxConfig.diaSettingId=e.params.setting_id}function setCatalog(e){if(!e.params.catalog_id)return console.error("Facebook Extension Error: got no catalog_id",e.params),void window.sendToFacebook("fail set catalog",e.params);settings.product_catalog_id=e.params.catalog_id,window.sendToFacebook("ack set catalog",e.params)}function setPixel(o){if(!o.params.pixel_id)return console.error("Facebook Ads Extension Error: got no pixel_id",o.params),void window.sendToFacebook("fail set pixel",o.params);get_pixel_id_box()&&(get_pixel_id_box().value=o.params.pixel_id),settings.pixel_id=o.params.pixel_id,pixel_settings.pixel_id=settings.pixel_id,void 0!==o.params.pixel_use_pii&&(get_pixel_use_pii_id_box()&&(get_pixel_use_pii_id_box().checked=!!o.params.pixel_use_pii),settings.pixel_use_pii=o.params.pixel_use_pii,pixel_settings.pixel_use_pii=settings.pixel_use_pii),save_settings(function(e){e&&e.includes("settings_saved")&&window.sendToFacebook("ack set pixel",o.params)},function(e){console.log(e),window.sendToFacebook("fail set pixel",e)},pixel_settings)}function genFeed(e){}function setAccessTokenAndPageId(e){if(!e.params.page_token)return console.error("Facebook Ads Extension Error: got no page_token",e.params),void window.sendToFacebook("fail set page access token",e.params);get_page_id_box()&&(get_page_id_box().value=e.params.page_id),settings.api_key=e.params.page_token,settings.page_id=e.params.page_id,window.facebookAdsToolboxConfig.tokenExpired=!1,document.querySelector("#connection-message-invalid")&&(document.querySelector("#connection-message-invalid").style.display="none"),document.querySelector("#connection-message-refresh")&&(document.querySelector("#connection-message-refresh").style.display="block")}function setMsgerChatSetup(e){if(e.hasOwnProperty("is_messenger_chat_plugin_enabled")&&(settings.is_messenger_chat_plugin_enabled=e.is_messenger_chat_plugin_enabled),e.hasOwnProperty("facebook_jssdk_version")&&(settings.facebook_jssdk_version=e.facebook_jssdk_version),e.hasOwnProperty("page_id")&&(settings.fb_page_id=e.page_id),e.hasOwnProperty("customization")){var o=e.customization;o.hasOwnProperty("greetingTextCode")&&(settings.msger_chat_customization_greeting_text_code=o.greetingTextCode),o.hasOwnProperty("locale")&&(settings.msger_chat_customization_locale=o.locale),o.hasOwnProperty("themeColorCode")&&(settings.msger_chat_customization_theme_color_code=o.themeColorCode)}}function iFrameListener(o){var e=o.origin||o.originalEvent.origin;switch(e!=window.facebookAdsToolboxConfig.popupOrigin&&urlFromSameDomain(e,window.facebookAdsToolboxConfig.popupOrigin)&&(window.facebookAdsToolboxConfig.popupOrigin=e),o.data.type){case"reset":delete_all_settings(function(e){e&&o.data.params?"Settings Deleted"===e?window.sendToFacebook("ack reset",o.data.params):(console.log(e),alert(e)):console.log("Got no response from delete_all_settings")},function(e){console.error(e)});break;case"get dia settings":window.sendToFacebook("dia settings",window.diaConfig);break;case"set merchant settings":setMerchantSettings(o.data);break;case"set catalog":setCatalog(o.data);break;case"set pixel":setPixel(o.data);break;case"gen feed":genFeed();break;case"set page access token":setAccessTokenAndPageId(o.data),save_settings_and_sync(o.data),jQuery("#fbsetup").hide(),jQuery("#integration-settings").show(),jQuery(".woocommerce-save-button").show();break;case"set msger chat":setMsgerChatSetup(o.data.params),save_settings_for_plugin(function(e){window.sendToFacebook("ack msger chat",o.data)},function(e){window.sendToFacebook("fail ack msger chat",o.data)})}}function urlFromSameDomain(e,o){if(!e.startsWith("http")||!o.startsWith("http"))return!1;var n=parseURL(e),t=parseURL(o),s=n.host.replace(/^\w+\./,"www."),i=t.host.replace(/^\w+\./,"www.");return n.protocol===t.protocol&&s===i}function parseURL(e){var o=document.createElement("a");return o.href=e,o}function check_background_processor_status(){window.facebookAdsToolboxConfig.feed.hasClientSideFeedUpload||(clearInterval(window.fb_pings),window.fb_pings=setInterval(function(){console.log("Pinging queue..."),check_queues()},1e4))}function ping_feed_status_queue(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0;clearInterval(window.fb_feed_pings),window.fb_feed_pings=setInterval(function(){console.log("Pinging feed uploading queue..."),check_feed_upload_queue(e)},3e4*(1<<e))}function product_sync_complete(e){sync_not_in_progress(),e&&(e.innerHTML=""),clearInterval(window.fb_pings)}function check_queues(){ajax("ajax_fb_background_check_queue",{request_time:(new Date).getTime(),_ajax_nonce:wc_facebook_settings_jsx.nonce},function(e){if(window.feed_upload)clearInterval(window.fb_pings);else{var o=document.querySelector("#sync_progress"),n=parse_response_check_connection(e);if(n){if(fb_sync_no_response_count=0,n){n.background||(console.log("No background sync found, disabling pings"),clearInterval(window.fb_pings));var t=!!n.processing,s=n.remaining;if(t)o&&(o.innerHTML="<strong>Progress:</strong> "+s+" item"+(1<s?"s":"")+' remaining.<span class="spinner is-active"></span>'),0===s&&product_sync_complete(o);else{if(window.fb_sync_start_time&&n.request_time){var i=new Date(parseInt(n.request_time));if(window.fb_sync_start_time>i)return void console.log("OLD PING")}0===s&&product_sync_complete(o)}}}else 5<fb_sync_no_response_count++&&clearInterval(window.fb_pings)}})}function parse_response_check_connection(e){if(e){console.log(e);var o=e.substring(e.indexOf("{"));return(o=JSON.parse(o)).connected||window.fb_connected?o:(not_connected(),null)}return null}function check_feed_upload_queue(t){ajax("ajax_check_feed_upload_status",{_ajax_nonce:wc_facebook_settings_jsx.nonce},function(e){var o=document.querySelector("#sync_progress"),n=parse_response_check_connection(e);if(clearInterval(window.fb_feed_pings),n)switch(n.status){case"complete":window.feed_upload=!1,window.is_test?display_test_result():product_sync_complete(o);break;case"in progress":o&&(o.innerHTML='Syncing... Keep this browser open until sync is complete.<span class="spinner is-active"></span>'),ping_feed_status_queue(t+1);break;default:o&&(o.innerHTML="<strong>Something wrong when uploading, please try again.</strong>"),window.feed_upload=!1,window.is_test&&display_test_result()}})}function display_test_result(){ajax("ajax_display_test_result",{_ajax_nonce:wc_facebook_settings_jsx.nonce},function(e){var o=document.querySelector("#sync_complete"),n=document.querySelector("#sync_progress"),t=parse_response_check_connection(e);if(t)switch(t.pass){case"true":sync_not_in_progress(),o&&(o.style.display="",o.innerHTML="<strong>Status: </strong>Test Pass."),n&&(n.innerHTML=""),window.is_test=!1;break;case"in progress":n&&(n.innerHTML="<strong>Integration test in progress...</strong>"),ping_feed_status_queue();break;default:window.debug_info=t.debug_info+"<br/>"+t.stack_trace,o&&(o.style.display="",o.innerHTML="<strong>Status: </strong>Test Fail."),n&&(n.innerHTML=""),document.querySelector("#debug_info")&&(document.querySelector("#debug_info").style.display=""),window.is_test=!1}})}function show_debug_info(){var e=document.querySelector("#stack_trace");e&&(e.innerHTML=window.debug_info),document.querySelector("#debug_info")&&(document.querySelector("#debug_info").style.display="none"),window.debug_info=""}function fbe_init_nux_messages(){var r=window.jQuery;r(function(){r.each(r(".nux-message"),function(e,o){var n=r(o),t=n.data("target"),s=r("#"+t),i=s.position(),a=s.height()/2,c=s.outerWidth();n.css({top:Math.ceil(i.top+a)+"px",left:Math.ceil(i.left+c)+"px",display:"block"}),r(".nux-message-close-btn",n).click(function(){r(o).hide()})})})}function saveAutoSyncSchedule(){var e=document.getElementsByClassName("autosyncCheck")[0].checked,o=document.getElementsByClassName("autosyncTime")[0],n=(document.getElementsByClassName("autosyncSaveButton")[0],document.getElementsByClassName("autosyncSavedNotice")[0]);e?(o.removeAttribute("disabled"),n.style.transition="",n.style.opacity=1,setTimeout(function(){n.style.opacity=0,n.style.transition="opacity 5s"},3e3)):o.setAttribute("disabled",!0),ajax("ajax_schedule_force_resync",{enabled:e?1:0,time:o.value,_ajax_nonce:wc_facebook_settings_jsx.nonce})}function syncShortDescription(){var e=document.getElementsByClassName("syncShortDescription")[0].checked;ajax("ajax_update_fb_option",{option:"fb_sync_short_description",option_value:e?1:0,_ajax_nonce:wc_facebook_settings_jsx.nonce},null,function(){document.getElementsByClassName("syncShortDescription")[0].checked=!e,console.log("Failed to sync Short Description")})}window.location.href.includes("fb_force_resync")?window.onload=function(){sync_confirm("fb_force_resync")}:window.location.href.includes("fb_test_product_sync")&&(window.is_test=!0,window.onload=function(){sync_confirm("fb_test_product_sync")}),addAnEventListener(window,"message",iFrameListener),jQuery(document).ready(function(e){check_background_processor_status(),e("#woocommerce-facebook-settings-sync-products").click(function(e){e.preventDefault(),sync_confirm()})});
changelog.txt CHANGED
@@ -1,415 +1,425 @@
1
- *** Facebook for WooCommerce Changelog ***
2
- 2019-06-27 - Version 1.9.15
3
- * CSRF handling for Ajax calls like ajax_woo_infobanner_post_click, ajax_woo_infobanner_post_xout, ajax_fb_toggle_visibility
4
- * use phpcs to adhere to WP coding standards
5
- * Minor UI changes on the iFrame
6
-
7
- 2019-06-20 - Version 1.9.14
8
- * Revisit CSRF security issue
9
- * Remove rest controller which is not used
10
-
11
- 2019-06-18 - Version 1.9.13
12
- * Fix security issue
13
- * Add more contributors to the plugin
14
-
15
- 2019-05-02 - Version 1.9.12
16
- * Remove dead code which causes exception (Issue 975)
17
-
18
- 2019-02-26 - Version 1.9.11
19
- * changing contributor to facebook from facebook4woocommerce, so that
20
- woo plugin will be shown under https://profiles.wordpress.org/facebook/#content-plugins
21
- * adding changelog in readme.txt so that notifications will be sent for updates and
22
- changelog will be shown under https://wordpress.org/plugins/facebook-for-woocommerce/#developers
23
- * removing debug flags notice under facebook-for-woocommerce.php so that developers will
24
- be able to debug with debug logs
25
-
26
- 2019-02-11 - Version 1.9.10
27
- * Add facebook support link, this will help merchants to reach out to facebook customer service.
28
- * Make plugin wordpress compatible by removing woocommerce updater and removing woo_include
29
-
30
- 2018-12-30 - Version 1.9.9
31
- * Fix issue with missing file in v1.9.8
32
- * Remove misleading content relating to Instagram which is not launched yet.
33
-
34
- 2018-11-30 - Version 1.9.8
35
- * Prevent Show/Hide button auto scroll.
36
- * DIY entry field for FB product Image.
37
- * Initial Support for Advanced Bulk Edit.
38
- * Added Option to Use short description instead of description.
39
- * Added checkbox for disable sync with FB for dev environment.
40
- * Add New Advanced Option : Auto Force Resync on Schedule.
41
- * Don't sync out of stock items to FB depending on Woo setting.
42
- * Add custom price.
43
- * Fix 502 Bad Gateway Error When Redirect.
44
- * Sync composite product with calculating the price based on the price of sub-items.
45
- * Advanced Options Toggle in Configuration Screen.
46
-
47
- 2018-11-01 - Version 1.9.7
48
- * Support messenger chat customization dialog
49
- * Add Copyright header.
50
- * Fix lowercasting product description.
51
- * Fix Connect Woo AYMT Logic Flow and improve Logging.
52
-
53
- 2018-09-21 - Version 1.9.6
54
- * Update plugin description of new design for WooCommerce.
55
- * Remove get_date() in Woocommerce plugin.
56
- * Add External Action-to-Make Channel Support.
57
-
58
- 2018-08-14 - Version 1.9.5
59
- * Fix Subscription Event Injection
60
-
61
- 2018-08-10 - Version 1.9.4
62
- * Support Lead Gen Event - Contact Form 7
63
- * Separate Redirect Entry Point Logging
64
- * Fix undefined variable warnings.
65
- * Add a Settings link to the plugin config page from the WP Plugins page.
66
- * Adding filter to Pixel init for injection of fbq(consent, revoke) (GDPR)
67
-
68
- 2018-08-01 - Version 1.9.3
69
- * Add Edge Cases for Integration Test.
70
- * Fix Undefined PHP Warning.
71
- * Add subscribe event.
72
- * Fix Unable to Change Pixel after Setup.
73
- * Fix Integration Test Confirmation Dialog.
74
-
75
- 2018-07-08 - Version 1.9.2
76
- * Exclude Virtual Variation and Set Staging.
77
- * Add Version Number for Logging.
78
-
79
- 2018-06-22 - version 1.9.1
80
- * Fix Page Name Extra Space .
81
- * Remove Strange Box in Design.
82
-
83
- 2018-06-15 - version 1.9.0
84
- * Fix Performance Issue by Reusing Existing wp_query Object Contents.
85
- * Rename Long Column Which Causes UI Issues for Users in Product Overview.
86
- * Update Admin Notice Content.
87
- * Fix Weird ID Error Message.
88
- * Fix Product ID for Brand Attribute.
89
- * Don't use Checkout URL for Unknown Product Types.
90
- * Add Beta Integration Test for Syncing Products by Uploading Feed.
91
- * Fix Pixel Fired on Related Products.
92
- * Redesign Admin Panel.
93
- * Add Integration Test Entry Point Button.
94
-
95
- 2018-05-02 - version 1.8.7
96
- * Fix PHP Error Due to product_brand Taxonomy Not Existing
97
-
98
- 2018-04-26 - version 1.8.6
99
- * Potential Fix for Compatibility with Enhanced ECommerce Plugin
100
- * Reduce Fetch ID API Call for Hidden Products
101
- * Support Product Bundles Extension
102
- * Basic Support for WP All Import
103
- * Fix Trashing and Deletion
104
- * Fetch Brand and Support WooCommerce Brand Extension
105
- * Remove warning for duplicate SKUs
106
- * Remove upsell header on config page
107
- * Update Info Banner Content
108
- * Fix Warning When Deleting NON PRODUCT post
109
- * WPML Support : Language Selector
110
-
111
- 2018-04-17 - version 1.8.5
112
- * Fix ViewContent event incorrectly firing with content_type 'product'
113
- * Fix product group retailer id not matching ViewContent content id.
114
- * Added logging and defensive code to debug #348
115
- * Warning about Cart URL changes now clears with Force Resync
116
-
117
- 2018-04-06 - version 1.8.4
118
- * Fire AddToCart on Cart Viewed for shops which redirect to cart.
119
- * Fix HTML AJAX comment inside script breaking HTML optimizers.
120
- * Log product sync speed as a performance metric.
121
-
122
- 2018-03-30 - version 1.8.3
123
- * Fix Hidden Product Showing Up in Shop after Initial Sync.
124
- * Hiding a variable product now hides the product on FB.
125
- * Fix Variable Subscription Products Not Syncing Variants.
126
- * Support Default Variant in Plugin via Graph API: Create and Update.
127
- * Set Default Variant as Default Product in Feed.
128
-
129
- 2018-03-20 - version 1.8.2
130
- * Fix category column in feed.
131
- * Update Force Resync to use a feed if feed was used for initial sync. (~15x faster)
132
- * Fix all caps description products being rejected from feed.
133
- * Fix gallery images for variable products not showing in feed.
134
- * Fix multiple category error in feed upload.
135
-
136
- 2018-02-27 - version 1.8.1
137
- * Fix Upgrade TagName For Beta Version
138
-
139
- 2018-02-14 - version 1.8.0
140
- * Up to 15x Performance Improvement of Initial Product Sync by using a feed upload.
141
- * Fix Subscription Product Bug Due to API Change.
142
- * Fix Undefined Index Notices.
143
- * Ensure jQuery is Loaded before Using it.
144
- * Moved apply_filters from Constructor to wp_head Action.
145
- * Remove Atlernative Pixel Basecode Fetching.
146
- * [WordPress]Separate the Plugins to Different Directories
147
-
148
- 2018-02-01 - version 1.7.11
149
- * Fix permission error due to difference in data format between graphapi and feed uploading.
150
-
151
- 2018-01-31 - version 1.7.10
152
- * Disable Alternate Pixel Basecode fetching due to issues for some stores.
153
- * Fix variation carry main description if variant description is empty.
154
- * Add version check information.
155
-
156
- 2018-01-30 - version 1.7.9
157
- * Add Filter hook for other plugins to override pixel behavior.
158
- * Fix 500 errors when saving settings.
159
-
160
- 2018-01-25 - version 1.7.8
161
- * Fixes WC_Facebookcommerce_Pixel reference error
162
-
163
- 2018-01-22 - version 1.7.7
164
- * Fix purchase event not firing for Stripe.
165
- * Fix duplicate pixel issue for Initiate Checkout and Purchase events
166
- * Pixel basecode is fetched from Facebook when setup is completed.
167
- * Pixel proxy endpoints added for cases where pixel script cannot be loaded.
168
-
169
- 2018-01-03 - version 1.7.6
170
- * WordPress only plugin notice on missing Pixel ID.
171
- * WordPress only plugin direct link to settings page from plugin page.
172
-
173
- 2018-01-11 - version 1.7.5
174
- * Fix auto-updater to upgrade facebook-for-woocommerce only.
175
-
176
- 2018-01-05 - version 1.7.4
177
- * Fix purchase event not firing for some payment types.
178
- * Provide functionality to refresh API token when invalid.
179
- * Added Quick Edit Compatibility.
180
- * Fix Incompatibility with remove HTTP extension.
181
- * Added Bulk Edit Compatibility.
182
- * WPML compatibility: products in non-default language set to staging
183
- * Add support for variable subscription products.
184
-
185
- 2017-12-13 - version 1.7.3
186
- * Fix security hole that would allow a logged in user without
187
- manage_woocommerce permissions to toggle the fb_visibility of products.
188
- * Handle shortcodes.
189
- * Support product duplication.
190
-
191
- 2017-11-30 - version 1.7.2
192
- * Fix issue with get_plugin_data being called before it was loaded.
193
- * Improve perf of info dialog.
194
- * Move class loading and DB read into admin gate to fix site slowdown.
195
-
196
- 2017-11-29 - version 1.7.0
197
- * Enable auto-upgrading.
198
- * Remove the extra content IDs to fix match rate issue.
199
- * Only show 'Any' in attribute value string and show attribute name.
200
- * Fix trash/restore products visibility on Facebook Shop.
201
- * Fix deprecated function for variant description.
202
- * Add hook and fix checkout url for external products.
203
- * Clean HTML tag in product title.
204
- * Add info dialog on WooCommerce report, settings and status page.
205
-
206
- 2017-11-03 - version 1.6.6
207
- * Solve race condition to avoid minus remaining number in syncing process.
208
- * Fix sync of variant product description.
209
- * Enable line breaks in product main description.
210
- * Enable upsell message and redirect link visible for upgrading users.
211
- * Improve upsell message content and style.
212
-
213
- 2017-10-19 - version 1.6.5
214
- * Fix unterminated div tag. Thanks @pwag42
215
- * After 7 days, show a link to a new ads interface on the settings page.
216
-
217
- 2017-10-04 - version 1.6.4
218
- * Default to variant specific image as primary image for FB.
219
- * Add a Checkbox to allow override to use the parent product image.
220
- * Don't sync items which have zero price.
221
- * Existing 0 price items will be marked invisible after Force-Resync.
222
- * Support Syncing Bookable Items with 'Display Cost' set.
223
- * Fix 'Update' and 'Publish' for Bookable Items.
224
-
225
-
226
- 2017-10-03 - version 1.6.3
227
- * Use Bookable price when regular price doesn't exist.
228
- * Support Default Variations.
229
- * Fix warning when generating attribute names.
230
-
231
- 2017-09-28 - version 1.6.2
232
- * Fix "Invalid Parameter" API error caused by invalid sale dates.
233
- * Fix variable product unable to sync gallery images.
234
- * Cache gallery image urls for variable products to reduce DB load.
235
- * Fix exception during generation of some ViewCategory events.
236
-
237
- 2017-09-21 - version 1.6.1
238
- * Prevent save settings button for other WooCommerce plugins erasing FB settings.
239
-
240
- 2017-09-15 - version 1.6.0
241
- * Support sale start and end dates
242
- * Include tax on sale price as needed
243
- * Fix visibility toggle on the product page
244
- * No longer publish hidden products
245
- * Use variable products' attribute name, instead of slug name
246
- * Fix encoding issue in Variation names
247
- * Resolve W3 validation error caused by pixel code
248
- * Correctly sync variants where the attribute is not specified or set to 'any'.
249
- * Save Changes button no longer disappears in other settings pages
250
- * Fix a JS warning caused by ViewCategory events by switching to trackCustom
251
- * Fix quoted strings having unneeded slashes in the FB Description
252
- * Fix Unicode encoding in Category Names. Thanks @jancinert.
253
-
254
- 2017-09-05 - version 1.5.1
255
- * Fix critical issue with ViewContent events not matching products.
256
-
257
- 2017-09-05 - version 1.5.0
258
- * Added support for generic WordPress installations (without WooCommerce)
259
- * Added Search events
260
- * Setting page for Pixel ID and for enabling advanced measurement
261
- * Use featured image as primary image for variants, and variant images as additional images.
262
-
263
- 2017-08-25 - version 1.4.6
264
- * Fix issue where prices were rounded incorrectly
265
-
266
- 2017-08-15 - version 1.4.5
267
- * Prevent printed output from breaking the popupOrigin
268
- * Add composer.json file
269
-
270
- 2017-07-25 - version 1.4.4
271
- * Remove duplicate and blank content ids in pixel fires.
272
- * Fix warning when sale price is malformed.
273
-
274
- 2017-07-26 - version 1.4.3
275
- * Remove search event for admin panel searches (fix JS error preventing quick edit)
276
- * Prevent search event from firing twice
277
- * Add categories to items
278
- * Add re-configure button back if merchant is locked out (e.g. due to password change)
279
-
280
- 2017-06-20 - version 1.4.2
281
- * Add custom Facebook description box
282
- * Less yelling during product sync
283
- * Remove deprecation warnings
284
- * Fix RTL issue for JS loading (thanks Ariel!)
285
- * Validate gender param to FB enum
286
- * Fix product deletion for sub variants
287
-
288
- 2017-06-15 - version 1.4.1
289
- * Fix OOM/whitescreen of death error (constrain product count query to IDs)
290
-
291
- 2017-06-05 - version 1.4.0
292
- * Background sync! Products will now sync in the background if you keep your settings page open.
293
- * Fix purchase pixel fires for product variants
294
- * Fix state on hide/show buttons
295
- * Fix issue with incorrect price rounding
296
- * Delete FB metadata from product items as well as groups
297
- * Add GPL license to repo
298
-
299
- 2017-05-30 - version 1.3.3
300
- * Use display prices for regular prices (includes VAT if used)
301
- * Switch from checkboxes to buttons on Products page
302
- * Add "Reset Facebook metadata" option for merchants that duplicate products
303
- * Add "Delete on Facebook" option for products
304
- * Only delete products when actually deleted (vs trashed)
305
- * Allow pixel resetting after setup completion
306
- * Disable plugin if WP_DEBUG_DISPLAY is detected (prevent PHP notice injection)
307
-
308
- 2017-05-25 - version 1.3.2
309
- * Allow Force Resync button to resume stalled product syncs.
310
- * Handle WP_Error errors
311
-
312
- 2017-05-23 - version 1.3.1
313
- * Only use checkout urls if valid cart url is detected
314
- * Set priority and namespacing for all ajax functions
315
- * Workaround for staticxx domain redirects
316
-
317
- 2017-05-15 - version 1.3.0
318
- * Improve memory usage and remove OOM for large product catalogs
319
- * Split variant methods for product groups and product items (fix mismatches)
320
- * Make re-sync button work for updates as well as creates
321
- * Fix issue with newly added variants breaking out of their product group
322
- * Use default form values for variants if present
323
- * Strip registered shortcodes from descriptions via strip_shortcodes
324
- * Remove PHP warning about variable passed by reference
325
- * Capture and save existing FBIDs on "Duplicate Retailer ID" error
326
-
327
- 2017-05-11 - version 1.2.6
328
- * Remove use of post guid for product URLs
329
-
330
- 2017-05-06 - version 1.2.5
331
- * Ajax lockdown: transmit fb-specific code and set priority on save_settings
332
-
333
- 2017-05-05 - version 1.2.4
334
- * Fix issue with pixel selection step freezing due to missing site url.
335
-
336
- 2017-05-04 - version 1.2.3
337
- * Workaround for servers that send additional characters on ajax responses
338
-
339
- 2017-05-02 - version 1.2.2
340
- * Fix issues with non-english variant labels
341
- * Support gallery image urls
342
-
343
- 2017-05-02 - version 1.2.1
344
- * Use wc_get_cart_url to support custom cart URLs
345
- * Fix logging bug for users without manage_woocommerce attempting to set up
346
-
347
- 2017-04-27 - version 1.2.0
348
- * Allow regular admins with manage_woocommerce permission to use plugin
349
- * Lock settings during product sync
350
- * Do not allow product sync during an existing product sync
351
- * Validate catalog ID before product sync
352
- * Fix issue with resync products button
353
- * Fix issue with plugin breaking product search
354
-
355
- 2017-04-25 - version 1.1.0
356
- * Support duplicate SKUs via better retailer ID logic
357
- * Add "resync products" button
358
- * Update FB logging to support objects as well as strings
359
- * Add support for regular and sale pricing
360
-
361
- 2017-04-20 - version 1.0.3
362
- * Remove delete button (use Advanced Settings tab instead)
363
- * Cleaned up admin messages, prepended them with "Facebook for WooCommerce"
364
-
365
- 2017-04-13 - version 1.0.2
366
- * Remove Save Settings button when not in debug mode
367
-
368
- 2017-04-11 - version 1.0.1
369
- * Prevent blank item descriptions
370
- * Update copy on setup page
371
- * Sanitize settings before sending via fblog
372
- * Show better warnings for duplicate SKUs
373
-
374
- 2017-04-10 - version 1.0.0
375
- * First release! Woo!
376
-
377
- 2017-04-09 - version 0.8.0
378
- * Include status messages during background sync
379
- * Fix several PHP warnings and various WooCommerce 3.0 compatibility issues
380
-
381
- 2017-04-07 - version 0.7.2
382
- * Fix issue where products were not being created due to blank descriptions
383
-
384
- 2017-04-04 - version 0.7.1
385
- * Clean up output for checkboxes via printf
386
- * Bug fixes and performance improvements
387
-
388
- 2017-04-03 - version 0.7.0
389
- * Add new product visibility checkbox toggle for Facebook Shops on Product list
390
- * Official rename: Facebook for WooCommerce
391
-
392
- 2017-03-30 - version 0.6.0
393
- * Revert back to minor revisions for versioning
394
- * Add ability to reset all settings to start over
395
-
396
- 2017-03-20 - version 0.0.5
397
- * Fix "Get Started" button bug
398
- * Fix issue preventing "Use Advanced Matching" setting from properly saving
399
- * Various security fixes
400
-
401
- 2017-03-01 - version 0.0.4
402
-
403
- * Add Facebook metabox on product page with products' FB ID and a Visibility toggle (publish/unpublish).
404
-
405
- 2017-02-15 - version 0.0.3
406
-
407
- * Add a change log!
408
- * Modify plugin to check for both local and network installs of WooCommerce.
409
- * Disable plugin hooks that were triggering before setup was complete.
410
- * Escape HTML tags in product descriptions.
411
- * Use attribute label name instead of first-letter-capitalized slug.
412
-
413
- 2017-02-02 - version 0.0.2
414
-
415
- * Fix breaking when debug mode is disabled (null check in facebook-settings.js)
1
+ *** Facebook for WooCommerce Changelog ***
2
+
3
+ 2020.03.03 - version 1.10.0
4
+ * Feature - Exclude specific products, variations, product categories, and product tags from syncing to Facebook
5
+ * Feature - Add Facebook product settings like price and description to variations
6
+ * Feature - Revamped settings screen with on-site control over pixel, product sync, and Messenger behavior
7
+ * Tweak - Use Action Scheduler for the daily forced re-sync, if enabled
8
+ * Fix - Improve pixel tracking accuracy for add-to-cart events
9
+ * Misc. - Add the SkyVerge plugin framework as the plugin base
10
+ * Misc. - Require WooCommerce 3.5 and above
11
+
12
+ 2019-06-27 - Version 1.9.15
13
+ * CSRF handling for Ajax calls like ajax_woo_infobanner_post_click, ajax_woo_infobanner_post_xout, ajax_fb_toggle_visibility
14
+ * use phpcs to adhere to WP coding standards
15
+ * Minor UI changes on the iFrame
16
+
17
+ 2019-06-20 - Version 1.9.14
18
+ * Revisit CSRF security issue
19
+ * Remove rest controller which is not used
20
+
21
+ 2019-06-18 - Version 1.9.13
22
+ * Fix security issue
23
+ * Add more contributors to the plugin
24
+
25
+ 2019-05-02 - Version 1.9.12
26
+ * Remove dead code which causes exception (Issue 975)
27
+
28
+ 2019-02-26 - Version 1.9.11
29
+ * changing contributor to facebook from facebook4woocommerce, so that
30
+ woo plugin will be shown under https://profiles.wordpress.org/facebook/#content-plugins
31
+ * adding changelog in readme.txt so that notifications will be sent for updates and
32
+ changelog will be shown under https://wordpress.org/plugins/facebook-for-woocommerce/#developers
33
+ * removing debug flags notice under facebook-for-woocommerce.php so that developers will
34
+ be able to debug with debug logs
35
+
36
+ 2019-02-11 - Version 1.9.10
37
+ * Add facebook support link, this will help merchants to reach out to facebook customer service.
38
+ * Make plugin wordpress compatible by removing woocommerce updater and removing woo_include
39
+
40
+ 2018-12-30 - Version 1.9.9
41
+ * Fix issue with missing file in v1.9.8
42
+ * Remove misleading content relating to Instagram which is not launched yet.
43
+
44
+ 2018-11-30 - Version 1.9.8
45
+ * Prevent Show/Hide button auto scroll.
46
+ * DIY entry field for FB product Image.
47
+ * Initial Support for Advanced Bulk Edit.
48
+ * Added Option to Use short description instead of description.
49
+ * Added checkbox for disable sync with FB for dev environment.
50
+ * Add New Advanced Option : Auto Force Resync on Schedule.
51
+ * Don't sync out of stock items to FB depending on Woo setting.
52
+ * Add custom price.
53
+ * Fix 502 Bad Gateway Error When Redirect.
54
+ * Sync composite product with calculating the price based on the price of sub-items.
55
+ * Advanced Options Toggle in Configuration Screen.
56
+
57
+ 2018-11-01 - Version 1.9.7
58
+ * Support messenger chat customization dialog
59
+ * Add Copyright header.
60
+ * Fix lowercasting product description.
61
+ * Fix Connect Woo AYMT Logic Flow and improve Logging.
62
+
63
+ 2018-09-21 - Version 1.9.6
64
+ * Update plugin description of new design for WooCommerce.
65
+ * Remove get_date() in Woocommerce plugin.
66
+ * Add External Action-to-Make Channel Support.
67
+
68
+ 2018-08-14 - Version 1.9.5
69
+ * Fix Subscription Event Injection
70
+
71
+ 2018-08-10 - Version 1.9.4
72
+ * Support Lead Gen Event - Contact Form 7
73
+ * Separate Redirect Entry Point Logging
74
+ * Fix undefined variable warnings.
75
+ * Add a Settings link to the plugin config page from the WP Plugins page.
76
+ * Adding filter to Pixel init for injection of fbq(consent, revoke) (GDPR)
77
+
78
+ 2018-08-01 - Version 1.9.3
79
+ * Add Edge Cases for Integration Test.
80
+ * Fix Undefined PHP Warning.
81
+ * Add subscribe event.
82
+ * Fix Unable to Change Pixel after Setup.
83
+ * Fix Integration Test Confirmation Dialog.
84
+
85
+ 2018-07-08 - Version 1.9.2
86
+ * Exclude Virtual Variation and Set Staging.
87
+ * Add Version Number for Logging.
88
+
89
+ 2018-06-22 - version 1.9.1
90
+ * Fix Page Name Extra Space .
91
+ * Remove Strange Box in Design.
92
+
93
+ 2018-06-15 - version 1.9.0
94
+ * Fix Performance Issue by Reusing Existing wp_query Object Contents.
95
+ * Rename Long Column Which Causes UI Issues for Users in Product Overview.
96
+ * Update Admin Notice Content.
97
+ * Fix Weird ID Error Message.
98
+ * Fix Product ID for Brand Attribute.
99
+ * Don't use Checkout URL for Unknown Product Types.
100
+ * Add Beta Integration Test for Syncing Products by Uploading Feed.
101
+ * Fix Pixel Fired on Related Products.
102
+ * Redesign Admin Panel.
103
+ * Add Integration Test Entry Point Button.
104
+
105
+ 2018-05-02 - version 1.8.7
106
+ * Fix PHP Error Due to product_brand Taxonomy Not Existing
107
+
108
+ 2018-04-26 - version 1.8.6
109
+ * Potential Fix for Compatibility with Enhanced ECommerce Plugin
110
+ * Reduce Fetch ID API Call for Hidden Products
111
+ * Support Product Bundles Extension
112
+ * Basic Support for WP All Import
113
+ * Fix Trashing and Deletion
114
+ * Fetch Brand and Support WooCommerce Brand Extension
115
+ * Remove warning for duplicate SKUs
116
+ * Remove upsell header on config page
117
+ * Update Info Banner Content
118
+ * Fix Warning When Deleting NON PRODUCT post
119
+ * WPML Support : Language Selector
120
+
121
+ 2018-04-17 - version 1.8.5
122
+ * Fix ViewContent event incorrectly firing with content_type 'product'
123
+ * Fix product group retailer id not matching ViewContent content id.
124
+ * Added logging and defensive code to debug #348
125
+ * Warning about Cart URL changes now clears with Force Resync
126
+
127
+ 2018-04-06 - version 1.8.4
128
+ * Fire AddToCart on Cart Viewed for shops which redirect to cart.
129
+ * Fix HTML AJAX comment inside script breaking HTML optimizers.
130
+ * Log product sync speed as a performance metric.
131
+
132
+ 2018-03-30 - version 1.8.3
133
+ * Fix Hidden Product Showing Up in Shop after Initial Sync.
134
+ * Hiding a variable product now hides the product on FB.
135
+ * Fix Variable Subscription Products Not Syncing Variants.
136
+ * Support Default Variant in Plugin via Graph API: Create and Update.
137
+ * Set Default Variant as Default Product in Feed.
138
+
139
+ 2018-03-20 - version 1.8.2
140
+ * Fix category column in feed.
141
+ * Update Force Resync to use a feed if feed was used for initial sync. (~15x faster)
142
+ * Fix all caps description products being rejected from feed.
143
+ * Fix gallery images for variable products not showing in feed.
144
+ * Fix multiple category error in feed upload.
145
+
146
+ 2018-02-27 - version 1.8.1
147
+ * Fix Upgrade TagName For Beta Version
148
+
149
+ 2018-02-14 - version 1.8.0
150
+ * Up to 15x Performance Improvement of Initial Product Sync by using a feed upload.
151
+ * Fix Subscription Product Bug Due to API Change.
152
+ * Fix Undefined Index Notices.
153
+ * Ensure jQuery is Loaded before Using it.
154
+ * Moved apply_filters from Constructor to wp_head Action.
155
+ * Remove Atlernative Pixel Basecode Fetching.
156
+ * [WordPress]Separate the Plugins to Different Directories
157
+
158
+ 2018-02-01 - version 1.7.11
159
+ * Fix permission error due to difference in data format between graphapi and feed uploading.
160
+
161
+ 2018-01-31 - version 1.7.10
162
+ * Disable Alternate Pixel Basecode fetching due to issues for some stores.
163
+ * Fix variation carry main description if variant description is empty.
164
+ * Add version check information.
165
+
166
+ 2018-01-30 - version 1.7.9
167
+ * Add Filter hook for other plugins to override pixel behavior.
168
+ * Fix 500 errors when saving settings.
169
+
170
+ 2018-01-25 - version 1.7.8
171
+ * Fixes WC_Facebookcommerce_Pixel reference error
172
+
173
+ 2018-01-22 - version 1.7.7
174
+ * Fix purchase event not firing for Stripe.
175
+ * Fix duplicate pixel issue for Initiate Checkout and Purchase events
176
+ * Pixel basecode is fetched from Facebook when setup is completed.
177
+ * Pixel proxy endpoints added for cases where pixel script cannot be loaded.
178
+
179
+ 2018-01-03 - version 1.7.6
180
+ * WordPress only plugin notice on missing Pixel ID.
181
+ * WordPress only plugin direct link to settings page from plugin page.
182
+
183
+ 2018-01-11 - version 1.7.5
184
+ * Fix auto-updater to upgrade facebook-for-woocommerce only.
185
+
186
+ 2018-01-05 - version 1.7.4
187
+ * Fix purchase event not firing for some payment types.
188
+ * Provide functionality to refresh API token when invalid.
189
+ * Added Quick Edit Compatibility.
190
+ * Fix Incompatibility with remove HTTP extension.
191
+ * Added Bulk Edit Compatibility.
192
+ * WPML compatibility: products in non-default language set to staging
193
+ * Add support for variable subscription products.
194
+
195
+ 2017-12-13 - version 1.7.3
196
+ * Fix security hole that would allow a logged in user without
197
+ manage_woocommerce permissions to toggle the fb_visibility of products.
198
+ * Handle shortcodes.
199
+ * Support product duplication.
200
+
201
+ 2017-11-30 - version 1.7.2
202
+ * Fix issue with get_plugin_data being called before it was loaded.
203
+ * Improve perf of info dialog.
204
+ * Move class loading and DB read into admin gate to fix site slowdown.
205
+
206
+ 2017-11-29 - version 1.7.0
207
+ * Enable auto-upgrading.
208
+ * Remove the extra content IDs to fix match rate issue.
209
+ * Only show 'Any' in attribute value string and show attribute name.
210
+ * Fix trash/restore products visibility on Facebook Shop.
211
+ * Fix deprecated function for variant description.
212
+ * Add hook and fix checkout url for external products.
213
+ * Clean HTML tag in product title.
214
+ * Add info dialog on WooCommerce report, settings and status page.
215
+
216
+ 2017-11-03 - version 1.6.6
217
+ * Solve race condition to avoid minus remaining number in syncing process.
218
+ * Fix sync of variant product description.
219
+ * Enable line breaks in product main description.
220
+ * Enable upsell message and redirect link visible for upgrading users.
221
+ * Improve upsell message content and style.
222
+
223
+ 2017-10-19 - version 1.6.5
224
+ * Fix unterminated div tag. Thanks @pwag42
225
+ * After 7 days, show a link to a new ads interface on the settings page.
226
+
227
+ 2017-10-04 - version 1.6.4
228
+ * Default to variant specific image as primary image for FB.
229
+ * Add a Checkbox to allow override to use the parent product image.
230
+ * Don't sync items which have zero price.
231
+ * Existing 0 price items will be marked invisible after Force-Resync.
232
+ * Support Syncing Bookable Items with 'Display Cost' set.
233
+ * Fix 'Update' and 'Publish' for Bookable Items.
234
+
235
+
236
+ 2017-10-03 - version 1.6.3
237
+ * Use Bookable price when regular price doesn't exist.
238
+ * Support Default Variations.
239
+ * Fix warning when generating attribute names.
240
+
241
+ 2017-09-28 - version 1.6.2
242
+ * Fix "Invalid Parameter" API error caused by invalid sale dates.
243
+ * Fix variable product unable to sync gallery images.
244
+ * Cache gallery image urls for variable products to reduce DB load.
245
+ * Fix exception during generation of some ViewCategory events.
246
+
247
+ 2017-09-21 - version 1.6.1
248
+ * Prevent save settings button for other WooCommerce plugins erasing FB settings.
249
+
250
+ 2017-09-15 - version 1.6.0
251
+ * Support sale start and end dates
252
+ * Include tax on sale price as needed
253
+ * Fix visibility toggle on the product page
254
+ * No longer publish hidden products
255
+ * Use variable products' attribute name, instead of slug name
256
+ * Fix encoding issue in Variation names
257
+ * Resolve W3 validation error caused by pixel code
258
+ * Correctly sync variants where the attribute is not specified or set to 'any'.
259
+ * Save Changes button no longer disappears in other settings pages
260
+ * Fix a JS warning caused by ViewCategory events by switching to trackCustom
261
+ * Fix quoted strings having unneeded slashes in the FB Description
262
+ * Fix Unicode encoding in Category Names. Thanks @jancinert.
263
+
264
+ 2017-09-05 - version 1.5.1
265
+ * Fix critical issue with ViewContent events not matching products.
266
+
267
+ 2017-09-05 - version 1.5.0
268
+ * Added support for generic WordPress installations (without WooCommerce)
269
+ * Added Search events
270
+ * Setting page for Pixel ID and for enabling advanced measurement
271
+ * Use featured image as primary image for variants, and variant images as additional images.
272
+
273
+ 2017-08-25 - version 1.4.6
274
+ * Fix issue where prices were rounded incorrectly
275
+
276
+ 2017-08-15 - version 1.4.5
277
+ * Prevent printed output from breaking the popupOrigin
278
+ * Add composer.json file
279
+
280
+ 2017-07-25 - version 1.4.4
281
+ * Remove duplicate and blank content ids in pixel fires.
282
+ * Fix warning when sale price is malformed.
283
+
284
+ 2017-07-26 - version 1.4.3
285
+ * Remove search event for admin panel searches (fix JS error preventing quick edit)
286
+ * Prevent search event from firing twice
287
+ * Add categories to items
288
+ * Add re-configure button back if merchant is locked out (e.g. due to password change)
289
+
290
+ 2017-06-20 - version 1.4.2
291
+ * Add custom Facebook description box
292
+ * Less yelling during product sync
293
+ * Remove deprecation warnings
294
+ * Fix RTL issue for JS loading (thanks Ariel!)
295
+ * Validate gender param to FB enum
296
+ * Fix product deletion for sub variants
297
+
298
+ 2017-06-15 - version 1.4.1
299
+ * Fix OOM/whitescreen of death error (constrain product count query to IDs)
300
+
301
+ 2017-06-05 - version 1.4.0
302
+ * Background sync! Products will now sync in the background if you keep your settings page open.
303
+ * Fix purchase pixel fires for product variants
304
+ * Fix state on hide/show buttons
305
+ * Fix issue with incorrect price rounding
306
+ * Delete FB metadata from product items as well as groups
307
+ * Add GPL license to repo
308
+
309
+ 2017-05-30 - version 1.3.3
310
+ * Use display prices for regular prices (includes VAT if used)
311
+ * Switch from checkboxes to buttons on Products page
312
+ * Add "Reset Facebook metadata" option for merchants that duplicate products
313
+ * Add "Delete on Facebook" option for products
314
+ * Only delete products when actually deleted (vs trashed)
315
+ * Allow pixel resetting after setup completion
316
+ * Disable plugin if WP_DEBUG_DISPLAY is detected (prevent PHP notice injection)
317
+
318
+ 2017-05-25 - version 1.3.2
319
+ * Allow Force Resync button to resume stalled product syncs.
320
+ * Handle WP_Error errors
321
+
322
+ 2017-05-23 - version 1.3.1
323
+ * Only use checkout urls if valid cart url is detected
324
+ * Set priority and namespacing for all ajax functions
325
+ * Workaround for staticxx domain redirects
326
+
327
+ 2017-05-15 - version 1.3.0
328
+ * Improve memory usage and remove OOM for large product catalogs
329
+ * Split variant methods for product groups and product items (fix mismatches)
330
+ * Make re-sync button work for updates as well as creates
331
+ * Fix issue with newly added variants breaking out of their product group
332
+ * Use default form values for variants if present
333
+ * Strip registered shortcodes from descriptions via strip_shortcodes
334
+ * Remove PHP warning about variable passed by reference
335
+ * Capture and save existing FBIDs on "Duplicate Retailer ID" error
336
+
337
+ 2017-05-11 - version 1.2.6
338
+ * Remove use of post guid for product URLs
339
+
340
+ 2017-05-06 - version 1.2.5
341
+ * Ajax lockdown: transmit fb-specific code and set priority on save_settings
342
+
343
+ 2017-05-05 - version 1.2.4
344
+ * Fix issue with pixel selection step freezing due to missing site url.
345
+
346
+ 2017-05-04 - version 1.2.3
347
+ * Workaround for servers that send additional characters on ajax responses
348
+
349
+ 2017-05-02 - version 1.2.2
350
+ * Fix issues with non-english variant labels
351
+ * Support gallery image urls
352
+
353
+ 2017-05-02 - version 1.2.1
354
+ * Use wc_get_cart_url to support custom cart URLs
355
+ * Fix logging bug for users without manage_woocommerce attempting to set up
356
+
357
+ 2017-04-27 - version 1.2.0
358
+ * Allow regular admins with manage_woocommerce permission to use plugin
359
+ * Lock settings during product sync
360
+ * Do not allow product sync during an existing product sync
361
+ * Validate catalog ID before product sync
362
+ * Fix issue with resync products button
363
+ * Fix issue with plugin breaking product search
364
+
365
+ 2017-04-25 - version 1.1.0
366
+ * Support duplicate SKUs via better retailer ID logic
367
+ * Add "resync products" button
368
+ * Update FB logging to support objects as well as strings
369
+ * Add support for regular and sale pricing
370
+
371
+ 2017-04-20 - version 1.0.3
372
+ * Remove delete button (use Advanced Settings tab instead)
373
+ * Cleaned up admin messages, prepended them with "Facebook for WooCommerce"
374
+
375
+ 2017-04-13 - version 1.0.2
376
+ * Remove Save Settings button when not in debug mode
377
+
378
+ 2017-04-11 - version 1.0.1
379
+ * Prevent blank item descriptions
380
+ * Update copy on setup page
381
+ * Sanitize settings before sending via fblog
382
+ * Show better warnings for duplicate SKUs
383
+
384
+ 2017-04-10 - version 1.0.0
385
+ * First release! Woo!
386
+
387
+ 2017-04-09 - version 0.8.0
388
+ * Include status messages during background sync
389
+ * Fix several PHP warnings and various WooCommerce 3.0 compatibility issues
390
+
391
+ 2017-04-07 - version 0.7.2
392
+ * Fix issue where products were not being created due to blank descriptions
393
+
394
+ 2017-04-04 - version 0.7.1
395
+ * Clean up output for checkboxes via printf
396
+ * Bug fixes and performance improvements
397
+
398
+ 2017-04-03 - version 0.7.0
399
+ * Add new product visibility checkbox toggle for Facebook Shops on Product list
400
+ * Official rename: Facebook for WooCommerce
401
+
402
+ 2017-03-30 - version 0.6.0
403
+ * Revert back to minor revisions for versioning
404
+ * Add ability to reset all settings to start over
405
+
406
+ 2017-03-20 - version 0.0.5
407
+ * Fix "Get Started" button bug
408
+ * Fix issue preventing "Use Advanced Matching" setting from properly saving
409
+ * Various security fixes
410
+
411
+ 2017-03-01 - version 0.0.4
412
+
413
+ * Add Facebook metabox on product page with products' FB ID and a Visibility toggle (publish/unpublish).
414
+
415
+ 2017-02-15 - version 0.0.3
416
+
417
+ * Add a change log!
418
+ * Modify plugin to check for both local and network installs of WooCommerce.
419
+ * Disable plugin hooks that were triggering before setup was complete.
420
+ * Escape HTML tags in product descriptions.
421
+ * Use attribute label name instead of first-letter-capitalized slug.
422
+
423
+ 2017-02-02 - version 0.0.2
424
+
425
+ * Fix breaking when debug mode is disabled (null check in facebook-settings.js)
class-wc-facebookcommerce.php ADDED
@@ -0,0 +1,381 @@