Automating deprecated call checks?

I’ve recently started revamping and re-releasing some abandoned (yet important) WordPress plugins. As I walk through the code patching other bugs, my IDE highlights deprecated function calls for me, which is fantastic!

I fix them immediately when I find them and move on.

Anything I don’t catch is called out by a Log Deprecated Calls plugin or by setting WP_DEBUG to true.

But both of these approaches are highly ineffective. With one, I need to actually open the PHP file and manually scan through each line of code looking for a deprecated call. With the other, I need to wait for the deprecated call to be invoked by WP before it’s flagged by the system.

Is there an easier way or some tool I can use that scans through WP plugins and themes and identifies any use of deprecated functionality?

4 Answers
4

I was inspired by your question to create a plugin that I’ve been kicking the can on for several months. I’m calling it Deprecation Checker. By default, it scans the plugin and theme directories (recursively) to find deprecated functions. The functions list is sourced directly from the WP deprecated files.

It then outputs a nice list including line number, file path, old function, and recommended function to use in its place.

There are a couple of filters to add custom paths and custom deprecated functions for your own uses. You can also turn off plugin/theme directory scanning easily.

You can download it here: http://coderrr.com/deprecation-checker/ (will be on WP.org soon)

Once activated, browse to the Tools administration menu.

Leave a Comment