Support » Plugin: Unattach and Re-attach Media Attachments » How to make the invisible menu
3 years, 6 months ago
Hi there, cool plugin 🙂
Just a heads up here:
//this is hacky but couldn't find the right hook
add_submenu_page('tools.php', 'Unattach Media', 'Unattach', 'upload_files', 'unattach', 'uar__unattach_attachment');
Simply add it to options.php (or null) and it will be invisible.
I already had the Re-attach feature in a plugin of mine and am shamelessly copying your unattach functions.
It’s good practice to secure all our actions. This is what I did:
In the column display use this URL
$url_unattach = wp_nonce_url(
admin_url( 'admin.php?page=unattach&noheader=true&post_id=' . $post->ID ),
And in the submenu callback, put this at first
check_admin_referer( 'my_nonce_name' );
It’s a pity that bulk actions can only be removed . I’ll report back if I have any suggestions on this.
Ok, final touch. You don’t need to check for is_admin() in the following, one because it’s already targeting upload.php and the other is already an admin_* action and can be targeted as well:
add_action( 'load-upload.php', 'bulk_action') );
add_action( 'admin_footer-upload.php', '_admin_footer') );