0

I am currently working on a WordPress-plugin to analyse post- and page-content. The plugin contains a php-function that read the post- and page-content across several different builder-plugins (such as Elementor). On top of that the function also reads the_content-filter and then combines all the content in a string which is then returned at the end of the function.

Even though the described method of reading the content works it has the big disadvantage that it needs to be extended in case that we want to add more page-builder-plugins to the plugin. This leads me to the question of whether anybody knows of a different way for reading post- and page-content across all possible builder-plugins without using a specific request for each page-builder.

I though of using a cUrl-request for the selected page. The downside of that would be that we could not analyse the content via cronjob for private pages that are only visible to admins of the website. I am therefore looking for a different way to accomplish that. Does anybody know how to do this the easy way? Any help would be appreciated. Thanks in advance.

2
  • There's a task underneath this that's not shared, an X Y problem. While this is an interesting question, it's very likely that an unrelated solution could solve your problem that has nothing to do with your question, but would never be found here because you don't share what your analysis is or what you're trying to do that requires this
    – Tom J Nowell
    Commented Aug 21, 2023 at 16:25
  • @TomJNowell thank you for your input. I will try to do better in the future.
    – Dennis
    Commented Aug 22, 2023 at 21:20

1 Answer 1

1

None, it is not possible to avoid the_content filter for what you're trying to do. The only foolproof method is to analyse the final HTML that's presented.

Page builders rely on different mechanisms to intercept how WordPress presents the content and without knowing how those page builders work you can only rely on the final result for full analysis.

The closest to an official framework or API for this in WordPress is blocks, but page builders don't use blocks internally, and blocks themselves can be dynamic PHP rendered. You also have non-block non-page builder functionality such as widgets and shortcodes, as well as filters that add content.

This leads me to the question of whether anybody knows of a different way for reading post- and page-content across all possible builder-plugins without using a specific request for each page-builder.

The only way to do this is to render the page as if you're a user. Either by making a HTTP request, or by using the_content filter.

1
  • 1
    Thank you for your response. I added the HTTP-request which seems to be working for now. I marked this response as the correct answer. Thank you again!
    – Dennis
    Commented Aug 22, 2023 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.