If you are frequently making changes to your WordPress blog, you have have become tired of having to go through a bunch of menus to delete an out of date or irrelevant post. With a simple edit to your functions.php file, you can add a “Move to Trash” button to your WordPress Admin bar for simple deletes.
Open your functions.php file and add the following code:
[php] // ————————————————————————–// Start Add Delete Button to Admin Bar
// ————————————————————————–
function fb_add_admin_bar_trash_menu() {
global $wp_admin_bar;
if ( !is_super_admin() || !is_admin_bar_showing() )
return;
$current_object = get_queried_object();
if ( empty($current_object) )
return;
if ( !empty( $current_object->post_type ) &&
( $post_type_object = get_post_type_object( $current_object->post_type ) ) &&
current_user_can( $post_type_object->cap->edit_post, $current_object->ID )
) {
$wp_admin_bar->add_menu(
array( ‘id’ => ‘delete’,
‘title’ => __(‘Move to Trash’),
‘href’ => get_delete_post_link($current_object->term_id)
)
);
}
}
add_action( ‘admin_bar_menu’, ‘fb_add_admin_bar_trash_menu’, 35 );
// ————————————————————————–
// End Add Delete Button to Admin Bar
// ————————————————————————–
[/php]
Note: Some of these functions are not of my own creation, simply things I have found along the way. If you are the author of this function, please let me know so I can properly credit you with your work!