timber / starter-theme

The "_s" for Timber: a dead-simple theme that you can build anything from
MIT License
812 stars 274 forks source link

Breakthrough in theme structure! #102

Closed szepeviktor closed 4 years ago

szepeviktor commented 4 years ago

Move all "WordPress files" under a subdirectory.

function _core_theme_subdir($directory) {
    return $directory . '/template';
}

add_filter('template_directory', '_core_theme_subdir', 11, 1);
add_filter('stylesheet_directory', '_core_theme_subdir', 11, 1);
add_filter('template_directory_uri', '_core_theme_subdir', 11, 1);
add_filter('stylesheet_directory_uri', '_core_theme_subdir', 11, 1);

So config (and other) files can jump around in the root and "WordPress files" in template/

szepeviktor commented 4 years ago

:) It turns out we need No code :)

$ wp eval 'var_export(search_theme_directories(true));'

array (
  'starter-theme/template' =>
  array (
    'theme_file' => 'starter-theme/template/style.css',
    'theme_root' => '/home/user/website/code/public/wp-content',
  ),
...
davidhund commented 4 years ago

👋🏻 I am just looking into using Timer and this Starter Theme. Should I expect this MR to be merged and the 'Wordpress files' be moved into their own folder? 😏

Also: I agree the template | templates names are confusing. Why not revert the Twig templates back to views and use templates for the 'Wordpress [PHP] files'?

./config
./templates/*.php
./views/*.twig

?

szepeviktor commented 4 years ago

Wordpress [PHP] files

plus the stylesheet, plus the screenshot ...

💻 🔫

davidhund commented 4 years ago

@szepeviktor I am a bit confused as to where the _core_theme_subdir function should go? Moving the stylesheet to a theme subfolder breaks the theme, so we need your _core_theme_subdir functions, but where do I place this, since functions.php etc. are also in that subfolder?

szepeviktor commented 4 years ago

Nowhere!

WordPress core by itself will detect the template in a theme subfolder. If you modify the active theme you need to reactivate it!

davidhund commented 4 years ago

If you modify the active theme you need to reactivate it!

🤪 Thanks!