Skip to content

Commit

Permalink
Fix child theme base path property (#27)
Browse files Browse the repository at this point in the history
* fix: Use get_stylesheet_directory instead of get_template_directory
* chore: Update ThemeProperties test
  • Loading branch information
o-samaras authored Feb 16, 2023
1 parent dd2ac0d commit eb14a9b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Properties/ThemeProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function __construct(string $themeDirectory)
}

$baseName = $theme->get_stylesheet();
$basePath = $theme->get_template_directory();
$basePath = $theme->get_stylesheet_directory();
$baseUrl = (string) trailingslashit($theme->get_stylesheet_directory_uri());

parent::__construct(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Properties/ThemePropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testBasic(): void
$themeStub->expects('get')->with($key)->andReturn($return);
}
$themeStub->expects('get_stylesheet')->andReturn($expectedBaseName);
$themeStub->expects('get_template_directory')->andReturn($expectedBasePath);
$themeStub->expects('get_stylesheet_directory')->andReturn($expectedBasePath);
$themeStub->expects('get_stylesheet_directory_uri')->andReturn($expectedBaseUrl);

Functions\expect('wp_get_theme')->with($expectedBasePath)->andReturn($themeStub);
Expand Down Expand Up @@ -109,7 +109,7 @@ public function testChildTheme(): void
$themeStub->shouldReceive('get')->zeroOrMoreTimes()->andReturnArg(0);

$themeStub->expects('get_stylesheet')->andReturn($expectedBaseName);
$themeStub->expects('get_template_directory')->andReturn($expectedBasePath);
$themeStub->expects('get_stylesheet_directory')->andReturn($expectedBasePath);
$themeStub->expects('get_stylesheet_directory_uri')->andReturn($expectedBaseUrl);

Functions\expect('wp_get_theme')->with($expectedBasePath)->andReturn($themeStub);
Expand Down

0 comments on commit eb14a9b

Please sign in to comment.