Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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