Created
August 26, 2021 15:03
-
-
Save anythinggraphic/833bc638dcb5a55ec153139130637898 to your computer and use it in GitHub Desktop.
WordPress: Redirect the Plugins and Plugins > Add New pages to the WP Admin Dashboard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WP Admin Page Redirects. | |
* | |
* Redirect the Plugins and Plugins > Add New pages to the WP Admin Dashboard in | |
* order to prevent the installation of plugins for overzealous editors. | |
* | |
* @since 1.0.0 | |
* | |
* @param object|null $my_current_screen Get the current screen object | |
*/ | |
add_action( | |
'current_screen', | |
function() { | |
$my_current_screen = get_current_screen(); | |
if ( isset( $my_current_screen->base ) && 'plugin-install' || 'plugins' === $my_current_screen->base ) { | |
wp_safe_redirect( admin_url() ); | |
exit(); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment