Facebook for WooCommerce - Version 2.3.4

Version Description

Download this release

Release Info

Developer automattic
Plugin Icon Facebook for WooCommerce
Version 2.3.4
Comparing to
See all releases

Code changes from version 2.3.3 to 2.3.4

assets/images/woocommerce-placeholder.png ADDED
Binary file
changelog.txt CHANGED
@@ -1,5 +1,13 @@
1
  *** Facebook for WooCommerce Changelog ***
2
 
 
 
 
 
 
 
 
 
3
  2021.03.22 - version 2.3.3
4
  * Fix - WooCommerce variation attribute sync not matching Enhanced Catalog attributes.
5
  * Fix - Enable display names to be used for variant attribute values.
1
  *** Facebook for WooCommerce Changelog ***
2
 
3
+ 2021.03.30 - version 2.3.4
4
+ * Feature - Add connection state to WooCommerce Usage Tracking.
5
+ * Feature - Register WooCommerce Navigation items.
6
+ * Fix - Disable product sync on 2.3.3 update ( temporary fix ).
7
+ * Fix - Add default placeholder for products with no image set.
8
+ * Fix - Undefined array key error for products without 'Product image' set.
9
+ * Dev - PHP Deprecated: Non-static method should not be called statically.
10
+
11
  2021.03.22 - version 2.3.3
12
  * Fix - WooCommerce variation attribute sync not matching Enhanced Catalog attributes.
13
  * Fix - Enable display names to be used for variant attribute values.
class-wc-facebookcommerce.php CHANGED
@@ -22,7 +22,7 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
22
 
23
 
24
  /** @var string the plugin version */
25
- const VERSION = '2.3.3';
26
 
27
  /** @var string for backwards compatibility TODO: remove this in v2.0.0 {CW 2020-02-06} */
28
  const PLUGIN_VERSION = self::VERSION;
@@ -88,6 +88,8 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
88
  /** @var \SkyVerge\WooCommerce\Facebook\Commerce commerce handler */
89
  private $commerce_handler;
90
 
 
 
91
 
92
  /**
93
  * Constructs the plugin.
@@ -152,6 +154,7 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
152
  require_once __DIR__ . '/includes/Events/Normalizer.php';
153
  require_once __DIR__ . '/includes/Events/AAMSettings.php';
154
  require_once __DIR__ . '/includes/Utilities/Shipment.php';
 
155
 
156
  $this->product_feed = new \SkyVerge\WooCommerce\Facebook\Products\Feed();
157
  $this->products_stock_handler = new \SkyVerge\WooCommerce\Facebook\Products\Stock();
@@ -185,6 +188,8 @@ if ( ! class_exists( 'WC_Facebookcommerce' ) ) :
185
  $this->connection_handler = new \SkyVerge\WooCommerce\Facebook\Handlers\Connection( $this );
186
  $this->webhook_handler = new \SkyVerge\WooCommerce\Facebook\Handlers\WebHook( $this );
187
 
 
 
188
  // load admin handlers, before admin_init
189
  if ( is_admin() ) {
190
 
22
 
23
 
24
  /** @var string the plugin version */
25
+ const VERSION = '2.3.4';
26
 
27
  /** @var string for backwards compatibility TODO: remove this in v2.0.0 {CW 2020-02-06} */
28
  const PLUGIN_VERSION = self::VERSION;
88
  /** @var \SkyVerge\WooCommerce\Facebook\Commerce commerce handler */
89
  private $commerce_handler;
90
 
91
+ /** @var \SkyVerge\WooCommerce\Facebook\Tracker */
92
+ private $tracker;
93
 
94
  /**
95
  * Constructs the plugin.
154
  require_once __DIR__ . '/includes/Events/Normalizer.php';
155
  require_once __DIR__ . '/includes/Events/AAMSettings.php';
156
  require_once __DIR__ . '/includes/Utilities/Shipment.php';
157
+ require_once __DIR__ . '/includes/Utilities/Tracker.php';
158
 
159
  $this->product_feed = new \SkyVerge\WooCommerce\Facebook\Products\Feed();
160
  $this->products_stock_handler = new \SkyVerge\WooCommerce\Facebook\Products\Stock();
188
  $this->connection_handler = new \SkyVerge\WooCommerce\Facebook\Handlers\Connection( $this );
189
  $this->webhook_handler = new \SkyVerge\WooCommerce\Facebook\Handlers\WebHook( $this );
190
 
191
+ $this->tracker = new \SkyVerge\WooCommerce\Facebook\Utilities\Tracker();
192
+
193
  // load admin handlers, before admin_init
194
  if ( is_admin() ) {
195
 
facebook-for-woocommerce.php CHANGED
@@ -10,7 +10,7 @@
10
  * Description: Grow your business on Facebook! Use this official plugin to help sell more of your products using Facebook. After completing the setup, you'll be ready to create ads that promote your products and you can also create a shop section on your Page where customers can browse your products on Facebook.
11
  * Author: Facebook
12
  * Author URI: https://www.facebook.com/
13
- * Version: 2.3.3
14
  * Text Domain: facebook-for-woocommerce
15
  * WC requires at least: 3.5.0
16
  * WC tested up to: 5.1.0
10
  * Description: Grow your business on Facebook! Use this official plugin to help sell more of your products using Facebook. After completing the setup, you'll be ready to create ads that promote your products and you can also create a shop section on your Page where customers can browse your products on Facebook.
11
  * Author: Facebook
12
  * Author URI: https://www.facebook.com/
13
+ * Version: 2.3.4
14
  * Text Domain: facebook-for-woocommerce
15
  * WC requires at least: 3.5.0
16
  * WC tested up to: 5.1.0
i18n/languages/facebook-for-woocommerce.pot CHANGED
@@ -2,10 +2,10 @@
2
  # This file is distributed under the same license as the Facebook for WooCommerce package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Facebook for WooCommerce 2.3.3\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
- "POT-Creation-Date: 2021-03-22 09:51:42+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
@@ -13,7 +13,7 @@ msgstr ""
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
- #: class-wc-facebookcommerce.php:257
17
  #. translators: Placeholders %1$s - opening strong HTML tag, %2$s - closing
18
  #. strong HTML tag, %3$s - opening link HTML tag, %4$s - closing link HTML tag
19
  msgid ""
@@ -21,7 +21,7 @@ msgid ""
21
  "Facebook for WooCommerce connection. Please %3$sclick here%4$s to reconnect!"
22
  msgstr ""
23
 
24
- #: class-wc-facebookcommerce.php:272
25
  #. translators: Placeholders %1$s - opening link HTML tag, %2$s - closing link
26
  #. HTML tag
27
  msgid ""
@@ -29,7 +29,7 @@ msgid ""
29
  "under %1$sWooCommerce > Facebook%2$s."
30
  msgstr ""
31
 
32
- #: class-wc-facebookcommerce.php:287
33
  #. translators: Placeholders %1$s - opening strong HTML tag, %2$s - closing
34
  #. strong HTML tag, %3$s - opening link HTML tag, %4$s - closing link HTML tag
35
  msgid ""
@@ -37,7 +37,7 @@ msgid ""
37
  "configuration, %3$scomplete the setup steps%4$s."
38
  msgstr ""
39
 
40
- #: class-wc-facebookcommerce.php:315
41
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
42
  #. <a> tag, %4$s - </a> tag
43
  msgid ""
@@ -46,7 +46,7 @@ msgid ""
46
  "Connection%4$s area."
47
  msgstr ""
48
 
49
- #: class-wc-facebookcommerce.php:332
50
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
51
  #. <a> tag, %4$s - </a> tag
52
  msgid ""
@@ -55,51 +55,51 @@ msgid ""
55
  "products."
56
  msgstr ""
57
 
58
- #: class-wc-facebookcommerce.php:352
59
  #. translators: Placeholders: %1$s - opening <a> HTML link tag, %2$s - closing
60
  #. </a> HTML link tag
61
  msgid "Heads up! The Facebook menu is now located under the %1$sMarketing%2$s menu."
62
  msgstr ""
63
 
64
- #: class-wc-facebookcommerce.php:422
65
  msgid "FB Product Sets"
66
  msgstr ""
67
 
68
- #: class-wc-facebookcommerce.php:423
69
  msgid "FB Product Set"
70
  msgstr ""
71
 
72
- #: class-wc-facebookcommerce.php:431
73
  #. translators: Edit item label
74
  msgid "Edit %s"
75
  msgstr ""
76
 
77
- #: class-wc-facebookcommerce.php:433
78
  #. translators: Add new label
79
  msgid "Add new %s"
80
  msgstr ""
81
 
82
- #: class-wc-facebookcommerce.php:436
83
  #. translators: No items found text
84
  msgid "No %s found."
85
  msgstr ""
86
 
87
- #: class-wc-facebookcommerce.php:438
88
  #. translators: Search label
89
  msgid "Search %s."
90
  msgstr ""
91
 
92
- #: class-wc-facebookcommerce.php:440
93
  #. translators: Text label
94
  msgid "Separate %s with commas"
95
  msgstr ""
96
 
97
- #: class-wc-facebookcommerce.php:442
98
  #. translators: Text label
99
  msgid "Choose from the most used %s"
100
  msgstr ""
101
 
102
- #: class-wc-facebookcommerce.php:558
103
  msgid "Cannot create the API instance because the access token is missing."
104
  msgstr ""
105
 
@@ -381,20 +381,20 @@ msgstr ""
381
  msgid "Facebook"
382
  msgstr ""
383
 
384
- #: includes/Admin/Settings.php:107
385
  #: includes/Admin/Settings_Screens/Connection.php:34
386
  #: includes/Admin/Settings_Screens/Connection.php:35
387
  msgid "Connection"
388
  msgstr ""
389
 
390
- #: includes/Admin/Settings.php:110
391
  #: includes/Admin/Settings_Screens/Messenger.php:40
392
  #: includes/Admin/Settings_Screens/Messenger.php:41
393
  #: includes/Admin/Settings_Screens/Messenger.php:144
394
  msgid "Messenger"
395
  msgstr ""
396
 
397
- #: includes/Admin/Settings.php:113
398
  #: includes/Admin/Settings_Screens/Product_Sync.php:42
399
  #: includes/Admin/Settings_Screens/Product_Sync.php:43
400
  #: includes/Admin/Settings_Screens/Product_Sync.php:167
@@ -402,21 +402,21 @@ msgstr ""
402
  msgid "Product sync"
403
  msgstr ""
404
 
405
- #: includes/Admin/Settings.php:116
406
  #: includes/Admin/Settings_Screens/Advertise.php:37
407
  #: includes/Admin/Settings_Screens/Advertise.php:38
408
  msgid "Advertise"
409
  msgstr ""
410
 
411
- #: includes/Admin/Settings.php:198
412
  msgid "You do not have permission to save these settings."
413
  msgstr ""
414
 
415
- #: includes/Admin/Settings.php:207
416
  msgid "Your settings have been saved."
417
  msgstr ""
418
 
419
- #: includes/Admin/Settings.php:214
420
  #. translators: Placeholders: %s - user-friendly error message
421
  msgid "Your settings could not be saved. %s"
422
  msgstr ""
2
  # This file is distributed under the same license as the Facebook for WooCommerce package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Facebook for WooCommerce 2.3.4\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://woocommerce.com/my-account/marketplace-ticket-form/\n"
8
+ "POT-Creation-Date: 2021-03-31 01:25:31+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
 
16
+ #: class-wc-facebookcommerce.php:262
17
  #. translators: Placeholders %1$s - opening strong HTML tag, %2$s - closing
18
  #. strong HTML tag, %3$s - opening link HTML tag, %4$s - closing link HTML tag
19
  msgid ""
21
  "Facebook for WooCommerce connection. Please %3$sclick here%4$s to reconnect!"
22
  msgstr ""
23
 
24
+ #: class-wc-facebookcommerce.php:277
25
  #. translators: Placeholders %1$s - opening link HTML tag, %2$s - closing link
26
  #. HTML tag
27
  msgid ""
29
  "under %1$sWooCommerce > Facebook%2$s."
30
  msgstr ""
31
 
32
+ #: class-wc-facebookcommerce.php:292
33
  #. translators: Placeholders %1$s - opening strong HTML tag, %2$s - closing
34
  #. strong HTML tag, %3$s - opening link HTML tag, %4$s - closing link HTML tag
35
  msgid ""
37
  "configuration, %3$scomplete the setup steps%4$s."
38
  msgstr ""
39
 
40
+ #: class-wc-facebookcommerce.php:320
41
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
42
  #. <a> tag, %4$s - </a> tag
43
  msgid ""
46
  "Connection%4$s area."
47
  msgstr ""
48
 
49
+ #: class-wc-facebookcommerce.php:337
50
  #. translators: Placeholders: %1$s - <strong> tag, %2$s - </strong> tag, %3$s -
51
  #. <a> tag, %4$s - </a> tag
52
  msgid ""
55
  "products."
56
  msgstr ""
57
 
58
+ #: class-wc-facebookcommerce.php:357
59
  #. translators: Placeholders: %1$s - opening <a> HTML link tag, %2$s - closing
60
  #. </a> HTML link tag
61
  msgid "Heads up! The Facebook menu is now located under the %1$sMarketing%2$s menu."
62
  msgstr ""
63
 
64
+ #: class-wc-facebookcommerce.php:427
65
  msgid "FB Product Sets"
66
  msgstr ""
67
 
68
+ #: class-wc-facebookcommerce.php:428
69
  msgid "FB Product Set"
70
  msgstr ""
71
 
72
+ #: class-wc-facebookcommerce.php:436
73
  #. translators: Edit item label
74
  msgid "Edit %s"
75
  msgstr ""
76
 
77
+ #: class-wc-facebookcommerce.php:438
78
  #. translators: Add new label
79
  msgid "Add new %s"
80
  msgstr ""
81
 
82
+ #: class-wc-facebookcommerce.php:441
83
  #. translators: No items found text
84
  msgid "No %s found."
85
  msgstr ""
86
 
87
+ #: class-wc-facebookcommerce.php:443
88
  #. translators: Search label
89
  msgid "Search %s."
90
  msgstr ""
91
 
92
+ #: class-wc-facebookcommerce.php:445
93
  #. translators: Text label
94
  msgid "Separate %s with commas"
95
  msgstr ""
96
 
97
+ #: class-wc-facebookcommerce.php:447
98
  #. translators: Text label
99
  msgid "Choose from the most used %s"
100
  msgstr ""
101
 
102
+ #: class-wc-facebookcommerce.php:563
103
  msgid "Cannot create the API instance because the access token is missing."
104
  msgstr ""
105
 
381
  msgid "Facebook"
382
  msgstr ""
383
 
384
+ #: includes/Admin/Settings.php:119
385
  #: includes/Admin/Settings_Screens/Connection.php:34
386
  #: includes/Admin/Settings_Screens/Connection.php:35
387
  msgid "Connection"
388
  msgstr ""
389
 
390
+ #: includes/Admin/Settings.php:122
391
  #: includes/Admin/Settings_Screens/Messenger.php:40
392
  #: includes/Admin/Settings_Screens/Messenger.php:41
393
  #: includes/Admin/Settings_Screens/Messenger.php:144
394
  msgid "Messenger"
395
  msgstr ""
396
 
397
+ #: includes/Admin/Settings.php:125
398
  #: includes/Admin/Settings_Screens/Product_Sync.php:42
399
  #: includes/Admin/Settings_Screens/Product_Sync.php:43
400
  #: includes/Admin/Settings_Screens/Product_Sync.php:167
402
  msgid "Product sync"
403
  msgstr ""
404
 
405
+ #: includes/Admin/Settings.php:128
406
  #: includes/Admin/Settings_Screens/Advertise.php:37
407
  #: includes/Admin/Settings_Screens/Advertise.php:38
408
  msgid "Advertise"
409
  msgstr ""
410
 
411
+ #: includes/Admin/Settings.php:212
412
  msgid "You do not have permission to save these settings."
413
  msgstr ""
414
 
415
+ #: includes/Admin/Settings.php:221
416
  msgid "Your settings have been saved."
417
  msgstr ""
418
 
419
+ #: includes/Admin/Settings.php:228
420
  #. translators: Placeholders: %s - user-friendly error message
421
  msgid "Your settings could not be saved. %s"
422
  msgstr ""
includes/Admin/Settings.php CHANGED
@@ -10,6 +10,8 @@
10
 
11
  namespace SkyVerge\WooCommerce\Facebook\Admin;
12
 
 
 
13
  use SkyVerge\WooCommerce\Facebook\Admin\Settings_Screens;
14
  use SkyVerge\WooCommerce\PluginFramework\v5_10_0 as Framework;
15
 
@@ -30,6 +32,13 @@ class Settings {
30
  /** @var Abstract_Settings_Screen[] */
