Skip to content

Instantly share code, notes, and snippets.

@vyskoczilova
Created October 9, 2020 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyskoczilova/b4ea5e4be68aeae6bed3603811561b6f to your computer and use it in GitHub Desktop.
Save vyskoczilova/b4ea5e4be68aeae6bed3603811561b6f to your computer and use it in GitHub Desktop.
Check if theme exists and is active or die
<?php
/**
* Plugin Name: Theme Guard
* Plugin URI: https://kybernaut.cz/?p=3204
* Description: Check if theme exists and is active or die.
* Version: 0.0.1
* Author: Karolína Vyskočilová
* Author URI: https://kybernaut.cz
* License: MIT
*/
add_action('init', function () {
$current = wp_get_theme();
$web = wp_get_theme('twentytwenty');
if (!$web->exists() || $current->name !== $web->name) {
wp_die('An error occured. We\'ll fix it ASAP.');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment