Skip to content

Commit

Permalink
fix theme folder when the original theme comes from a subfolder
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Jun 19, 2023
1 parent 83c94c4 commit cf3dc1c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions admin/create-theme/cbt-zip-archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ class CbtZipArchive extends ZipArchive {
private string $theme_slug;

function __construct( $theme_slug ) {
$this->theme_slug = $theme_slug;
// If the original theme is in a subfolder the theme slug will be the last part of the path
$complete_slug = explode( DIRECTORY_SEPARATOR, $theme_slug );
$folder = end( $complete_slug );
$this->theme_folder = $folder;
}

function addFromStringToTheme( $name, $content ) {
$name = $this->theme_slug . '/' . $name;
$name = $this->theme_folder . '/' . $name;
return parent::addFromString( $name, $content );
}

function addFileToTheme( $filepath, $entryname ) {
$entryname = $this->theme_slug . '/' . $entryname;
$entryname = $this->theme_folder . '/' . $entryname;
return parent::addFile( $filepath, $entryname );
}

function addThemeDir( $dirname ) {
$dirname = $this->theme_slug . '/' . $dirname;
$dirname = $this->theme_folder . '/' . $dirname;
return parent::addEmptyDir( $dirname );
}

Expand Down

0 comments on commit cf3dc1c

Please sign in to comment.