Is there any solution, ide/tool etc., for automatic escaping for WordPress?

Is there any tool/ide etc. to escape WordPress theme/plugin files automatically? How can I do it with PhpStorm?

Topic escaping theme-development Wordpress

Category Web


A tool like PHP CodeSniffer, combined with the WordPress Coding Standards can be used to warn you if values are not being escaped. These warnings can be shown in the editor if the editor has a PHPCS extension of some kind (VS Code does, but I'm not sure about PhpStorm).

With PHPCS it's possible to automatically fix many issues using phpcbf, but I don't think the escaping rule is one of them. This is because the proper escaping function to use depends entirely on context, and an automated tool won't necessarily know which is appropriate. It would only know if one wasn't used.

Frankly, you'd be much better of learning the purpose of the various escaping functions and getting in the habit of using them, rather than relying on automated tools to secure your code.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.