views:

80

answers:

3

Learning php, figure as well as following tutorials doing some practical useful stuff is import. So a wordpress plugin....

Trying to remove the favorite actions box that you get in the wordpress admin header.

<?php
/*
Plugin Name: Hide Favorite Actions
Plugin URI: http://www.mysite.com
Description: Allows you to remove the Screen Options and Help tabs from view
Author: Tai Havard
Version: 1.0
Author URI: 
*/

add_action('admin_menu','removeHelpAndScreenOptions');

function removeHelpAndScreenOptions()
{
remove_action('favorite_actions');  
}

?>

Plugins activated, function runs, I'm just not sure how to get hold of the favorite_actions correctly and wether remove_action is the correct function for use with the favorite_actions hook.

Thanks

+1  A: 

Here's how remove action works:

remove_action( 'hook_name', 'function_name' );

That says you want to remove the function function_name from the hook hook_name. I don't know what the hook and function are fore removing help and screen options, though. If I remember correctly, those tabs are hardcoded into the actual admin pages.

John P Bloch
Ok thanks, if their hard coded, back to the drawing board.
phantomdentist
Yeah, I double checked the code on this one. There are ways to remove the text from the help screen or screen options screen, but no way to actually remove the tabs.
John P Bloch
A: 

In your plugin just add

function rb_ax() {
return;
}
add_filter( 'favorite_actions', 'rb_ax' );

And you're done.

Francois
A: 

I used that code and got an error in a template.php (presumably expecting an array) THe box disappears if you return an with an empty element, something like this:

add_filter('favorite_actions', 'no_fav');
function no_fav($actions) {
    $actions = array(
        '' => array(__(''), '')
    );
    return $actions;
} 

I just deleted the strings, somebody could probably write a more elegant empty array.

p161