Peter Westwood: Making your broken Plugin work again with WordPress 2.8.1
238 Views Published 1 year, 1 month ago in WordpressWordPress 2.8.1 contains changes to improve the security of plugins by ensuring that only correctly registered plugin pages can be accessed as well as only showing the link to the page to users who have the capability required in the add_x_page call.
This change has broken a number of plugins which were adding there menus on the wrong action hook bypassing some capability checks.
The correct hook to use, as documented in the codex, is admin_menu. However, some plugins have successfully in the past been using admin_init but this meant that they bypassed some of the capability checking that WordPress does to help limit access to plugins pages.
This capability checking is there to help limit access to plugin added pages but plugins must always use current_user_can() to check the capability they require to ensure they prevent access to incapable users.
The code to look for in your plugins is something like this:
add_action('admin_init', 'my_plugin_menu');
function my_plugin_menu() {
add_options_page('My Plugin Options', 'My Plugin', 'manage_options', 'your-unique-identifier', 'my_plugin_options');
}
Which should be:
add_action('admin_menu', 'my_plugin_menu');
function my_plugin_menu() {
add_options_page('My Plugin Options', 'My Plugin', 'manage_options', 'your-unique-identifier', 'my_plugin_options');
}
And don’t forget while checking your plugin for this issue go and check to make sure you use current_user_can() to check user capabilities before allowing them to access your plugin page functionality.

Search
About This Entry
- You’re currently reading “Peter Westwood: Making your broken Plugin work again with WordPress 2.8.1,” an entry on The Staff Lounge
- Published at 7.15.09 / 7am
Related Entries
- Weblog Tools Collection: Bookmarklet to Quickly Access WordPress Admin Menu - Wordpress
- Peter Westwood: Introducing menu_page_url() - Wordpress
- Ryan: 2.8 Plugin Compatibility - Wordpress
- Weblog Tools Collection: WordPress Plugin Development Beginner’s Guide - Wordpress
- Weblog Tools Collection: WordPress Plugin Releases for 10/02 - Wordpress
Recent Entries
- Matt: Upcoming WordCamps - Wordpress
- Dougal Campbell: WordPress Care Package - Wordpress
- Weblog Tools Collection: WordPress Plugin Releases for 09/01 - Wordpress
- WordPress Podcast: Listen to Liz Strauss: “Treat Your Blog Like a Business!” - Wordpress
- Lorelle on WP: Mind Blowing WordPress Plugins - Wordpress
Popular Resources
- Phorum-5.2.8 final released (12 replies) - 46672 Views
- Phorum-5.2.9a released (10 replies) - 35707 Views
- IPB Resources - 21799 Views
- Weblog Tools Collection: WordPress Plugin Releases for 02/07 - 17672 Views
- Phorum-5.2.9 released! Security Upgrade! (no replies) - 13812 Views







This is right but may not be enough as you cannot add a menuitem for all php files
Still there is a trick :
http://www.lautre-monde.fr/wordpress-2-8-1-et-la-securite/
Basically, it is about turning on a global var thus allowing the page to be browsed…