-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove-theme-plugin-editor.php
More file actions
34 lines (29 loc) · 986 Bytes
/
remove-theme-plugin-editor.php
File metadata and controls
34 lines (29 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<php
/**
* Removes theme editor.
*/
function wpdocs_remove_menus(){
remove_submenu_page( 'themes.php', 'theme-editor.php' );
remove_submenu_page( 'plugins.php', 'plugin-editor.php' );
}
add_action( 'admin_menu', 'wpdocs_remove_menus', 999 );
function admin_page_theme_editor_manipulation(){
global $pagenow;
// echo $pagenow;
if ($pagenow == 'theme-editor.php' || $pagenow == 'plugin-editor.php') {
wp_redirect( admin_url( '/?action=editor-restricted-access' ) );
exit;
}
}
add_action('admin_init', 'admin_page_theme_editor_manipulation');
function file_editor_restricted_notice() {
global $pagenow;
if ($pagenow == 'index.php' && $_REQUEST['action'] == 'editor-restricted-access') {
?>
<div class="error notice is-dismissible">
<p><?php _e( 'Access to file editors has been restricted!, please contact your web developer.', 'whello' ); ?></p>
</div>
<?php
}
}
add_action( 'admin_notices', 'file_editor_restricted_notice' );