Skip to content

Instantly share code, notes, and snippets.

@wildiney
Created June 22, 2011 16:59
Show Gist options
  • Save wildiney/1040557 to your computer and use it in GitHub Desktop.
Save wildiney/1040557 to your computer and use it in GitHub Desktop.
WordPress - Snippet to add a trash button on admin bar on Wordpress
<?php
/* Insert into functions.php on WordPress */
add_action('admin_bar_menu', 'fb_add_admin_bar_trash_menu', 35);
function fb_add_admin_bar_trash_menu(){
global $wp_admin_bar;
if(!is_super_admin() || !is_admin_bar_showing()){
return;
}
if(!empty($current_object->post_type) &&
($post_type_object = get_post_type($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)
)
);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment