Removing delete permanently button in uploading files media

How do I delete or remove the word Delete Permanently in uploading files? I wanted to remove this permanently so that the users won't keep deleting files which are not supposed to delete.

I use this code:

.button-link.delete-attachment{display:none}

But the problem of this, if the user uses the inspect element, they can just change it to display:block to show the delete button. Using CSS is not an option.

Is there a function code here to remove this? Or where can I find the core file in wp-admin folder, so that I could delete the div element manually?

Topic media-modal media-library attachments Wordpress

Category Web


This might do the trick!

css:

.media-sidebar .details .edit-attachment {
    display: none;
}
.media-sidebar .details .delete-attachment {
    display: none;
}

And this:

foreach( array( 'post.php', 'post-new.php' ) as $hook )
    add_action( "admin_print_styles-$hook", 'admin_styles_so_25894288');

function admin_styles_so_25894288() {
    global $typenow;
    if( 'post' !== $typenow )
        return;
    ?>
    <style>
        .media-sidebar .details .delete-attachment
        { 
            display: block; 
        }
        .media-sidebar .details .edit-attachment
        { 
            display: block; 
        }
    </style>
    <?php

}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.