Fix: Apply WordPress filters to post content, excerpt, and title in get_fb_description() #3685
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
Fixes #1712
Previously,
get_fb_description()was directly accessing post properties ($post->post_content,$post->post_excerpt,$post->post_title) which bypassed WordPress and third-party plugin filters.This caused issues when plugins used filters like
the_content,the_excerpt, orget_the_titleto modify product descriptions, as these modifications were not reflected in the Facebook catalog.Changes Made
$post->post_contentwithapply_filters('the_content', $post->post_content)$post->post_excerptwithget_the_excerpt($post)$post->post_titlewithget_the_title($post)This ensures that all WordPress filters are properly applied and third-party plugins that modify post content, excerpts, or titles will now work correctly with Facebook product descriptions.
Type of change
Checklist
Changelog entry
Fix - Apply WordPress filters to post content, excerpt, and title when generating Facebook product descriptions
Test Plan
Manual Testing Steps:
Install a plugin that modifies product titles using WordPress filters (or add this code to functions.php):
Create or edit a WooCommerce product
Sync the product to Facebook catalog
Verify the modified title (with "Modified: " prefix) appears in Facebook Commerce Manager
Remove the test filter and verify normal titles work correctly
Expected Behavior:
Before: Product titles/descriptions in Facebook catalog ignored WordPress filters
After: Product titles/descriptions in Facebook catalog properly apply all WordPress filters, allowing third-party plugins to modify the content sent to Facebook
Compatibility:
Related Issues
Closes #1712 (reported November 2020 - 5 years old!)