This evening I have added some changes for the upcoming WordPress v2.4 release which will help theme, plugin and site developers track down when they are using deprecated WordPress functions. This new functionality relies, in part, on the new WP_DEBUG flag being enabled before anything interesting happens. With the new flag enabled a USER_NOTICE php error will be raised for each call to a deprecated function and if a deprecated file is included by a plugin. The error messages include the replacement function name and the version in which the function was deprecated.
The changes also introduce a pair of new hooks,
deprecated_file_included, which could be used by a plugin to create a log of all the functions used and provide the developer with information of what files need updating to use the replacement functions. These new hooks will fire whenever a deprecated function/file is used even if WP_DEBUG is disabled to allow for a simple plugin to log the errors without triggering the actual error on a live site.
Props to docwhat and darkdragon/santosj for their work on this change.
For WordPress v2.4 I have introduced some changes to the way in which all of the generator tags present in the output from WordPress are generated.
The generator tags/comments were previously hard coded in the following items: Theme’s header.php, all of the feed generation files, the export generation process. I have now centralised the generation process into three functions in
wp_generator. The new functions provide an array of filters to enable you to modify the generator output or remove it completely if you so wish. The standard WordPress xhtml generator tag is now generated on the
wp_head hook rather than needing to be hard coded into the themes files – this does mean that themes with a generator tag in them will now have two but it does reduce the number of things a theme author need to remember to include in the theme files.
For example, if you are creating a HTML theme rather than an XHTML theme then you will want to add the following to your themes
functions.php file which will ensure that the default generator tag output by WordPress on the
wp_head hook is the HTML one:
Another use of the newly available filters is, for example, to enable you to hide the fact that your site is running WordPress or to mask the version of WordPress that you are running. In order to do this the new functions have a variety of filters available. As we have already seen there is a filter to enable you to determine the type of generator output in your theme, the other filters available are:
$type is the name of the specific generator type you want to filter/hide. You can hide all of the generators on your blog with one simple plugin containing the following code:
If you want to read more about the reasons behind these changes then please see the related trac tickets, #4803 and #5085, or read the code itself in the changeset .
As part of keeping track of the WordPress 2.4 development cycle I have started a series of WordPress weekly digests over on my other blog.
You can read the first one here: http://westi.wordpress.com/2007/09/30/wordpress-weekly-digest-24th-september-to-30th-september-2007/