Use separate filter hooks for formatting and displaying content
|Reported by:||bungeshea||Owned by:|
The functions that format the post content are hooked to the_content filter. So if I wanted to format some text in the same way the post content is formatted, I'd use apply_filters( 'the_content', $text_to_format );
However, some plugins (especially social sharing buttons, Jetpack is an offender) hook to the_content to add additional output to the end of the post content. This really messes up when formatting text using the_content filter, as you get all of these social sharing buttons and related posts tacked onto the end of it. Currently the only way to safely format custom text is to apply the functions manually.
Instead, let's hook those formatting functions to a separate hook (eg: format_content), which is then applied to the post content along with the_content. New plugins can use the format_content hook to format their custom text, existing plugins don't break and everyone is happy.
Change History (1)
comment:1 SergeyBiryukov — 11 months ago
- Component changed from Formatting to Template
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Severity changed from trivial to normal
- Status changed from new to closed
- Summary changed from Use seperate filter hooks for formatting and displaying content to Use separate filter hooks for formatting and displaying content