From f3d99318d0691f7ce08946e5559a2d2fc70d3985 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Tue, 28 May 2024 22:54:46 +0200 Subject: [PATCH 1/2] Move messenger constants into lifecycle class --- facebook-commerce.php | 12 ------------ includes/Lifecycle.php | 38 +++++++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/facebook-commerce.php b/facebook-commerce.php index 81113a46b..637be1c72 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -86,18 +86,6 @@ class WC_Facebookcommerce_Integration extends WC_Integration { /** @var string the scheduled resync offset setting ID */ const SETTING_SCHEDULED_RESYNC_OFFSET = 'scheduled_resync_offset'; - /** @var string the "enable messenger" setting ID */ - const SETTING_ENABLE_MESSENGER = 'wc_facebook_enable_messenger'; - - /** @var string the messenger locale setting ID */ - const SETTING_MESSENGER_LOCALE = 'wc_facebook_messenger_locale'; - - /** @var string the messenger greeting setting ID */ - const SETTING_MESSENGER_GREETING = 'wc_facebook_messenger_greeting'; - - /** @var string the messenger color HEX setting ID */ - const SETTING_MESSENGER_COLOR_HEX = 'wc_facebook_messenger_color_hex'; - /** @var string the "debug mode" setting ID */ const SETTING_ENABLE_DEBUG_MODE = 'wc_facebook_enable_debug_mode'; diff --git a/includes/Lifecycle.php b/includes/Lifecycle.php index fb39b909a..0160d05ab 100644 --- a/includes/Lifecycle.php +++ b/includes/Lifecycle.php @@ -22,6 +22,18 @@ */ class Lifecycle extends Framework\Lifecycle { + /** @var string the "enable messenger" setting ID */ + const SETTING_ENABLE_MESSENGER = 'wc_facebook_enable_messenger'; + + /** @var string the messenger locale setting ID */ + const SETTING_MESSENGER_LOCALE = 'wc_facebook_messenger_locale'; + + /** @var string the messenger greeting setting ID */ + const SETTING_MESSENGER_GREETING = 'wc_facebook_messenger_greeting'; + + /** @var string the messenger color HEX setting ID */ + const SETTING_MESSENGER_COLOR_HEX = 'wc_facebook_messenger_color_hex'; + /** * Lifecycle constructor. @@ -119,10 +131,10 @@ private function migrate_1_9_settings() { 'fb_page_id' => \WC_Facebookcommerce_Integration::SETTING_FACEBOOK_PAGE_ID, 'fb_pixel_id' => \WC_Facebookcommerce_Integration::SETTING_FACEBOOK_PIXEL_ID, 'fb_pixel_use_pii' => \WC_Facebookcommerce_Integration::SETTING_ENABLE_ADVANCED_MATCHING, - 'is_messenger_chat_plugin_enabled' => \WC_Facebookcommerce_Integration::SETTING_ENABLE_MESSENGER, - 'msger_chat_customization_locale' => \WC_Facebookcommerce_Integration::SETTING_MESSENGER_LOCALE, - 'msger_chat_customization_greeting_text_code' => \WC_Facebookcommerce_Integration::SETTING_MESSENGER_GREETING, - 'msger_chat_customization_theme_color_code' => \WC_Facebookcommerce_Integration::SETTING_MESSENGER_COLOR_HEX, + 'is_messenger_chat_plugin_enabled' => self::SETTING_ENABLE_MESSENGER, + 'msger_chat_customization_locale' => self::SETTING_MESSENGER_LOCALE, + 'msger_chat_customization_greeting_text_code' => self::SETTING_MESSENGER_GREETING, + 'msger_chat_customization_theme_color_code' => self::SETTING_MESSENGER_COLOR_HEX, ); foreach ( $settings as $old_index => $new_index ) { @@ -208,11 +220,11 @@ protected function upgrade_to_2_0_0() { 'excluded_product_category_ids' => \WC_Facebookcommerce_Integration::SETTING_EXCLUDED_PRODUCT_CATEGORY_IDS, 'excluded_product_tag_ids' => \WC_Facebookcommerce_Integration::SETTING_EXCLUDED_PRODUCT_TAG_IDS, 'product_description_mode' => \WC_Facebookcommerce_Integration::SETTING_PRODUCT_DESCRIPTION_MODE, - 'enable_messenger' => \WC_Facebookcommerce_Integration::SETTING_ENABLE_MESSENGER, - 'messenger_locale' => \WC_Facebookcommerce_Integration::SETTING_MESSENGER_LOCALE, - 'messenger_greeting' => \WC_Facebookcommerce_Integration::SETTING_MESSENGER_GREETING, - 'messenger_color_hex' => \WC_Facebookcommerce_Integration::SETTING_MESSENGER_COLOR_HEX, - 'enable_debug_mode' => \WC_Facebookcommerce_Integration::SETTING_ENABLE_DEBUG_MODE, + 'enable_messenger' => self::SETTING_ENABLE_MESSENGER, + 'messenger_locale' => self::SETTING_MESSENGER_LOCALE, + 'messenger_greeting' => self::SETTING_MESSENGER_GREETING, + 'messenger_color_hex' => self::SETTING_MESSENGER_COLOR_HEX, + 'enable_debug_mode' => self::SETTING_ENABLE_DEBUG_MODE, ); foreach ( $settings_map as $old_name => $new_name ) { if ( ! empty( $settings[ $old_name ] ) ) { @@ -323,10 +335,10 @@ protected function upgrade_to_3_2_0() { } // Delete all messenger options - delete_option( \WC_Facebookcommerce_Integration::SETTING_ENABLE_MESSENGER ); - delete_option( \WC_Facebookcommerce_Integration::SETTING_MESSENGER_LOCALE ); - delete_option( \WC_Facebookcommerce_Integration::SETTING_MESSENGER_GREETING ); - delete_option( \WC_Facebookcommerce_Integration::SETTING_MESSENGER_COLOR_HEX ); + delete_option( self::SETTING_ENABLE_MESSENGER ); + delete_option( self::SETTING_MESSENGER_LOCALE ); + delete_option( self::SETTING_MESSENGER_GREETING ); + delete_option( self::SETTING_MESSENGER_COLOR_HEX ); } } From fa6b2e1519442475c86ed8b558fdfa4b7f615b75 Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Tue, 28 May 2024 22:55:09 +0200 Subject: [PATCH 2/2] Remove all messenger methods that just invoked doing_it_wrong --- facebook-commerce.php | 84 ------------------- .../WCFacebookCommerceIntegrationTest.php | 10 --- 2 files changed, 94 deletions(-) diff --git a/facebook-commerce.php b/facebook-commerce.php index 637be1c72..0623889d4 100644 --- a/facebook-commerce.php +++ b/facebook-commerce.php @@ -2472,64 +2472,6 @@ public function get_product_description_mode() { return $mode; } - /** - * Gets the configured Facebook messenger locale. - * - * @since 1.10.0 - * @deprecated 3.2.0 - * - * @return string - */ - public function get_messenger_locale() { - $this->messenger_doing_it_wrong(); - return 'en_US'; - } - - /** - * Gets the configured Facebook messenger greeting. - * - * @since 1.10.0 - * @deprecated 3.2.0 - * - * @return string - */ - public function get_messenger_greeting() { - $this->messenger_doing_it_wrong(); - return Helper::str_truncate( - __( "Hi! We're here to answer any questions you may have.", 'facebook-for-woocommerce' ), - $this->get_messenger_greeting_max_characters(), - '' - ); - } - - /** - * Gets the maximum number of characters allowed in the messenger greeting. - * - * @since 1.10.0 - * @deprecated 3.2.0 - * - * @return int - */ - public function get_messenger_greeting_max_characters() { - $this->messenger_doing_it_wrong(); - return 80; - } - - /** - * Gets the configured Facebook messenger color hex. - * - * This is used to style the messenger UI. - * - * @since 1.10.0 - * @deprecated 3.2.0 - * - * @return string - */ - public function get_messenger_color_hex() { - $this->messenger_doing_it_wrong(); - return '#0084ff'; - } - /** Setter methods ************************************************************************************************/ @@ -2694,32 +2636,6 @@ public function is_legacy_feed_file_generation_enabled() { return 'yes' === get_option( self::OPTION_LEGACY_FEED_FILE_GENERATION_ENABLED, 'yes' ); } - /** - * Determines whether the Facebook messenger is enabled. - * - * @since 1.10.0 - * @deprecated 3.2.0 - * - * @return bool - */ - public function is_messenger_enabled() { - $this->messenger_doing_it_wrong(); - return false; - } - - /** - * Show _doing_it_wrong for any deprecated public Messenger-related methods. - * - * @since 3.2.0 - */ - private function messenger_doing_it_wrong() { - _doing_it_wrong( - __FUNCTION__, - esc_html__( 'The Facebook Messenger chat plugin was deprecated in May 2024.', 'facebook-for-woocommerce' ), - '3.2.0' - ); - } - /** * Determines whether debug mode is enabled. * diff --git a/tests/Unit/WCFacebookCommerceIntegrationTest.php b/tests/Unit/WCFacebookCommerceIntegrationTest.php index 0dcc65317..3a0009f61 100644 --- a/tests/Unit/WCFacebookCommerceIntegrationTest.php +++ b/tests/Unit/WCFacebookCommerceIntegrationTest.php @@ -2770,16 +2770,6 @@ public function test_is_legacy_feed_file_generation_enabled_with_option() { $this->assertFalse( $result ); } - /** - * Tests is messenger enabled returns the doing it wrong message - * - * @expectedIncorrectUsage messenger_doing_it_wrong - */ - public function test_is_messenger_enabled_doing_it_wrong() { - $result = $this->integration->is_messenger_enabled(); - $this->assertFalse( $result ); - } - /** * Tests is debug mode enabled returns default value. *