WordPress 3.3 Deprecates Contextual Help
WordPress version 3.3 has completely changed how contextual help is handled. The old contectual help function has been deprecated and replaced with a new add_help_tabs() function. Until WordPress 3.3 has been widely adopted, Plugin developers should provide help that will display in both the new version and older ones.
One way to do this is to create one function that generates contextual help which can be used by either method, then call it depending on the WordPress version.
// When the plugin loads
if ( version_compare($wp_version, '3.3' >= 0) ) {
add_action("admin_head", array($this, 'add_help_tab'));else add_action('contextual_help', array($this, 'add_contextual_help'), 10, 1 );
}
// WP 3.3
function add_help_tab() {
$screen = get_current_screen();$help = $this->contextual_help($screen->id);if ( !$help ) return;
$screen->add_help_tab($help);
}
// add contextual help prior to WP 3.3
function add_contextual_help($contextual_help = "") {
if ( method_exists($this, 'contextual_help') ){
$current_screen = get_current_screen();$screen_id = $current_screen->id;$content = $this->contextual_help($screen_id);
if ( $content ) {
$help = '';if ( is_array($content) ) $help = $value['content'];
else $help = $content;
$contextual_help = $help.$contextual_help;
}
return $contextual_help;
}
// Create help content
function contextual_help($screen_id) {
$help = false
switch ( $screen_id ) {
// content for the plugin admin page
case ( $this->screen_id ):
$content = ...
$id = ...
$title = ...
break;
// content for post or page screens
case ( 'post' ):
case ( page' ):
$content = ...
$id = ...
$title = ...
break;
}
if ( $help ) return array('id'=>$id, 'title'=>$title, 'content'=>$content);
else return false;
}
