Created
March 20, 2015 12:06
-
-
Save wp-kitten/79233437569b637ece19 to your computer and use it in GitHub Desktop.
Prevents a WodPress Core Theme from being activated.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Prevents a WodPress Core Theme from being activated. | |
* | |
* As a Theme Framework, it provides all the help and functionality child themes need, but child themes | |
* should be activated instead. | |
* | |
* This should go into the Core Theme's functions.php file | |
*/ | |
if(! class_exists('CORE-THEME-MAIN-CLASS-NAME')) { | |
add_action('after_switch_theme', '_core_prevent_activation', 10, 2); | |
function _core_prevent_activation($oldThemeName, $oldTheme) | |
{ | |
add_action('admin_notices', '_core_do_not_activate'); | |
function _core_do_not_activate() | |
{ | |
echo '<div class="update-nag">'; | |
_e('Theme not activated: the Core Theme is a Theme Framework. Activate the child theme instead!<br/> | |
For now, the previous theme was reactivated.', 'text-domain'); | |
echo '</div>'; | |
} | |
// Revert to the previous used theme | |
switch_theme($oldTheme->stylesheet); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment