Skip to content

Commit fb19145

Browse files
committed
Theme activation updates 'stylesheet' option instead of 'template'
1 parent 8c9ba05 commit fb19145

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

functions.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,21 @@
2020
* We do this so that the Template Hierarchy will look in themes/sage/templates for core WordPress themes
2121
* But functions.php, style.css, and index.php are all still located in themes/sage
2222
*
23-
* themes/sage/index.php also contains some self-correcting code, just in case the template option gets reset
23+
* get_template_directory() -> /srv/www/example.com/current/web/app/themes/sage
24+
* get_stylesheet_directory() -> /srv/www/example.com/current/web/app/themes/sage
25+
* locate_template()
26+
* ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage
27+
* └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/templates
2428
*/
25-
add_filter('stylesheet', function ($stylesheet) {
29+
add_filter('template', function ($stylesheet) {
2630
return dirname($stylesheet);
2731
});
2832
add_action('after_switch_theme', function () {
29-
$stylesheet = get_option('stylesheet');
33+
$stylesheet = get_option('template');
3034
if (basename($stylesheet) !== 'templates') {
31-
update_option('stylesheet', $stylesheet . '/templates');
35+
update_option('template', $stylesheet . '/templates');
3236
}
3337
});
34-
add_action('customize_render_section', function ($section) {
35-
if ($section->type === 'themes') {
36-
$section->title = wp_get_theme(basename(__DIR__))->display('Name');
37-
}
38-
}, 10, 2);
3938

4039
/**
4140
* Sage includes

index.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
<?php
22

3-
if (defined('ABSPATH')) {
4-
update_option('template', get_option('template') . '/templates');
5-
}
6-
die("Kind Regards,\nRoots");
3+
include __DIR__ . '/templates/index.php';

src/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function template_part($template, array $context = [], $layout = 'base')
2424
function asset_path($filename)
2525
{
2626
static $manifest;
27-
isset($manifest) || $manifest = new JsonManifest(get_template_directory() . '/' . Asset::$dist . '/assets.json');
27+
isset($manifest) || $manifest = new JsonManifest(get_stylesheet_directory() . '/' . Asset::$dist . '/assets.json');
2828
return (string) new Asset($filename, $manifest);
2929
}
3030

0 commit comments

Comments
 (0)