WP-Mix

A fresh mix of code snippets and tutorials

Disable theme switching

By default WordPress enables users to switch themes while working in the Admin area. Sometimes a user might screw this up and accidentally activate the wrong theme.

To prevent this, add the following code to your functions.php file:

function remove_theme_menus() {
	global $submenu;
	unset($submenu['themes.php'][5]);
	unset($submenu['themes.php'][15]);
}
add_action('admin_init', 'remove_theme_menus');

Technically theme switching will still be possible, but this code will prevent mistakes by disabling WordPress theme menus. Good times.

Learn more

Digging Into WordPressWordPress Themes In DepthWizard’s SQL Recipes for WordPress