Key points
- AI models learned from code of every era, including obsolete code.
- PHP_CodeSniffer with WordPress rules flags deprecated functions and unescaped output.
- Run on every commit, it keeps these mistakes out of production.
A coding assistant builds a WordPress block in seconds. It works, but on review we find get_page_by_title(), deprecated since WordPress 6.2, and an unescaped echo $title. Easy to miss by eye; a tool catches them every time.
Why AI suggests outdated code
Models were trained on years of tutorials and forum answers, many written for old WordPress versions. A function that appears in thousands of old examples looks “normal” to the model even when it is deprecated.
Set up PHPCS with WordPress rules
composer require --dev wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer
vendor/bin/phpcs --standard=WordPress-Extra wp-content/themes/mytheme
The report lists, line by line, deprecated functions, unescaped output (WordPress.Security.EscapeOutput), unsanitised input and unprepared SQL. Many style issues fix themselves with vendor/bin/phpcbf.
Set the minimum version
In a phpcs.xml at the project root, state your target WordPress version so deprecations are judged correctly:
<ruleset name="Project">
<rule ref="WordPress-Extra"/>
<config name="minimum_wp_version" value="6.4"/>
<exclude-pattern>vendor/*</exclude-pattern>
</ruleset>
Automate it
On our projects, PHPCS runs in GitHub Actions on every push: if unescaped output shows up, the deploy is blocked. AI-generated code goes through the same gate as hand-written code, without relying on anyone remembering to check.
FAQ
Does PHPCS replace human review?
No. It catches mechanical mistakes; logic, architecture and edge cases still need a developer.
Can I just tell the AI to avoid these?
Stating the WordPress version and requiring escaping helps. Only an automated check gives a guarantee.
Facing this on your site or app? We diagnose and fix it.



