Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions commands/internals/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public function activate($args = array()) {
exit;
}

$theme = array_shift( $args );
$child = array_shift( $args );

$stylesheet = WP_CONTENT_DIR . '/themes/' . $theme . '/style.css';
$stylesheet = $this->get_stylesheet_path( $child );

if ( !is_readable( $stylesheet ) ) {
WP_CLI::warning( 'theme not found' );
Expand All @@ -98,14 +98,22 @@ public function activate($args = array()) {

$details = get_theme_data( $stylesheet );

$child = $theme;
$parent = $details['Template'];
if ( empty( $parent ) )

if ( empty( $parent ) ) {
$parent = $child;
} elseif ( !is_readable( $this->get_stylesheet_path ( $parent ) ) ) {
WP_CLI::warning( 'parent theme not found' );
exit;
}

switch_theme( $parent, $child );
}

protected function get_stylesheet_path( $theme ) {
return WP_CONTENT_DIR . '/themes/' . $theme . '/style.css';
}

/**
* Help function for this command
*
Expand Down