Automating deprecated call checks?

The question:

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?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

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: (will be on soon)

Once activated, browse to the Tools administration menu.

Method 2

Ehm, Theme Check plugin? 🙂 It is set up for themes, but easy enough to make use of parts:

require WP_PLUGIN_DIR . '/theme-check/checkbase.php';
$check = new Deprecated();
$path  = 'c:serverwwwdevwp-contentpluginsdeprecated.php';
$files = array( $path => php_strip_whitespace( $path ) );
$check->check( $files, array(), array() );
var_dump( $check->getError() );

Note that it has lists of deprecated functions hardcoded, which might or might not be enough for your needs.

Method 3

Well, the longest bit is going to be getting together a list of all the deprecated functions. has a page for it here, but since that may or may not be current I would suggest going through the 5 listed files and searching for “function” to get a better list. Once you have the list together in a text file (one function name per line), put that text file into /wp-content and run this command from that directory (assuming *nix and ssh) – grep -rnf deprecatedfunctionlist.txt ./ > files.txt
That will recursively search the /wp-content directly and output a text file in that directory listing the files and lines (with line numbers) those functions appear on. This way you can see exactly which functions reside in which files. I’m sure there’s a more elegant solution, but this should get you started!

Method 4

As Theme Checker is no longer supported, we can use new “Log Deprecated Notices” plugin.

After install, just go to “Tools -> Deprecated Calls”

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment