Skip to content

Commit eb14a9b

Browse files
authoredFeb 16, 2023
Fix child theme base path property (#27)
* fix: Use get_stylesheet_directory instead of get_template_directory * chore: Update ThemeProperties test
1 parent dd2ac0d commit eb14a9b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎src/Properties/ThemeProperties.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function __construct(string $themeDirectory)
7272
}
7373

7474
$baseName = $theme->get_stylesheet();
75-
$basePath = $theme->get_template_directory();
75+
$basePath = $theme->get_stylesheet_directory();
7676
$baseUrl = (string) trailingslashit($theme->get_stylesheet_directory_uri());
7777

7878
parent::__construct(

‎tests/unit/Properties/ThemePropertiesTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testBasic(): void
5656
$themeStub->expects('get')->with($key)->andReturn($return);
5757
}
5858
$themeStub->expects('get_stylesheet')->andReturn($expectedBaseName);
59-
$themeStub->expects('get_template_directory')->andReturn($expectedBasePath);
59+
$themeStub->expects('get_stylesheet_directory')->andReturn($expectedBasePath);
6060
$themeStub->expects('get_stylesheet_directory_uri')->andReturn($expectedBaseUrl);
6161

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

111111
$themeStub->expects('get_stylesheet')->andReturn($expectedBaseName);
112-
$themeStub->expects('get_template_directory')->andReturn($expectedBasePath);
112+
$themeStub->expects('get_stylesheet_directory')->andReturn($expectedBasePath);
113113
$themeStub->expects('get_stylesheet_directory_uri')->andReturn($expectedBaseUrl);
114114

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

0 commit comments

Comments
 (0)
Please sign in to comment.