Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite filtering logic using the DOM extension (instead of regular expressions) #58

Open
3 tasks
jan-san opened this issue Jul 10, 2019 · 0 comments
Open
3 tasks

Comments

@jan-san
Copy link
Collaborator

jan-san commented Jul 10, 2019

Trying to parse HTML with regular expressions is cumbersome, error-prone and ultimately futile.
A safer (and potentially more efficient) approach would be to use the DOM extension instead.

The DOM extension is not a hard requirement for running WordPress - based on a brief look into the code, all calls to DOM extension functionality in the WP core seem to be guarded with class_exists() checks to prevent errors. However, the extension is enabled in PHP by default (see here), and is listed as a required module for WordPress in the WP Extension Check command for WP-CLI.

The following would be necessary to move to the DOM extension:

  • (optional) Implement a performance check for the filter_*() functions (to get a before/after comparison)
  • Re-implement the filter_*() functions using the DOM extension
  • Add a check to the plugin that disables all functionality and shows a warning if the DOM extension is not active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant