WordPress Plugin: Log Deprecated Calls

This is a pretty straightforward plugin for WordPress 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 on this page, when activated, puts an entry in your PHP log any time a deprecated function is called, or a deprecated file is included. 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.

By default, it logs deprecated calls to the PHP error log. There is an admin screen (under the Plugins menu) that lets you toggle logging to the database, which, if activated, allows you to see the log on that same admin screen.

For plugin authors, it also serves as an example of how to use the new uninstall functionality coming up in WordPress 2.7. Simply put: if you use the Plugin Management page to delete this plugin, it will first clean up everything it did in the system, including clearing options, deleting the log table, and so forth….

Download

Here’s the link. Have at it!

Log Deprecated Calls v0.4

Is this download worth something to you? If you have found this plugin useful, please consider making a donation. Even as little as a dollar is appreciated:





24 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 :)

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>