31
  private $screens;
32
 
 
 
 
 
 
 
 
33
 
34
  /**
35
  * Settings constructor.
@@ -49,6 +58,8 @@ class Settings {
49
  add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
50
 
51
  add_action( 'wp_loaded', array( $this, 'save' ) );
 
 
52
  }
53
 
54
 
@@ -83,6 +94,7 @@ class Settings {
83
  );
84
 
85
  $this->connect_to_enhanced_admin( $is_marketing_enabled ? 'marketing_page_wc-facebook' : 'woocommerce_page_wc-facebook' );
 
86
  }
87
 
88
 
@@ -148,13 +160,15 @@ class Settings {
148
 
149
  <div class="wrap woocommerce">
150
 
151
- <nav class="nav-tab-wrapper woo-nav-tab-wrapper">
 
152
 
153
- <?php foreach ( $tabs as $id => $label ) : ?>
154
- <a href="<?php echo esc_html( admin_url( 'admin.php?page=' . self::PAGE_ID . '&tab=' . esc_attr( $id ) ) ); ?>" class="nav-tab <?php echo $current_tab === $id ? 'nav-tab-active' : ''; ?>"><?php echo esc_html( $label ); ?></a>
155
- <?php endforeach; ?>
156
 
157
- </nav>
 
158
 
159
  <?php facebook_for_woocommerce()->get_message_handler()->show_messages(); ?>
160
 
@@ -292,5 +306,42 @@ class Settings {
292
  return (array) apply_filters( 'wc_facebook_admin_settings_tabs', $tabs, $this );
293
  }
294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
 
296
- }
10
 
11
  namespace SkyVerge\WooCommerce\Facebook\Admin;
12
 
13
+ use Automattic\WooCommerce\Admin\Features\Features as WooAdminFeatures;
14
+ use Automattic\WooCommerce\Admin\Features\Navigation\Menu as WooAdminMenu;
15
  use SkyVerge\WooCommerce\Facebook\Admin\Settings_Screens;
16
  use SkyVerge\WooCommerce\PluginFramework\v5_10_0 as Framework;
17
 
32
  /** @var Abstract_Settings_Screen[] */
