There’re several filters that you can utilize:
Custom column content
If you got a custom column that you added with the “-filter, then you can use the
manage_{$post->post_type}_posts_custom_column
filter to alter the content. If you only want to target non-hierarchial post types then there’s as well the manage_posts_custom_column
and for hierarchical ones, there’s manage_pages_custom_column
. All three filters have two arguemnts: $column_name, $post->ID
.
For the media library there’s a special filter: manage_media_custom_column
.
Removing actions
IIRC, there’s the following filter to add or remove different actions:
apply_filters( 'bulk_actions-' . $this->screen->id, $this->_actions );
You should be able to obtain the screen ID from get_current_screen()->ID
.
For the media library it’s – again – a special case and you have to use the
apply_filters( 'media_row_actions', $actions, $post, $this->detached );
filter.
Make sure that you don’t use $this->
inside your callback arguments as you’re not in object context.
Removing the image link
So far there’s no possibility to completely remove the <a href="" ...
tag without a lot of effort. But you can (simply) set the link target to the current page with using the get_edit_post_link
-filter.
Just re-target it to sprintf( '#post-%s', $post_id );
:
add_filter( 'get_edit_post_link', 'wpse107783_remove_media_icon_link', 20, 2 );
function wpse107783_remove_media_icon_link( $url, $post_id )
{
if ( 'upload' !== get_current_screen()->id )
return $url;
return sprintf( '#post-%s', $post_id );
}
Why not CSS or JS?
Still people could remove event listeners or CSS rules via their developer tools, which is something you might not want.
Redirect
A real lock out can only happen server side based on roles and capabilities.
add_action( 'template_redirect', 'wpse107783_redirect_media_edit' );
function wpse107783_redirect_media_edit()
{
if (
! is_admin()
OR 'attachment' !== get_current_screen()->id
)
return;
exit( wp_redirect( admin_url() ) );
}
Note: I’m not sure if template_redirect
is the right hook here. It might as well be admin_menu
or init
.