Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/official-facebook-pixel/FacebookAds/ApiRequest.php
+++ b/official-facebook-pixel/FacebookAds/ApiRequest.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
--- a/official-facebook-pixel/FacebookAds/CrashReporter.php
+++ b/official-facebook-pixel/FacebookAds/CrashReporter.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
--- a/official-facebook-pixel/FacebookAds/Cursor.php
+++ b/official-facebook-pixel/FacebookAds/Cursor.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
--- a/official-facebook-pixel/FacebookAds/Enum/AbstractEnum.php
+++ b/official-facebook-pixel/FacebookAds/Enum/AbstractEnum.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Http/Adapter/Curl/AbstractCurl.php
+++ b/official-facebook-pixel/FacebookAds/Http/Adapter/Curl/AbstractCurl.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Http/Adapter/Curl/Curl.php
+++ b/official-facebook-pixel/FacebookAds/Http/Adapter/Curl/Curl.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Http/Adapter/Curl/Curl55.php
+++ b/official-facebook-pixel/FacebookAds/Http/Adapter/Curl/Curl55.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Http/Adapter/CurlAdapter.php
+++ b/official-facebook-pixel/FacebookAds/Http/Adapter/CurlAdapter.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Http/Client.php
+++ b/official-facebook-pixel/FacebookAds/Http/Client.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Logger/CurlLogger.php
+++ b/official-facebook-pixel/FacebookAds/Logger/CurlLogger.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Logger/CurlLogger/JsonNode.php
+++ b/official-facebook-pixel/FacebookAds/Logger/CurlLogger/JsonNode.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Object/AbstractCrudObject.php
+++ b/official-facebook-pixel/FacebookAds/Object/AbstractCrudObject.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
--- a/official-facebook-pixel/FacebookAds/Object/AbstractObject.php
+++ b/official-facebook-pixel/FacebookAds/Object/AbstractObject.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
--- a/official-facebook-pixel/FacebookAds/Object/AdImage.php
+++ b/official-facebook-pixel/FacebookAds/Object/AdImage.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
--- a/official-facebook-pixel/FacebookAds/Object/CustomAudience.php
+++ b/official-facebook-pixel/FacebookAds/Object/CustomAudience.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
--- a/official-facebook-pixel/FacebookAds/Object/CustomAudienceMultiKey.php
+++ b/official-facebook-pixel/FacebookAds/Object/CustomAudienceMultiKey.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
--- a/official-facebook-pixel/FacebookAds/Object/ServerSide/CAPIGatewayEndpoint.php
+++ b/official-facebook-pixel/FacebookAds/Object/ServerSide/CAPIGatewayEndpoint.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Object/ServerSide/CustomData.php
+++ b/official-facebook-pixel/FacebookAds/Object/ServerSide/CustomData.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Object/ServerSide/Normalizer.php
+++ b/official-facebook-pixel/FacebookAds/Object/ServerSide/Normalizer.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Object/ServerSide/UserData.php
+++ b/official-facebook-pixel/FacebookAds/Object/ServerSide/UserData.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Object/ServerSide/Util.php
+++ b/official-facebook-pixel/FacebookAds/Object/ServerSide/Util.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/**
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
*
--- a/official-facebook-pixel/FacebookAds/Object/Traits/FieldValidation.php
+++ b/official-facebook-pixel/FacebookAds/Object/Traits/FieldValidation.php
@@ -1,4 +1,5 @@
<?php
+// phpcs:ignoreFile — third-party Meta Business SDK (vendored); excluded from linting.
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
--- a/official-facebook-pixel/core/class-facebookpluginconfig.php
+++ b/official-facebook-pixel/core/class-facebookpluginconfig.php
@@ -33,7 +33,7 @@
* Class FacebookPluginConfig
*/
class FacebookPluginConfig {
- const PLUGIN_VERSION = '5.2.1';
+ const PLUGIN_VERSION = '5.2.2';
const SOURCE = 'wordpress';
const TEXT_DOMAIN = 'official-facebook-pixel';
const PLUGIN_NAME = 'Meta Pixel for WordPress';
--- a/official-facebook-pixel/core/class-facebookwordpresssettingspage.php
+++ b/official-facebook-pixel/core/class-facebookwordpresssettingspage.php
@@ -1081,17 +1081,17 @@
'
<div class="notice notice-%s is-dismissible">
<p>%s</p>
- <button
- type="button"
+ <a
+ href="%s"
class="notice-dismiss"
- onClick="location.href='%s'">
+ style="text-decoration: none;">
<span class="screen-reader-text">%s</span>
- </button>
+ </a>
</div>
',
esc_html( $notice_type ),
wp_kses_post( $link ),
- esc_url( add_query_arg( $dismiss_config, '' ) ),
+ esc_url( add_query_arg( $dismiss_config, '1', admin_url() ) ),
esc_html__(
'Dismiss this notice.',
'official-facebook-pixel'
--- a/official-facebook-pixel/facebook-for-wordpress.php
+++ b/official-facebook-pixel/facebook-for-wordpress.php
@@ -6,7 +6,9 @@
* Description: <strong><em>***ATTENTION: After upgrade the plugin may be deactivated due to a known issue, to workaround please refresh this page and activate plugin.***</em></strong> The Facebook pixel is an analytics tool that helps you measure the effectiveness of your advertising. You can use the Facebook pixel to understand the actions people are taking on your website and reach audiences you care about.
* Author: Facebook
* Author URI: https://www.facebook.com/
- * Version: 5.2.1
+ * Version: 5.2.2
+ * License: GPLv2
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: official-facebook-pixel
*
* @package FacebookPixelPlugin
--- a/official-facebook-pixel/integration/class-facebookwordpresswoocommerce.php
+++ b/official-facebook-pixel/integration/class-facebookwordpresswoocommerce.php
@@ -290,6 +290,10 @@
foreach ( $order->get_items() as $item ) {
$product = wc_get_product( $item->get_product_id() );
+ if ( ! is_object( $product ) || ! method_exists( $product, 'get_id' ) ) {
+ continue;
+ }
+
if ( 'product_group' !== $content_type
&& $product->is_type( 'variable' ) ) {
$content_type = 'product_group';
@@ -352,7 +356,7 @@
$server_event = ServerEventFactory::safe_create_event(
'AddToCart',
array( __CLASS__, 'createAddToCartEvent' ),
- array( $cart_item_key, $product_id, $quantity ),
+ array( $cart_item_key, $product_id, $quantity, $variation_id ),
self::TRACKING_NAME
);
@@ -412,6 +416,7 @@
* @param string $cart_item_key The cart item key.
* @param int $product_id The product ID.
* @param int $quantity The quantity.
+ * @param int $variation_id The variation ID.
*
* @return array The event data.
*
@@ -420,14 +425,15 @@
public static function createAddToCartEvent(
$cart_item_key,
$product_id,
- $quantity
+ $quantity,
+ $variation_id = null
) {
$event_data = self::getPIIFromSession();
$event_data['content_type'] = 'product';
$event_data['currency'] = get_woocommerce_currency();
$cart_item = self::getCartItem( $cart_item_key );
- if ( ! empty( $cart_item_key ) ) {
+ if ( ! empty( $cart_item ) && ! empty( $cart_item['data'] ) ) {
$event_data['content_ids'] = array(
self::getProductId(
$cart_item['data']
@@ -437,6 +443,22 @@
$cart_item,
$quantity
);
+
+ return $event_data;
+ }
+
+ // Fallback for integrations that call Woo add_to_cart() on a
+ // temporary/private cart (e.g. subscription cloning flows).
+ $product_lookup_id = ! empty( $variation_id ) ? $variation_id : $product_id;
+ $product = wc_get_product( $product_lookup_id );
+ $product_fb_id = self::getProductId( $product );
+
+ if ( ! empty( $product_fb_id ) ) {
+ $event_data['content_ids'] = array( $product_fb_id );
+
+ if ( is_object( $product ) && method_exists( $product, 'get_price' ) ) {
+ $event_data['value'] = (float) $quantity * (float) $product->get_price();
+ }
}
return $event_data;
@@ -649,6 +671,10 @@
* @since 1.0.0
*/
private static function getProductId( $product ) {
+ if ( ! is_object( $product ) || ! method_exists( $product, 'get_id' ) ) {
+ return null;
+ }
+
$woo_id = $product->get_id();
return $product->get_sku() ? $product->get_sku() . '_' .
--- a/official-facebook-pixel/local-config-sample.php
+++ b/official-facebook-pixel/local-config-sample.php
@@ -1,5 +1,15 @@
<?php
/**
+ * Copyright (C) 2017-present, Meta, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
* Local development overrides (copy to local-config.php).
*
* This file is loaded by facebook-for-wordpress.php before anything else.
--- a/official-facebook-pixel/vendor/composer/installed.php
+++ b/official-facebook-pixel/vendor/composer/installed.php
@@ -1,8 +1,8 @@
<?php return array(
'root' => array(
'name' => 'facebook/pixel-for-wordpress',
- 'pretty_version' => '5.2.1',
- 'version' => '5.2.1.0',
+ 'pretty_version' => '5.2.2',
+ 'version' => '5.2.2.0',
'reference' => null,
'type' => 'project',
'install_path' => __DIR__ . '/../../',
@@ -20,8 +20,8 @@
'dev_requirement' => false,
),
'facebook/pixel-for-wordpress' => array(
- 'pretty_version' => '5.2.1',
- 'version' => '5.2.1.0',
+ 'pretty_version' => '5.2.2',
+ 'version' => '5.2.2.0',
'reference' => null,
'type' => 'project',
'install_path' => __DIR__ . '/../../',