33
  private $screens;
34
 
35
+ /**
36
+ * Whether the new Woo nav should be used.
37
+ *
38
+ * @var bool
39
+ */
40
+ public $use_woo_nav;
41
+
42
 
43
  /**
44
  * Settings constructor.
58
  add_action( 'admin_menu', array( $this, 'add_menu_item' ) );
59
 
60
  add_action( 'wp_loaded', array( $this, 'save' ) );
61
+
62
+ $this->use_woo_nav = class_exists( WooAdminMenu::class ) && WooAdminFeatures::is_enabled( 'navigation' );
63
  }
64
 
65
 
94
  );
95
 
96
  $this->connect_to_enhanced_admin( $is_marketing_enabled ? 'marketing_page_wc-facebook' : 'woocommerce_page_wc-facebook' );
97
+ $this->register_woo_nav_menu_items();
98
  }
99
 
100
 
160
 
161
  <div class="wrap woocommerce">
162
 
163
+ <?php if ( ! $this->use_woo_nav ): ?>
164
+ <nav class="nav-tab-wrapper woo-nav-tab-wrapper">
165
 
166
+ <?php foreach ( $tabs as $id => $label ) : ?>
167
+ <a href="<?php echo esc_html( admin_url( 'admin.php?page=' . self::PAGE_ID . '&tab=' . esc_attr( $id ) ) ); ?>" class="nav-tab <?php echo $current_tab === $id ? 'nav-tab-active' : ''; ?>"><?php echo esc_html( $label ); ?></a>
168
+ <?php endforeach; ?>
169
 
170
+ </nav>
171
+ <?php endif; ?>
172
 
173
  <?php facebook_for_woocommerce()->get_message_handler()->show_messages(); ?>
174
 
306
  return (array) apply_filters( 'wc_facebook_admin_settings_tabs', $tabs, $this );
307
  }
308
 
309
+ /**
310
+ * Register nav items for new Woo nav.
311
+ *
312
+ * @since 2.3.3
313
+ */
314
+ private function register_woo_nav_menu_items() {
315
+ if ( ! $this->use_woo_nav ) {
316
+ return;
317
+ }
318
+
319
+ WooAdminMenu::add_plugin_category(
320
+ array(
321
+ 'id' => 'facebook-for-woocommerce',
322
+ 'title' => __( 'Facebook', 'facebook-for-woocommerce' ),
323
+ 'capability' => 'manage_woocommerce',
324
+ )
325
+ );
326
+
327
+ $order = 1;
328
+ foreach( $this->get_screens() as $screen_id => $screen ) {
329
+ $url = $screen instanceof Settings_Screens\Product_Sets
330
+ ? 'edit-tags.php?taxonomy=fb_product_set&post_type=product'
331
+ : 'wc-facebook&tab=' . $screen->get_id();
332
+
333
+ WooAdminMenu::add_plugin_item(
334
+ array(
335
+ 'id' => 'facebook-for-woocommerce-'. $screen->get_id(),
336
+ 'parent' => 'facebook-for-woocommerce',
337
+ 'title' => $screen->get_label(),
338
+ 'url' => $url,
339
+ 'order' => $order,
340
+ )
341
+ );
342
+ $order++;
343
+ }
344
+ }
345
+
346
 
