a8cteam51 / safety-net

Scrub options, deactivate denylisted plugins, and delete user data on development sites.
17 stars 1 forks source link

Add a filter to hide/disable the admin controls #68

Closed bernattorras closed 1 year ago

bernattorras commented 1 year ago

Description

As detailed in #43, it would be nice to be able to hide the Safety Net admin page (Tools > Safety Net) using a filter. This way, any developer (or us) could disable it easily by using the following code:

add_filter( 'safety_net_hide_admin', '__return_true' );

NickGreen commented 1 year ago

Most of the functions that you've allowed to be filtered out there are functions that we actually want to run, regardless of if the admin controls are showing or not. For example, add_filter( 'wp_mail', __NAMESPACE__ . '\stop_emails', 10, 1 ); is the function that stops emails.

I think the admin tools that he meant are the actual buttons and toggle at Tools > Safety Net, as seen here: Screen Shot on 2022-11-17 at 14:29:39

So what you'll probably want to do is only include the hooks in that filterable function which render the wp-admin menu item, the link on the plugins page, and the one that renders the Safety Net Tools page.

bernattorras commented 1 year ago

Thanks for the head-ups @NickGreen! Yeah, I missed these filters!

I'm a bit doubtful though about just hiding the controls... Would it make sense to have the Safety Net page available in the admin if you can't perform any actions from there? What would be the benefit? To check the possible features that aren't available for the user?

Markup 2022-11-22 at 13 25 07

I think that since we already display the admin notice in the backend (and pause the emails, scheduled actions, etc), we could directly hide the entire Safety Net options page, but that's just my opinion. :)

What do you think @nate-allen @NickGreen? Could you share your thoughts and possible cases to find out the best approach?

NickGreen commented 1 year ago

Yeah, I agree, it would be fine to hide the whole page and the links to the page (there's one in the Tools menu and one on the plugin page).

The main thing is that we don't want to stop all of the functions that load in admin, just the ones that render the page and menu items.

bernattorras commented 1 year ago

Thanks @nate-allen! Yeah, these are the ones that I had in my mind, but I just wanted to clarify first if we still needed to load the options page (without the controls) or hide it completely. 👍

nate-allen commented 1 year ago

We should hide it completely, even removing "Safety Net" link from the Tools menu.