From a95c3e74d8a9450dd6f8d4b19c42b75fb65d0701 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 14:50:55 +0200 Subject: [PATCH 01/32] Remove Messenger settings tab --- includes/Admin/Settings.php | 1 - 1 file changed, 1 deletion(-) diff --git a/includes/Admin/Settings.php b/includes/Admin/Settings.php index dd709f37e..14e46a61d 100644 --- a/includes/Admin/Settings.php +++ b/includes/Admin/Settings.php @@ -78,7 +78,6 @@ private function build_menu_item_array( bool $is_connected ): array { $screens = array( Settings_Screens\Product_Sync::ID => new Settings_Screens\Product_Sync(), Settings_Screens\Product_Sets::ID => new Settings_Screens\Product_Sets(), - Settings_Screens\Messenger::ID => new Settings_Screens\Messenger(), ); return array_merge( array_merge( $first, $screens ), $last ); From 283bd2db3d99e52cce86546db0c1025848dadf70 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 14:51:23 +0200 Subject: [PATCH 02/32] Remove messenger breadcrumbs --- includes/Admin/Settings.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/includes/Admin/Settings.php b/includes/Admin/Settings.php index 14e46a61d..9e34b4aa9 100644 --- a/includes/Admin/Settings.php +++ b/includes/Admin/Settings.php @@ -182,9 +182,6 @@ private function connect_to_enhanced_admin( $screen_id ) { case Connection::ID: $crumbs[] = __( 'Connection', 'facebook-for-woocommerce' ); break; - case Settings_Screens\Messenger::ID: - $crumbs[] = __( 'Messenger', 'facebook-for-woocommerce' ); - break; case Settings_Screens\Product_Sync::ID: $crumbs[] = __( 'Product sync', 'facebook-for-woocommerce' ); break; From 56cf714df146753e72cf4bafa83812276741584a Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 14:57:42 +0200 Subject: [PATCH 03/32] Mark Settings_Screens/Messenger class as deprecated --- includes/Admin/Settings_Screens/Messenger.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/Admin/Settings_Screens/Messenger.php b/includes/Admin/Settings_Screens/Messenger.php index b4e62bf21..87c602ebc 100644 --- a/includes/Admin/Settings_Screens/Messenger.php +++ b/includes/Admin/Settings_Screens/Messenger.php @@ -21,6 +21,8 @@ /** * The Messenger settings screen object. + * + * @deprecated 3.2.0 */ class Messenger extends Abstract_Settings_Screen { From 6e3e505affa4b42e0fae2156464911cab96f3122 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:03:11 +0200 Subject: [PATCH 04/32] Remove deprecation notice on upgrade --- includes/Lifecycle.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/includes/Lifecycle.php b/includes/Lifecycle.php index 2789e31ff..5f6b69a54 100644 --- a/includes/Lifecycle.php +++ b/includes/Lifecycle.php @@ -322,4 +322,18 @@ protected function upgrade_to_3_1_13() { } } + + /** + * Removes the messenger deprecation notice on upgrade to 3.2.0. + * + * @since 3.2.0 + */ + protected function upgrade_to_3_2_0() { + // Remove the Messenger deprecation notice. + $notice_slug = 'facebook_messenger_deprecation_warning'; + if( class_exists( 'WC_Admin_Notices' ) && \WC_Admin_Notices::has_notice( $notice_slug ) ) { + \WC_Admin_Notices::remove_notice( $notice_slug ); + } + } + } From 839598d318ab72a42bc6e943bced6f43b62f7b85 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:17:38 +0200 Subject: [PATCH 05/32] Deprecate and force false for is_messenger_enabled() --- facebook-commerce.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/facebook-commerce.php b/facebook-commerce.php index ca358cd6f..328393e63 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -2746,10 +2746,13 @@ public function is_legacy_feed_file_generation_enabled() { * Determines whether the Facebook messenger is enabled. * * @since 1.10.0 + * @deprecated 3.2.0 * * @return bool */ public function is_messenger_enabled() { + return false; + /** * Filters whether the Facebook messenger is enabled. * From 4c0bdcb659b5399f28be3c6cc54580a48ad6f11b Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:21:17 +0200 Subject: [PATCH 06/32] Don't initialize the messenger chat features --- facebook-commerce.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/facebook-commerce.php b/facebook-commerce.php index 328393e63..0dca6daf9 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -360,14 +360,6 @@ public function __construct( WC_Facebookcommerce $facebook_for_woocommerce ) { $this->events_tracker = new WC_Facebookcommerce_EventsTracker( $user_info, $aam_settings ); } - // Initialize the messenger chat features. - $this->messenger_chat = new WC_Facebookcommerce_MessengerChat( - array( - 'fb_page_id' => $this->get_facebook_page_id(), - 'facebook_jssdk_version' => $this->get_js_sdk_version(), - ) - ); - // Update products on change of status. add_action( 'transition_post_status', From 8ebf0c18d58fd9d94a85717119fc40748758a371 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:22:16 +0200 Subject: [PATCH 07/32] Remove messenger_chat property --- facebook-commerce.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/facebook-commerce.php b/facebook-commerce.php index 0dca6daf9..21ad7d6b4 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -185,9 +185,6 @@ class WC_Facebookcommerce_Integration extends WC_Integration { /** @var WC_Facebookcommerce_EventsTracker instance. */ private $events_tracker; - /** @var WC_Facebookcommerce_MessengerChat instance. */ - private $messenger_chat; - /** @var WC_Facebookcommerce_Background_Process instance. */ private $background_processor; From 5b4727c065be99d3eb3ffc7b615569220f568b51 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:41:52 +0200 Subject: [PATCH 08/32] Mark WC_Facebookcommerce_MessengerChat as deprecated --- facebook-commerce-messenger-chat.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/facebook-commerce-messenger-chat.php b/facebook-commerce-messenger-chat.php index 426234258..5fd2bd852 100755 --- a/facebook-commerce-messenger-chat.php +++ b/facebook-commerce-messenger-chat.php @@ -19,6 +19,8 @@ /** * Messenger chat handler class. + * + * @deprecated 3.2.0 */ class WC_Facebookcommerce_MessengerChat { From e02207d09b1b857fa0a6354dcf1020c68bc4ad49 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:43:12 +0200 Subject: [PATCH 09/32] Remove messenger_chat from magic method --- facebook-commerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/facebook-commerce.php b/facebook-commerce.php index 21ad7d6b4..a8f6647fb 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -389,7 +389,7 @@ public function __construct( WC_Facebookcommerce $facebook_for_woocommerce ) { */ public function __get( $key ) { // Add warning for private properties. - if ( in_array( $key, array( 'events_tracker', 'messenger_chat', 'background_processor' ), true ) ) { + if ( in_array( $key, array( 'events_tracker', 'background_processor' ), true ) ) { /* translators: %s property name. */ _doing_it_wrong( __FUNCTION__, sprintf( esc_html__( 'The %s property is private and should not be accessed outside its class.', 'facebook-for-woocommerce' ), esc_html( $key ) ), '3.0.32' ); return $this->$key; From 4be30a505af3fb1e085f293a97876779277deac8 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:44:04 +0200 Subject: [PATCH 10/32] Remove messenger_chat from facebookAdsToolboxConfig --- facebook-commerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/facebook-commerce.php b/facebook-commerce.php index a8f6647fb..9ed72b3db 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -706,7 +706,7 @@ public function load_assets() { -
- ", - esc_attr( $this->page_id ), - esc_js( $this->jssdk_version ?: 'v5.0' ), - esc_js( facebook_for_woocommerce()->get_integration()->get_messenger_locale() ?: 'en_US' ) - ); - - endif; - } - - } - -endif; From eb24fd0c621c38492de76af46e73d7f053f302a5 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:48:25 +0200 Subject: [PATCH 22/32] Clarify class doc --- includes/Admin/Settings_Screens/Product_Sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Admin/Settings_Screens/Product_Sync.php b/includes/Admin/Settings_Screens/Product_Sync.php index 670860430..57bc7d862 100644 --- a/includes/Admin/Settings_Screens/Product_Sync.php +++ b/includes/Admin/Settings_Screens/Product_Sync.php @@ -20,7 +20,7 @@ use WooCommerce\Facebook\Products\Sync; /** - * The Messenger settings screen object. + * The Product Sync settings screen object. */ class Product_Sync extends Abstract_Settings_Screen { From 84ea046006f80bda9ed5bb1bcdd7bb3ed16a9e18 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:49:18 +0200 Subject: [PATCH 23/32] Remove Messenger config from reconnection URL params --- includes/Handlers/Connection.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/includes/Handlers/Connection.php b/includes/Handlers/Connection.php index 97d053cf0..42f32e5fa 100644 --- a/includes/Handlers/Connection.php +++ b/includes/Handlers/Connection.php @@ -901,15 +901,6 @@ private function get_connect_parameters_extras() { if ( $external_merchant_settings_id = facebook_for_woocommerce()->get_integration()->get_external_merchant_settings_id() ) { $parameters['setup']['merchant_settings_id'] = $external_merchant_settings_id; } - // if messenger was previously enabled - if ( facebook_for_woocommerce()->get_integration()->is_messenger_enabled() ) { - $parameters['business_config']['messenger_chat'] = array( - 'enabled' => true, - 'domains' => array( - home_url( '/' ), - ), - ); - } return $parameters; } From 5c6882cd2d03f81da69cc5814f58dde4e0633a92 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Tue, 16 Apr 2024 15:51:24 +0200 Subject: [PATCH 24/32] Remove messenger deprecation notice handlers --- facebook-for-woocommerce.php | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/facebook-for-woocommerce.php b/facebook-for-woocommerce.php index b5e5e01a8..55d66d1dd 100644 --- a/facebook-for-woocommerce.php +++ b/facebook-for-woocommerce.php @@ -296,38 +296,6 @@ public function add_plugin_notices() { } - /** - * Adds warning notice that Facebook Messenger will be deprecated if the setting is enabled. - * - * @since 3.1.13 - * @deprecated 3.2.0 - */ - public function maybe_show_messenger_deprecation_notice() { - // Display the notice on the Facebook for WooCommerce settings pages (except Messenger settings, which has a static notice). - $notice_slug = 'facebook_messenger_deprecation_warning'; - $is_facebook_admin = isset( $_GET['page'] ) && 'wc-facebook' === $_GET['page']; - $is_messenger_settings = isset( $_GET['tab'] ) && 'messenger' === $_GET['tab']; - $has_deprecation_notice_queued = class_exists( 'WC_Admin_Notices' ) && \WC_Admin_Notices::has_notice( $notice_slug ); - - if( $is_facebook_admin && ! $is_messenger_settings && $has_deprecation_notice_queued ) { - \WC_Admin_Notices::output_custom_notices(); - } - } - - /** - * Removes facebook_messenger_deprecation_warning notice if it exists. - * - * @since 3.1.14 - * @deprecated 3.2.0 - * @return void - */ - public function maybe_remove_messenger_deprecation_notice() { - $notice_slug = 'facebook_messenger_deprecation_warning'; - if( class_exists( 'WC_Admin_Notices' ) && \WC_Admin_Notices::has_notice( $notice_slug ) ) { - \WC_Admin_Notices::remove_notice( $notice_slug ); - } - } - /** * Determines if the required plugins are compatible. From 061f40a93af9b9d470f616de429da76fab51d1db Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:03:00 +0200 Subject: [PATCH 25/32] Remove messenger enabled data from WC Tracker info --- includes/Utilities/Tracker.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/includes/Utilities/Tracker.php b/includes/Utilities/Tracker.php index 9d38e55bc..9d19d1832 100644 --- a/includes/Utilities/Tracker.php +++ b/includes/Utilities/Tracker.php @@ -120,8 +120,6 @@ public function add_tracker_data( array $data = [] ) { */ $product_sync_enabled = facebook_for_woocommerce()->get_integration()->is_product_sync_enabled(); $data['extensions']['facebook-for-woocommerce']['product-sync-enabled'] = wc_bool_to_string( $product_sync_enabled ); - $messenger_enabled = facebook_for_woocommerce()->get_integration()->is_messenger_enabled(); - $data['extensions']['facebook-for-woocommerce']['messenger-enabled'] = wc_bool_to_string( $messenger_enabled ); /** * How long did the last feed generation take (or did it fail - 0)? This counts just the time when the batches have been generated. From 611a19a6a48fc4d8e2604eba1a02f70cc609af91 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:04:35 +0200 Subject: [PATCH 26/32] Leave only messenger enabled unit tests --- .../WCFacebookCommerceIntegrationTest.php | 205 ------------------ 1 file changed, 205 deletions(-) diff --git a/tests/Unit/WCFacebookCommerceIntegrationTest.php b/tests/Unit/WCFacebookCommerceIntegrationTest.php index 0afd0cb83..e0b9d5e1a 100644 --- a/tests/Unit/WCFacebookCommerceIntegrationTest.php +++ b/tests/Unit/WCFacebookCommerceIntegrationTest.php @@ -2447,211 +2447,6 @@ function ( $mode ) { $this->assertEquals( WC_Facebookcommerce_Integration::PRODUCT_DESCRIPTION_MODE_STANDARD, $mode ); } - /** - * Tests get messenger locale returns default locale. - * - * @return void - */ - public function test_get_messenger_locale_no_filter_no_options() { - remove_all_filters( 'wc_facebook_messenger_locale' ); - delete_option( WC_Facebookcommerce_Integration::SETTING_MESSENGER_LOCALE ); - - $locale = $this->integration->get_messenger_locale(); - - $this->assertEquals( 'en_US', $locale ); - } - - /** - * Tests get messenger locale no filter, returns option value. - * - * @return void - */ - public function test_get_messenger_locale_no_filter() { - remove_all_filters( 'wc_facebook_messenger_locale' ); - add_option( WC_Facebookcommerce_Integration::SETTING_MESSENGER_LOCALE, 'fr-FR' ); - - $locale = $this->integration->get_messenger_locale(); - - $this->assertEquals( 'fr-FR', $locale ); - } - - /** - * Tests get messenger locale with filter. - * - * @return void - */ - public function test_get_messenger_locale_with_filter() { - add_filter( - 'wc_facebook_messenger_locale', - function ( $locale ) { - return 'es-ES'; - } - ); - add_option( WC_Facebookcommerce_Integration::SETTING_MESSENGER_LOCALE, 'fr-FR' ); - - $locale = $this->integration->get_messenger_locale(); - - $this->assertEquals( 'es-ES', $locale ); - } - - /** - * Tests get messenger greeting with no filters and no options set, returns - * default greeting text which is also not truncated @see WC_Facebookcommerce_Integration::get_messenger_greeting_max_characters() - * - * @return void - */ - public function test_get_messenger_greeting_no_filter_no_options() { - remove_all_filters( 'wc_facebook_messenger_greeting' ); - delete_option( WC_Facebookcommerce_Integration::SETTING_MESSENGER_GREETING ); - - $greeting = $this->integration->get_messenger_greeting(); - - $this->assertEquals( 'Hi! We\'re here to answer any questions you may have.', $greeting ); - } - - /** - * Tests get messenger greeting with no filters but the message exceeds characters - * limit so is truncated to the default 80 characters in length @see WC_Facebookcommerce_Integration::get_messenger_greeting_max_characters() - * - * @return void - */ - public function test_get_messenger_greeting_truncated_no_filter() { - remove_all_filters( 'wc_facebook_messenger_greeting' ); - add_option( - WC_Facebookcommerce_Integration::SETTING_MESSENGER_GREETING, - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pulvinar sit amet sit.' - ); - - $greeting = $this->integration->get_messenger_greeting(); - - $this->assertEquals( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pulvinar sit', $greeting ); - } - - /** - * Tests get messenger greeting with filter. - * - * @return void - */ - public function test_get_messenger_greeting_truncated_with_filter() { - add_filter( - 'wc_facebook_messenger_greeting', - function ( $greeting ) { - return 'Updated with filter. ' . $greeting; - } - ); - add_option( - WC_Facebookcommerce_Integration::SETTING_MESSENGER_GREETING, - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum pulvinar sit amet sit.' - ); - - $greeting = $this->integration->get_messenger_greeting(); - - $this->assertEquals( 'Updated with filter. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ve', $greeting ); - } - - /** - * Tests get messenger greeting max characters returns default value when no filter is set. - * - * @return void - */ - public function test_get_messenger_greeting_max_characters_no_filter() { - remove_all_filters( 'wc_facebook_messenger_greeting_max_characters' ); - - $length = $this->integration->get_messenger_greeting_max_characters(); - - $this->assertEquals( 80, $length ); - } - - /** - * Tests get messenger greeting max character with filter which falls back to default - * if returned filter value is less than 1. - * - * @return void - */ - public function test_get_messenger_greeting_max_characters_with_filter_falls_back_to_default() { - add_filter( - 'wc_facebook_messenger_greeting_max_characters', - function ( $length ) { - return 0; - } - ); - - $length = $this->integration->get_messenger_greeting_max_characters(); - - $this->assertEquals( 80, $length ); - } - - /** - * Tests get messenger greeting max character with filter. - * - * @return void - */ - public function test_get_messenger_greeting_max_characters_with_filter() { - add_filter( - 'wc_facebook_messenger_greeting_max_characters', - function ( $length ) { - return 120; - } - ); - - $length = $this->integration->get_messenger_greeting_max_characters(); - - $this->assertEquals( 120, $length ); - } - - /** - * Tests get messenger color hex when no filters nor options are set. - * - * @return void - */ - public function test_get_messenger_color_hex_no_filter_no_options() { - remove_all_filters( 'wc_facebook_messenger_color_hex' ); - delete_option( WC_Facebookcommerce_Integration::SETTING_MESSENGER_COLOR_HEX ); - - $hex = $this->integration->get_messenger_color_hex(); - - $this->assertEquals( '#0084ff', $hex ); - } - - /** - * Tests get messenger color hex returns option value when no filter is set. - * - * @return void - */ - public function test_get_messenger_color_hex_no_filter() { - remove_all_filters( 'wc_facebook_messenger_color_hex' ); - add_option( - WC_Facebookcommerce_Integration::SETTING_MESSENGER_COLOR_HEX, - '#red' - ); - - $hex = $this->integration->get_messenger_color_hex(); - - $this->assertEquals( '#red', $hex ); - } - - /** - * Tests get messenger color hex uses filter. - * - * @return void - */ - public function test_get_messenger_color_hex_with_filter() { - add_filter( - 'wc_facebook_messenger_color_hex', - function ( $hex ) { - return '#green'; - } - ); - add_option( - WC_Facebookcommerce_Integration::SETTING_MESSENGER_COLOR_HEX, - '#red' - ); - - $hex = $this->integration->get_messenger_color_hex(); - - $this->assertEquals( '#green', $hex ); - } - /** * Tests product catalog id option update with valid catalog id value. * From 12c8f43bff121d3ee837b40e2f4aa3768aefd201 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Tue, 16 Apr 2024 16:09:06 +0200 Subject: [PATCH 27/32] Remove messenger functionality from FBE API and tests --- includes/API.php | 16 -- includes/API/FBE/Configuration/Messenger.php | 156 ------------------ .../API/FBE/Configuration/Read/Response.php | 8 - .../API/FBE/Configuration/Update/Request.php | 17 -- tests/Unit/ApiTest.php | 41 +---- 5 files changed, 1 insertion(+), 237 deletions(-) delete mode 100644 includes/API/FBE/Configuration/Messenger.php diff --git a/includes/API.php b/includes/API.php index d301c43ef..d61a9fc40 100644 --- a/includes/API.php +++ b/includes/API.php @@ -279,22 +279,6 @@ public function get_business_configuration( $external_business_id ) { return $this->perform_request( $request ); } - - /** - * Updates the messenger configuration. - * - * @param string $external_business_id external business ID - * @param API\FBE\Configuration\Messenger $configuration messenger configuration - * @return API\Response|API\FBE\Configuration\Update\Response - * @throws ApiException - */ - public function update_messenger_configuration( string $external_business_id, API\FBE\Configuration\Messenger $configuration ): API\FBE\Configuration\Update\Response { - $request = new API\FBE\Configuration\Update\Request( $external_business_id ); - $request->set_messenger_configuration( $configuration ); - $this->set_response_handler( API\FBE\Configuration\Update\Response::class ); - return $this->perform_request( $request ); - } - /** * Updates the plugin version configuration. * diff --git a/includes/API/FBE/Configuration/Messenger.php b/includes/API/FBE/Configuration/Messenger.php deleted file mode 100644 index eff65e1cc..000000000 --- a/includes/API/FBE/Configuration/Messenger.php +++ /dev/null @@ -1,156 +0,0 @@ - false, - 'default_locale' => '', - 'domains' => array(), - ) - ); - - $this->set_enabled( $data['enabled'] ); - $this->set_default_locale( $data['default_locale'] ); - $this->set_domains( $data['domains'] ); - } - - - /** - * Determines if messenger is enabled. - * - * @since 2.0.0 - * - * @return bool - */ - public function is_enabled() { - - return $this->enabled; - } - - - /** - * Gets the default locale. - * - * @since 2.0.0 - * - * @return string - */ - public function get_default_locale() { - - return $this->default_locale; - } - - - /** - * Gets the domains that messenger is configured for. - * - * @since 2.0.0 - * - * @return string[] - */ - public function get_domains() { - - if ( is_array( $this->domains ) ) { - $domains = array_map( 'trailingslashit', $this->domains ); - } else { - $domains = array(); - } - - return $domains; - } - - - /** - * Sets whether messenger is enabled. - * - * @since 2.0.0 - * - * @param bool $is_enabled whether messenger is enabled - */ - public function set_enabled( $is_enabled ) { - - $this->enabled = (bool) $is_enabled; - } - - - /** - * Sets the default locale. - * - * @since 2.0.0 - * - * @param string $locale default locale - */ - public function set_default_locale( $locale ) { - - $this->default_locale = (string) $locale; - } - - - /** - * Adds a domain to the list of approved domains. - * - * @since 2.0.0 - * - * @param string $domain domain to add - */ - public function add_domain( $domain ) { - - $domains = is_array( $this->domains ) ? $this->domains : array(); - - $domains[] = $domain; - - $this->set_domains( $domains ); - } - - - /** - * Sets the list of approved domains. - * - * @since 2.0.0 - * - * @param string[] $domains list of domains - */ - public function set_domains( array $domains ) { - - $this->domains = array_unique( array_filter( $domains, 'wc_is_valid_url' ) ); - } - - -} diff --git a/includes/API/FBE/Configuration/Read/Response.php b/includes/API/FBE/Configuration/Read/Response.php index f5af09639..5e4884e45 100644 --- a/includes/API/FBE/Configuration/Read/Response.php +++ b/includes/API/FBE/Configuration/Read/Response.php @@ -11,14 +11,6 @@ * FBE Configuration API read response object. */ class Response extends API\Response { - /** - * Gets the messenger configuration object. - * - * @return API\FBE\Configuration\Messenger - */ - public function get_messenger_configuration(): API\FBE\Configuration\Messenger { - return new API\FBE\Configuration\Messenger( $this->response_data['messenger_chat'] ?? [] ); - } /** * Is Instagram Shopping enabled? diff --git a/includes/API/FBE/Configuration/Update/Request.php b/includes/API/FBE/Configuration/Update/Request.php index d15c472f2..a3c76af72 100644 --- a/includes/API/FBE/Configuration/Update/Request.php +++ b/includes/API/FBE/Configuration/Update/Request.php @@ -36,23 +36,6 @@ public function __construct( $external_business_id ) { } - /** - * Sets the messenger configuration. - * - * Only the enabled and domains values are able to accept updates right now. - * - * @since 2.0.0 - * - * @param Configuration\Messenger $configuration messenger configuration object - */ - public function set_messenger_configuration( Configuration\Messenger $configuration ) { - - $this->data['messenger_chat'] = array( - 'enabled' => $configuration->is_enabled(), - 'domains' => $configuration->get_domains(), - ); - } - /** * Sets the plugin version for configuration update request. * diff --git a/tests/Unit/ApiTest.php b/tests/Unit/ApiTest.php index 559db7f56..961483d8c 100644 --- a/tests/Unit/ApiTest.php +++ b/tests/Unit/ApiTest.php @@ -2,7 +2,6 @@ declare( strict_types=1 ); use WooCommerce\Facebook\API; -use WooCommerce\Facebook\API\FBE\Configuration\Messenger; use WooCommerce\Facebook\Framework\Api\Exception as ApiException; /** @@ -208,7 +207,7 @@ public function test_get_business_configuration_returns_business_configuration_r $this->assertEquals( 'GET', $parsed_args['method'] ); $this->assertEquals( "{$this->endpoint}{$this->version}/fbe_business?fbe_external_business_id={$external_business_id}", $url ); return [ - 'body' => '{"business":{"name":"WordPress-Facebook"},"catalogs":[{"feature_instance_id":"562415265365817","enabled":true}],"catalog_feed_scheduled":{"enabled":false},"fb_shops":[{"feature_instance_id":"554457382898066","enabled":true}],"ig_cta":{"enabled":false},"ig_shopping":{"enabled":false},"messenger_chat":{"enabled":false},"messenger_chats":[{"enabled":false}],"messenger_menu":{"enabled":false},"page_card":{"enabled":false},"page_cta":{"enabled":false},"page_post":{"enabled":false},"page_shop":{"enabled":false},"pixels":[{"feature_instance_id":"762898101511280","enabled":true}],"thread_intent":{"enabled":false}}', + 'body' => '{"business":{"name":"WordPress-Facebook"},"catalogs":[{"feature_instance_id":"562415265365817","enabled":true}],"catalog_feed_scheduled":{"enabled":false},"fb_shops":[{"feature_instance_id":"554457382898066","enabled":true}],"ig_cta":{"enabled":false},"ig_shopping":{"enabled":false},"page_card":{"enabled":false},"page_cta":{"enabled":false},"page_post":{"enabled":false},"page_shop":{"enabled":false},"pixels":[{"feature_instance_id":"762898101511280","enabled":true}],"thread_intent":{"enabled":false}}', 'response' => [ 'code' => 200, 'message' => 'OK', @@ -219,48 +218,10 @@ public function test_get_business_configuration_returns_business_configuration_r $response = $this->api->get_business_configuration( $external_business_id ); - $configuration = $response->get_messenger_configuration(); - - $this->assertFalse( $configuration->is_enabled() ); $this->assertFalse( $response->is_ig_shopping_enabled() ); $this->assertFalse( $response->is_ig_cta_enabled() ); } - /** - * Tests update messenger configuration sends data to Facebook. - * - * @return void - * @throws ApiException In case of network request error. - */ - public function test_update_messenger_configuration_sends_message_configuration_update_request() { - $external_business_id = 'wordpress-facebook-62c3f1add134a'; - $configuration = new Messenger( - [ - 'enabled' => true, - 'default_locale' => '', - 'domains' => [ 'https://wordpress-facebook.ddev.site/' ], - ] - ); - - $response = function( $result, $parsed_args, $url ) use ( $external_business_id ) { - $this->assertEquals( 'POST', $parsed_args['method'] ); - $this->assertEquals( "{$this->endpoint}{$this->version}/fbe_business?fbe_external_business_id={$external_business_id}", $url ); - $this->assertEquals( '{"fbe_external_business_id":"' . $external_business_id . '","messenger_chat":{"enabled":true,"domains":["https:\/\/wordpress-facebook.ddev.site\/"]}}', $parsed_args['body'] ); - return [ - 'body' => '{"success":true}', - 'response' => [ - 'code' => 200, - 'message' => 'OK', - ], - ]; - }; - add_filter( 'pre_http_request', $response, 10, 3 ); - - $response = $this->api->update_messenger_configuration( $external_business_id, $configuration ); - - $this->assertTrue( $response->success ); - } - /** * Tests send item updates sends updates to Facebook. * From 868522a4393cd9d42659a49bafb5df3193360fbc Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:47:22 +0200 Subject: [PATCH 28/32] Change is messenger enabled to expectedIncorrectUsage --- .../WCFacebookCommerceIntegrationTest.php | 49 ++----------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/tests/Unit/WCFacebookCommerceIntegrationTest.php b/tests/Unit/WCFacebookCommerceIntegrationTest.php index e0b9d5e1a..0dcc65317 100644 --- a/tests/Unit/WCFacebookCommerceIntegrationTest.php +++ b/tests/Unit/WCFacebookCommerceIntegrationTest.php @@ -2771,55 +2771,12 @@ public function test_is_legacy_feed_file_generation_enabled_with_option() { } /** - * Tests is messenger enabled returns default value. + * Tests is messenger enabled returns the doing it wrong message * - * @return void - */ - public function test_is_messenger_enabled_no_filter_no_option() { - remove_all_filters( 'wc_facebook_is_messenger_enabled' ); - delete_option( WC_Facebookcommerce_Integration::SETTING_ENABLE_MESSENGER ); - - $result = $this->integration->is_messenger_enabled(); - - $this->assertFalse( $result ); - } - - /** - * Tests is messenger disabled no filter but with option still set. - * - * @return void - */ - public function test_is_messenger_enabled_no_filter() { - remove_all_filters( 'wc_facebook_is_messenger_enabled' ); - add_option( - WC_Facebookcommerce_Integration::SETTING_ENABLE_MESSENGER, - 'yes' - ); - - $result = $this->integration->is_messenger_enabled(); - - $this->assertFalse( $result ); - } - - /** - * Tests is messenger disabled enabled no option but with filter. - * - * @return void + * @expectedIncorrectUsage messenger_doing_it_wrong */ - public function test_is_messenger_enabled_with_filter() { - add_filter( - 'wc_facebook_is_messenger_enabled', - function ( $is_enabled ) { - return true; - } - ); - add_option( - WC_Facebookcommerce_Integration::SETTING_ENABLE_MESSENGER, - 'no' - ); - + public function test_is_messenger_enabled_doing_it_wrong() { $result = $this->integration->is_messenger_enabled(); - $this->assertFalse( $result ); } From fe752c099614a77c19aed4b128e7634a15a48772 Mon Sep 17 00:00:00 2001 From: Dima <9010963+message-dimke@users.noreply.github.com> Date: Mon, 22 Apr 2024 22:08:09 +0300 Subject: [PATCH 29/32] Adding php8.3 to GitHub workflow for unit tests. --- .github/workflows/php-unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php-unit-tests.yml b/.github/workflows/php-unit-tests.yml index dc1bec91e..a37abe4a6 100644 --- a/.github/workflows/php-unit-tests.yml +++ b/.github/workflows/php-unit-tests.yml @@ -30,7 +30,7 @@ jobs: WP_TESTS_DIR: "/tmp/wordpress/tests/phpunit" strategy: matrix: - php: [7.4, 8.0, 8.1, 8.2] + php: [7.4, 8.3] wp-version: [latest] steps: From 1520f579a98ed0270712cdeb06b930e47bc75fee Mon Sep 17 00:00:00 2001 From: Dima <9010963+message-dimke@users.noreply.github.com> Date: Tue, 23 Apr 2024 07:48:35 +0300 Subject: [PATCH 30/32] Adding php8.3 to GitHub workflow for PHPCS. --- .github/workflows/php-cs-on-changes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php-cs-on-changes.yml b/.github/workflows/php-cs-on-changes.yml index 94b82d7be..fedc8577c 100644 --- a/.github/workflows/php-cs-on-changes.yml +++ b/.github/workflows/php-cs-on-changes.yml @@ -16,7 +16,7 @@ jobs: timeout-minutes: 15 strategy: matrix: - php: [7.4, 8.2] + php: [7.4, 8.3] name: Code sniff (PHP ${{ matrix.php }}, WP Latest) permissions: contents: read From faa513fb234d9b3d745804a6faa266ad39a7f75d Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Wed, 1 May 2024 14:04:23 +0530 Subject: [PATCH 31/32] Product version bump update --- facebook-for-woocommerce.php | 4 ++-- package-lock.json | 2 +- package.json | 2 +- readme.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/facebook-for-woocommerce.php b/facebook-for-woocommerce.php index c19fc202a..cf73b0548 100644 --- a/facebook-for-woocommerce.php +++ b/facebook-for-woocommerce.php @@ -11,7 +11,7 @@ * 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. * Author: Facebook * Author URI: https://www.facebook.com/ - * Version: 3.1.15 + * Version: 3.2.0 * Requires at least: 5.6 * Text Domain: facebook-for-woocommerce * Tested up to: 6.5 @@ -44,7 +44,7 @@ class WC_Facebook_Loader { /** * @var string the plugin version. This must be in the main plugin file to be automatically bumped by Woorelease. */ - const PLUGIN_VERSION = '3.1.15'; // WRCS: DEFINED_VERSION. + const PLUGIN_VERSION = '3.2.0'; // WRCS: DEFINED_VERSION. // Minimum PHP version required by this plugin. const MINIMUM_PHP_VERSION = '7.4.0'; diff --git a/package-lock.json b/package-lock.json index ab995cdd1..9dd8c3cb7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "facebook-for-woocommerce", - "version": "3.1.15", + "version": "3.2.0", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index a2a89a9ef..ab88ee00e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "facebook-for-woocommerce", - "version": "3.1.15", + "version": "3.2.0", "author": "Facebook", "homepage": "https://woo.com/products/facebook/", "license": "GPL-2.0", diff --git a/readme.txt b/readme.txt index 4b7f81af3..f1b480f43 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: facebook, automattic, woothemes Tags: facebook, woocommerce, marketing, product catalog feed, pixel Requires at least: 4.4 Tested up to: 6.5 -Stable tag: 3.1.15 +Stable tag: 3.2.0 Requires PHP: 5.6 or greater MySQL: 5.6 or greater License: GPLv2 or later From 839bf33a1fdea56c2bddfd9d0168cf6bf60b586a Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Wed, 1 May 2024 14:04:33 +0530 Subject: [PATCH 32/32] Changelog update --- changelog.txt | 4 ++++ readme.txt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/changelog.txt b/changelog.txt index 8f45f24ea..d52ab8f8a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,9 @@ *** Facebook for WooCommerce Changelog *** += 3.2.0 - 2024-05-01 = +* Tweak - PHP8.3 to GitHub PHPCS and Unit Tests workflows. +* Update - Remove the sunsetted Messenger Chat feature. + = 3.1.15 - 2024-04-16 = * Tweak - Replace the middleware URL from connect.woocommerce.com to api.woocommerce.com/integrations. * Tweak - Test environment setup to resolve notice. diff --git a/readme.txt b/readme.txt index f1b480f43..1215f77a6 100644 --- a/readme.txt +++ b/readme.txt @@ -40,6 +40,10 @@ When opening a bug on GitHub, please give us as many details as possible. == Changelog == += 3.2.0 - 2024-05-01 = +* Tweak - PHP8.3 to GitHub PHPCS and Unit Tests workflows. +* Update - Remove the sunsetted Messenger Chat feature. + = 3.1.15 - 2024-04-16 = * Tweak - Replace the middleware URL from connect.woocommerce.com to api.woocommerce.com/integrations. * Tweak - Test environment setup to resolve notice.