347
+ }
includes/Lifecycle.php CHANGED
@@ -42,7 +42,6 @@ class Lifecycle extends Framework\Plugin\Lifecycle {
42
  '2.0.0',
43
  '2.0.3',
44
  '2.0.4',
45
- '2.3.3',
46
  ];
47
  }
48
 
@@ -337,17 +336,4 @@ class Lifecycle extends Framework\Plugin\Lifecycle {
337
  }
338
  }
339
 
340
- /**
341
- * Upgrades to version 2.3.3
342
- *
343
- * @since 2.3.3.
344
- */
345
- protected function upgrade_to_2_3_3() {
346
- $sync_enabled = 'yes' === get_option( \WC_Facebookcommerce_Integration::SETTING_ENABLE_PRODUCT_SYNC, 'yes' );
347
- if ( ! $sync_enabled ) {
348
- return;
349
- }
350
- facebook_for_woocommerce()->get_products_sync_handler()->create_or_update_all_products();
351
- }
352
-
353
  }
42
  '2.0.0',
43
  '2.0.3',
44
  '2.0.4',
 
45
  ];
46
  }
47
 
336
  }
337
  }
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  }
includes/Utilities/Tracker.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @package FacebookCommerce
9
+ */
10
+
11
+ namespace SkyVerge\WooCommerce\Facebook\Utilities;
12
+
13
+ defined( 'ABSPATH' ) or exit;
14
+
15
+ /**
16
+ * Class for adding diagnostic info to WooCommerce Tracker snapshot.
17
+ *
18
+ * See https://woocommerce.com/usage-tracking/ for more information.
19
+ *
20
+ * @since 2.3.4
21
+ */
22
+ class Tracker {
23
+
24
+ /**
25
+ * Constructor.
26
+ *
27
+ * @since 2.3.4
28
+ */
29
+ public function __construct() {
30
+ add_filter(
31
+ 'woocommerce_tracker_data',
32
+ array( $this, 'add_tracker_data' )
33
+ );
34
+ }
35
+
36
+ /**
37
+ * Append our tracker properties.
38
+ *
39
+ * @param array $data The current tracker snapshot data.
40
+ * @return array $data Snapshot updated with our data.
41
+ * @since 2.3.4
42
+ */
43
+ public function add_tracker_data( array $data = array() ) {
44
+ if ( ! isset( $data['extensions'] ) ) {
45
+ $data['extensions'] = array();
46
+ }
47
+
48
+ $connection_is_happy = false;
49
+ $connection_handler = facebook_for_woocommerce()->get_connection_handler();
50
+ if ( $connection_handler ) {
51
+ $connection_is_happy = $connection_handler->is_connected() && ! get_transient( 'wc_facebook_connection_invalid' );
52
+ }
53
+ $data['extensions']['facebook-for-woocommerce']['is-connected'] = wc_bool_to_string( $connection_is_happy );
54
+
55
+ return $data;
56
+ }
57
+ }
includes/fbproduct.php CHANGED
@@ -198,9 +198,13 @@ if ( ! class_exists( 'WC_Facebook_Product' ) ) :
198
  $image_urls = array_merge( $image_urls, $this->get_gallery_urls() );
