After building websites for clients with WordPress, I’ve noticed a recurring problem: clients love to explore the admin panel. Some of the more curious ones go ahead and switch to a different WordPress theme, and then… disaster strikes. So here’s a method to disable theme switching in the WordPress admin panel.
/*
Plugin Name: Disable WordPress Theme Switching
Plugin URI: https://imzl.com/wordpress-disable-background-theme-switching.html
Description: WordPress Tips: Disable WordPress Theme Switching
Version: 0.1
Author: Len Chou
Author URI: http://imzl.com
*/
add_action('admin_init', 'wplg_lock_theme');
function wplg_lock_theme() {
global $submenu;
unset($submenu['themes.php'][5]);
unset($submenu['themes.php'][15]);
}
Copy and paste the above code into a .php file and upload it to the plugins directory to activate, or paste it directly into your current theme’s functions.php file. (If pasting into functions.php, you must remove the opening <?php and the closing ?> — otherwise you’ll run into trouble.)