Open
Conversation
Contributor
|
@sol-loup has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
📦 Latest Plugin BuildBuilt at: 2025-05-27T16:51:01.478Z Download: Click here to download the plugin To download: Click the link above → Scroll to bottom → Download "facebook-for-woocommerce" artifact |
Contributor
|
@sol-loup has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This change fixes a bug where the "Product sync" button and associated title were appearing twice on the Product Sync settings page (
wp-admin/admin.php?page=wc-facebook&tab=product_sync) when enhanced onboarding is active.The root cause was identified in the
Enhanced_Settingsclass. Its constructor was correctly instantiating the settings screen objects (includingSettings_Screens\Product_Sync) and storing them in$this->screens. However, it was also incorrectly hooking itsbuild_menu_item_arraymethod to theadmin_menuaction. This causedbuild_menu_item_arrayto be executed a second time when theadmin_menuaction fired, leading to a second instantiation ofSettings_Screens\Product_Sync.As a result, the constructor of
Settings_Screens\Product_Sync(which adds WordPress actions for rendering custom setting fields likewoocommerce_admin_field_product_sync_title) was running twice. This duplicated the action hook forrender_title, causing the "Sync products" button and its surrounding elements (originally including an H2 title) to be rendered twice when WooCommerce processed that settings field.The fix removes the redundant
add_action( 'admin_menu', array( $this, 'build_menu_item_array' ) );from theEnhanced_Settingsconstructor. Thebuild_menu_item_arraymethod is now only called once at construction time to populate$this->screens, ensuring that each settings screen (and its associated action hooks) is initialized only once.Type of change
Checklist
Changelog entry
Fix: Prevent duplicate "Product sync" button on settings page when enhanced onboarding is active.
Test Plan
wp-admin/admin.php?page=wc-facebook&tab=product_sync.Screenshots
Enhanced_settings = true

Enhanced_settings = false (identical)

Broken state (previous)

Before
(Ideally, a screenshot showing the "Product sync" button and title appearing twice)
After
(Ideally, a screenshot showing the "Product sync" button and title appearing once after the fix)