199
  $image_urls = array_filter( array_unique( $image_urls ) );
200
 
 
 
 
 
 
201
  if ( empty( $image_urls ) ) {
202
- // TODO: replace or remove this placeholder - placeholdit.imgix.net is no longer available {WV 2020-01-21}
203
- $image_urls[] = sprintf( 'https://placeholdit.imgix.net/~text?txtsize=33&name=%s&w=530&h=530', rawurlencode( strip_tags( $this->woo_product->get_title() ) ) );
204
  }
205
 
206
  return $image_urls;
@@ -215,7 +219,7 @@ if ( ! class_exists( 'WC_Facebook_Product' ) ) :
215
  *
216
  * @since 2.0.2
217
  *
218
- * @param array $image_urls all image URLs for the product
219
  * @return array
220
  */
221
  private function get_additional_image_urls( $image_urls ) {
198
  $image_urls = array_merge( $image_urls, $this->get_gallery_urls() );
199
  $image_urls = array_filter( array_unique( $image_urls ) );
200
 
201
+ // Regenerate $image_url PHP array indexes after filtering.
202
+ // The array_filter does not touches indexes so if something gets removed we may end up with gaps.
203
+ // Later parts of the code expect something to exist under the 0 index.
204
+ $image_urls = array_values( $image_urls );
205
+
206
  if ( empty( $image_urls ) ) {
207
+ $image_urls[] = facebook_for_woocommerce()->get_plugin_url() . '/assets/images/woocommerce-placeholder.png';
 
208
  }
209
 
210
  return $image_urls;
219
  *
220
  * @since 2.0.2
221
  *
222
+ * @param array $image_urls all image URLs for the product.
223
  * @return array
224
  */
225
  private function get_additional_image_urls( $image_urls ) {
includes/fbutils.php CHANGED
@@ -419,10 +419,15 @@ if ( ! class_exists( 'WC_Facebookcommerce_Utils' ) ) :
419
  }
420
 
421
 
422
- /*
423
  * Get visible name for variant attribute rather than the slug
424
- */
425
- public function get_variant_option_name( $wp_id, $label, $default_value ) {
 
 
 
 
 
426
  $meta = get_post_meta( $wp_id, $label, true );
427
  $attribute_name = str_replace( 'attribute_', '', $label );
428
  $term = get_term_by( 'slug', $meta, $attribute_name );
419
  }
420
 
421
 
422
+ /**
423
  * Get visible name for variant attribute rather than the slug
424
+ *
425
+ * @param int $wp_id Post ID.
426
+ * @param string $label Attribute label.
427
+ * @param string $default_value Default value to use if the term has no name.
428
+ * @return string Term name or the default value.
429
+ */
430
+ public static function get_variant_option_name( $wp_id, $label, $default_value ) {
431
  $meta = get_post_meta( $wp_id, $label, true );
432
  $attribute_name = str_replace( 'attribute_', '', $label );
433
  $term = get_term_by( 'slug', $meta, $attribute_name );
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: facebook, automattic, woothemes
3
  Tags: facebook, shop, catalog, advertise, pixel, product
4
  Requires at least: 4.4
5
  Tested up to: 5.6
6
- Stable tag: 2.3.3
7
  Requires PHP: 5.6 or greater
8
  MySQL: 5.6 or greater
9
  License: GPLv2 or later
@@ -39,6 +39,14 @@ When opening a bug on GitHub, please give us as many details as possible.
39
 
40
  == Changelog ==
41
 
 
 
 
 
 
 
 
 
42
  = 2021.03.22 - version 2.3.3 =
43
  * Fix - WooCommerce variation attribute sync not matching Enhanced Catalog attributes.
44
  * Fix - Enable display names to be used for variant attribute values.
3
  Tags: facebook, shop, catalog, advertise, pixel, product
4
  Requires at least: 4.4
5
  Tested up to: 5.6
6
+ Stable tag: 2.3.4
7
  Requires PHP: 5.6 or greater
8
  MySQL: 5.6 or greater
9
  License: GPLv2 or later
39
 
40
  == Changelog ==
41
 
42
+ = 2021.03.30 - version 2.3.4 =
43
+ * Feature - Add connection state to WooCommerce Usage Tracking.
44
+ * Feature - Register WooCommerce Navigation items.
45
+ * Fix - Disable product sync on 2.3.3 update ( temporary fix ).
46
+ * Fix - Add default placeholder for products with no image set.
47
+ * Fix - Undefined array key error for products without 'Product image' set.
48
+ * Dev - PHP Deprecated: Non-static method should not be called statically.
49
+
50
  = 2021.03.22 - version 2.3.3 =
51
  * Fix - WooCommerce variation attribute sync not matching Enhanced Catalog attributes.
52
  * Fix - Enable display names to be used for variant attribute values.