Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
allow the default theme to be overridden when deactivating
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwach committed Nov 7, 2012
1 parent 24faba9 commit 215ffed
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions commentpress-core/class_commentpress_display.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,61 @@ function activate() {
*/
function deactivate() {

// switch to default theme
switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
// test for WP3.4...
if ( function_exists( 'wp_get_theme' ) ) {

// get Commentpress theme by default, but allow overrides
$target_theme = apply_filters(
'cp_restore_theme_slug',
WP_DEFAULT_THEME
);

// get the theme we want
$theme = wp_get_theme(

$target_theme

);

// if we get it...
if ( $theme->exists() ) {

// ignore if not allowed
//if ( is_multisite() AND !$theme->is_allowed() ) { return; }

// activate it
switch_theme(
$theme->get_template(),
$theme->get_stylesheet()
);

}

} else {

// use pre-3.4 logic
$themes = get_themes();
//print_r( $themes ); die();

// get default theme by default, but allow overrides
// NB, the key prior to WP 3.4 is the theme's *name*
$target_theme = apply_filters(
'cp_restore_theme_name',
WP_DEFAULT_THEME
);

// the key is the theme name
if ( isset( $themes[ $target_theme ] ) ) {

// activate it
switch_theme(
$themes[ $target_theme ]['Template'],
$themes[ $target_theme ]['Stylesheet']
);

}

}

}

Expand Down

0 comments on commit 215ffed

Please sign in to comment.