Hovering my mouse over a file name or a thumbnail brings up the Edit option, I want to know is there any hook to disable all edit links in Media library on Multisite
2 comments
Comments are closed.
Hovering my mouse over a file name or a thumbnail brings up the Edit option, I want to know is there any hook to disable all edit links in Media library on Multisite
Comments are closed.
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
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’smanage_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:
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
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 theget_edit_post_link
-filter.Just re-target it to
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.
Note: I’m not sure if
template_redirect
is the right hook here. It might as well beadmin_menu
orinit
.Add some CSS to admin_head to hide the image actions bar, and hide the edit button once clicking into the image:
This should do the trick: