Fix/variation field persistence & rich text description handling for variants#3269
Closed
devbodaghe wants to merge 10 commits intofacebook:mainfrom
Closed
Fix/variation field persistence & rich text description handling for variants#3269devbodaghe wants to merge 10 commits intofacebook:mainfrom
devbodaghe wants to merge 10 commits intofacebook:mainfrom
Conversation
373f4e2 to
8badfad
Compare
e64d62e to
107e22a
Compare
Contributor
|
@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
|
@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
|
@devbodaghe has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Contributor
|
@devbodaghe merged this pull request in 3c96826. |
Closed
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 PR fixes critical issues with Facebook product description handling for WooCommerce product variations, ensuring HTML content is properly preserved in rich text descriptions while maintaining plain text for regular descriptions.
Summary of Changes
🚨 Critical Fix - Preserve HTML Input in Variation Facebook Fields:
save_product_variation_edit_fields()inAdmin.phpwas usingsanitize_text_field()for both regular and rich text descriptionssanitize_text_field()(plain text only)wp_kses_post()(preserves safe HTML)Form Display Improvements:
Enhanced Rich Text Description Method:
get_rich_text_description()method infbproduct.phpwith proper fallback chainfacebook_for_woocommerce_fb_rich_text_descriptionUpdated Tests:
Root Cause
The critical issue was in the variation save method using
sanitize_text_field()for both regular and rich text descriptions. This function strips ALL HTML tags, meaning users would enter formatted content with HTML (lists, bold text, links) but it would be completely removed upon saving, breaking the rich text functionality that's essential for proper Facebook product presentation.Solution
sanitize_text_field()for plain text safetywp_kses_post()to preserve safe HTML while sanitizing dangerous contentType of change
Checklist
Testing
Before/After
Before: User enters
<p>Product with <strong>bold</strong> text and <ul><li>Feature 1</li></ul></p>→ Saved asProduct with bold text and Feature 1After: User enters
<p>Product with <strong>bold</strong> text and <ul><li>Feature 1</li></ul></p>→ Saved as<p>Product with <strong>bold</strong> text and <ul><li>Feature 1</li></ul></p>Changelog entry
Fixed critical issue where HTML content was being stripped from Facebook rich text descriptions for product variations, ensuring proper formatting is preserved for Facebook product listings.