WordPress Plugin: Log Deprecated Calls

This is the Original™ “Log Deprecated” plugin for WordPress — a straightforward plugin that is of particular interest to fellow plugin authors. (Theme authors too!)

As WordPress changes over time, old functions and files are sometimes replaced with new ones. There is generally a transitional period during which the old functions (and files) are “deprecated”, which is basically an official statement to the effect of:

This function may go away in a future version of WordPress. It works for now, but you should really switch to using such-and-such new function instead, or your plugin/theme will stop working after some future update.

There is a functionality built-in to WordPress that allows you to flag deprecated functions, but it’s not terribly informative, and thus not very useful for plugin authors.

The plugin keeps track of any deprecated functions, files, or arguments called from code within WordPress plugins and themes. You can see the results in one of two ways: it either puts an entry in your PHP log, or logs it to the database and displays it on the plugin’s Admin screen. The entry is far more useful than the default WordPress log notice — this one tells you the name of the function, the exact file that called it, the line the call was on, and what new function, if any, you should use instead. It looks something like this:

WordPress: The ***deprecated function*** "some_old_function" was called from wp-content/plugins/myplugin/myplugin.php on line 170. Use "some_new_function" instead.

WP Log Deprecated Calls screenshot

By default, it logs deprecated calls to the PHP error log. You can change the settings in Admin.

(Andrew Nacin later wrote his own version of this plugin; he talks about the changes on his blog. Although he has some interesting changes, I believe the display of my version is more clear. His certainly is — by his own admission — an experiment in pushing the boundaries of hacking WordPress Core!)

Download

Current release v1.4

This plugin is available from GitHub: https://github.com/strider72/log-deprecated-calls/releases

27 Responses to WordPress Plugin: Log Deprecated Calls

  1. Pingback: Daily Digest for June 12th

  2. Pingback: New Plugin: Log Deprecated Notices | Andrew Nacin

  3. Pingback: Our WordPress Developer Toolbox | Geek is a Lift-Style.

  4. WAon, Very Usefull. Thank wp log deprecated developer 🙂

  5. Pingback: Elegant Design: A Case Study | Nerdaphernalia

  6. Stephen R says:

    There’s a new update — version 1.2. If you haven’t updated in a long time, this version is worth getting, as i recently added support for deprecated arguments in addition to functions and files.

    Note that there’s a change to the database structure, so your deprecated log will be reset.

    If you updated very recently, there’s an important bug fix.

    More to come. In the near future this should either become part of WordPress Extend (yay! automatic updates!), or have its own update mechanism built in (yay! Automatic updates!). Before that happens I want to improve database efficiency — right now it’s relatively bloated.

  7. Stephen R says:

    New update — 1.3 greatly improves database efficiency.

Leave a Reply

Your email address will not be published.