There are a few changes in 0.9 which plugin developers need to be aware of. So here are some notes to help you get your plugins running under the new release.
Detecting version 0.9
First of all if you want to detect whether someone is running version 0.9 or higher you can use this code:
if (version_compare(bb_get_option('version'), '0.9-z', '>=')) { // Tell us what your name is! echo('This is bbPress version 0.9 or higher.'); }
Note: The “-z” on the end will make sure you catch all pre-release versions of bbPress 0.9 as well, like “0.9-dev”.
Removing deprecated function calls
There are a number of no-longer-used functions from previous versions that we provide backwards compatibility for in bb-includes/deprecated.php
. So you may not have noticed that your plugin is still using some of them. In version 0.9 we have made detecting your use of these a little easier by providing a way to report their use via PHP errors when they get called.
Just open up the file bb-includes/deprecated.php
and change the “BB_LOG_DEPRECATED” constant at the top of the file from the boolean false to true.
Now if one of the many deprecated functions gets called it will be written to the same place that your PHP errors are written (either an error log or to the screen). The errors will tell you which deprecated function was called and what to replace it with.
Removing deprecated constants
A whole bunch of PHP constants have been deprecated in this release in an attempt to standardise our naming of constants. For now we are providing backwards compatibility for the older constants, but you should check your own usage of these and change them to use the correct ones.
Unfortunately there is no way to log these to errors, so this is a manual find and replace task. Two arrays of constants and their replacements can be found in bb-settings.php
starting at line 304.
New “bb-plugins” directory for core plugins only
There is a new directory called bb-plugins
in the root of the bbPress codebase. This directory is reserved for plugins that are distributed with the core bbPress files. Third-party plugins should still be stored in a separate my-plugins
directory. Do not instruct users to install files in the bb-plugins
directory, they are functionally no different from each other, except that the bb-plugins directory has more potential to be destroyed during user upgrades. You have been warned!!!
Storage of active plugins and active theme in options
Formerly we stored active plugins in a serialized array where each plugin was identified using it’s relative path from the my-plugins
directory, e.g. “plugin.php” or “folder/plugin.php”. With the advent of core plugins there exists a need to differentiate between “core” and “user” plugins.
We are doing so by prefixing either “core#” or “user#” to the plugin, so the previous examples in the my-plugins
folder would become “user#plugin.php” and “user#folder/plugin.php” in the same serialized array.
Similarly we are changing the way the active theme is stored. Instead of saving the absolute path to the active them, instead we are simply storing it’s name, i.e. the name of the directory it is contained prefixed with either “core#” or “user#” depending on it’s location.
Plugin activation and deactivation hooks
The correct way to register a function to run on plugin activation is like this:
function foo() { echo 'bar!'; } bb_register_plugin_activation_hook(__FILE__, 'foo');
Provided that the file you are registering in is the base plugin file. Do not hardcode the plugin file name as users may move them into directories inside the plugins directory.
Registering a function to run on plugin deactivation is similar except you need to call bb_register_plugin_deactivation_hook()
Built-in avatar support
With the inclusion of built-in avatar support you may think that all the time you spent on that custom avatar plugin is wasted. But actually, it is quite the opposite. By incorporating avatar calls into the default templates and providing a fully pluggable and filterable get_avatars()
function, integrating avatars is actually easier than ever.
New plugin browser
One thing that might have slipped by without enough attention is the new plugin browser which was recently implemented. Go have a play and check out all of the newness.
Thanks…
And finally, a big thanks to all our plugin developers for contributing so much to the bbPress community. If you have any ideas about how we can help you build better plugins, then let us know.
related to the top image: Italian do it simple and better.
Nope, Europe do it in RockStar way ^_~