Indexing is broken when plugins output directly during post content
Describe the bug
If a plugin has a shortcode that outputs directly rather than returning content, or tries to hook in to display extra output at a later date ( e.g. Gravity Forms ). This breaks the output of syncing and can stop the sync if it was triggered in the Admin UI
Steps to Reproduce
- install a plugin that echo's rather than returns its content in a shortcode or block
- use that in a post
- Trigger an index from WP Admin
- Watch as it fails to parse the output due to the stray HTML, and syncing stops
Screenshots, screen recording, code snippet
No response
Environment information
No response
WordPress and ElasticPress information
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
We will need a specific (free) plugin with specific steps for this one, @tomjn, as the documentation specifically states that:
Note that the function called by the shortcode should never produce an output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode.
Indeed I'm a strong proponent of that, unfortunately lots of new WP devs are unfamiliar with this, I've even had some outright rebel in disbelief when I tell them :( . An output buffer should suffice to mitigate this in the meantime.