Here’s one idea:
/**
* Reactivate the sticky theme, if someone activates another theme.
*/
add_action( 'switch_theme', 'wpse_permanent_theme' );
function wpse_permanent_theme( $new_name )
{
$sticky_theme_name="twentyfifteen"; // Modify this to your needs!
// Get the sticky theme info, to check if it exists (named):
$sticky_theme = wp_get_theme( $sticky_theme_name );
// Reactivate the sticky theme:
if( $sticky_theme->get( 'Name' ) && $sticky_theme_name !== $new_name )
{
remove_action( current_action(), __FUNCTION__ );
switch_theme( $sticky_theme_name );
}
}
where you have to modify the sticky theme name to your needs. You may need to test this further.
Another thing to try out would be to remove the switch_themes
capability for all users!
For example, we can filter out this capability on the fly with:
/**
* Remove the 'switch_themes' capability for all users.
*/
add_filter('user_has_cap', function( $allcaps )
{
if( isset( $allcaps['switch_themes'] ) )
unset( $allcaps['switch_themes'] );
return $allcaps;
});
so the current_user_can( 'switch_themes' )
check during a theme activation in themes.php
returns false.