Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove/clean up messenger references #2754

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 0 additions & 96 deletions facebook-commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -2484,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 ************************************************************************************************/


Expand Down Expand Up @@ -2706,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.
*
Expand Down
38 changes: 25 additions & 13 deletions includes/Lifecycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 ] ) ) {
Expand Down Expand Up @@ -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 );
}

}
10 changes: 0 additions & 10 deletions tests/Unit/WCFacebookCommerceIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Loading