templates/ -> resources/views/
This commit is contained in:
@@ -13,5 +13,5 @@ insert_final_newline = true
|
|||||||
[*.php]
|
[*.php]
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
||||||
[templates/**.php]
|
[resources/views/**.php]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
### HEAD
|
### HEAD
|
||||||
* Rename `base.blade.php` to `app.blade.php` ([#1864](https://github.com/roots/sage/pull/1864))
|
* Move `templates/` to `resources/views/`, rename `base.blade.php` to `app.blade.php`, ([#1864](https://github.com/roots/sage/pull/1864))
|
||||||
* Add option to configure build settings ([#1822](https://github.com/roots/sage/pull/1822))
|
* Add option to configure build settings ([#1822](https://github.com/roots/sage/pull/1822))
|
||||||
* Add support for HTML injection ([#1817](https://github.com/roots/sage/pull/1817))
|
* Add support for HTML injection ([#1817](https://github.com/roots/sage/pull/1817))
|
||||||
|
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -53,13 +53,6 @@ During theme installation you will have the options to:
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
themes/your-theme-name/ # → Root of your Sage based theme
|
themes/your-theme-name/ # → Root of your Sage based theme
|
||||||
├── assets # → Front-end assets
|
|
||||||
│ ├── config.json # → Settings for compiled assets
|
|
||||||
│ ├── build/ # → Webpack and ESLint config
|
|
||||||
│ ├── fonts/ # → Theme fonts
|
|
||||||
│ ├── images/ # → Theme images
|
|
||||||
│ ├── scripts/ # → Theme JS
|
|
||||||
│ └── styles/ # → Theme stylesheets
|
|
||||||
├── composer.json # → Autoloading for `src/` files
|
├── composer.json # → Autoloading for `src/` files
|
||||||
├── composer.lock # → Composer lock file (never edit)
|
├── composer.lock # → Composer lock file (never edit)
|
||||||
├── dist/ # → Built theme assets (never edit)
|
├── dist/ # → Built theme assets (never edit)
|
||||||
@@ -75,7 +68,15 @@ themes/your-theme-name/ # → Root of your Sage based theme
|
|||||||
│ ├── helpers.php # → Helper functions
|
│ ├── helpers.php # → Helper functions
|
||||||
│ └── setup.php # → Theme setup
|
│ └── setup.php # → Theme setup
|
||||||
├── style.css # → Theme meta information
|
├── style.css # → Theme meta information
|
||||||
├── templates/ # → Theme templates
|
├── resources/ # → Theme assets and templates
|
||||||
|
├── ├── assets/ # → Front-end assets
|
||||||
|
│ │ ├── config.json # → Settings for compiled assets
|
||||||
|
│ │ ├── build/ # → Webpack and ESLint config
|
||||||
|
│ │ ├── fonts/ # → Theme fonts
|
||||||
|
│ │ ├── images/ # → Theme images
|
||||||
|
│ │ ├── scripts/ # → Theme JS
|
||||||
|
│ │ └── styles/ # → Theme stylesheets
|
||||||
|
│ └── views/ # → Theme templates
|
||||||
│ ├── layouts/ # → Base templates
|
│ ├── layouts/ # → Base templates
|
||||||
│ └── partials/ # → Partial templates
|
│ └── partials/ # → Partial templates
|
||||||
└── vendor/ # → Composer packages (never edit)
|
└── vendor/ # → Composer packages (never edit)
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ array_map(function ($file) use ($sage_error) {
|
|||||||
/**
|
/**
|
||||||
* Here's what's happening with these hooks:
|
* Here's what's happening with these hooks:
|
||||||
* 1. WordPress initially detects theme in themes/sage
|
* 1. WordPress initially detects theme in themes/sage
|
||||||
* 2. Upon activation, we tell WordPress that the theme is actually in themes/sage/templates
|
* 2. Upon activation, we tell WordPress that the theme is actually in themes/sage/resources/views
|
||||||
* 3. When we call get_template_directory() or get_template_directory_uri(), we point it back to themes/sage
|
* 3. When we call get_template_directory() or get_template_directory_uri(), we point it back to themes/sage
|
||||||
*
|
*
|
||||||
* We do this so that the Template Hierarchy will look in themes/sage/templates for core WordPress themes
|
* We do this so that the Template Hierarchy will look in themes/sage/resources/views for core WordPress themes
|
||||||
* But functions.php, style.css, and index.php are all still located in themes/sage
|
* But functions.php, style.css, and index.php are all still located in themes/sage
|
||||||
*
|
*
|
||||||
* This is not compatible with the WordPress Customizer theme preview prior to theme activation
|
* This is not compatible with the WordPress Customizer theme preview prior to theme activation
|
||||||
@@ -72,16 +72,16 @@ array_map(function ($file) use ($sage_error) {
|
|||||||
* get_stylesheet_directory() -> /srv/www/example.com/current/web/app/themes/sage
|
* get_stylesheet_directory() -> /srv/www/example.com/current/web/app/themes/sage
|
||||||
* locate_template()
|
* locate_template()
|
||||||
* ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage
|
* ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage
|
||||||
* └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/templates
|
* └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/resources/views
|
||||||
*/
|
*/
|
||||||
if (is_customize_preview() && isset($_GET['theme'])) {
|
if (is_customize_preview() && isset($_GET['theme'])) {
|
||||||
$sage_error(__('Theme must be activated prior to using the customizer.', 'sage'));
|
$sage_error(__('Theme must be activated prior to using the customizer.', 'sage'));
|
||||||
}
|
}
|
||||||
add_filter('template', function ($stylesheet) {
|
add_filter('template', function ($stylesheet) {
|
||||||
return dirname($stylesheet);
|
return dirname(dirname($stylesheet));
|
||||||
});
|
});
|
||||||
if (basename($stylesheet = get_option('template')) !== 'templates') {
|
if (basename($stylesheet = get_option('template')) !== 'resources/views') {
|
||||||
update_option('template', "{$stylesheet}/templates");
|
update_option('template', "{$stylesheet}/resources/views");
|
||||||
wp_redirect($_SERVER['REQUEST_URI']);
|
wp_redirect($_SERVER['REQUEST_URI']);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|||||||
24
phpcs.xml
24
phpcs.xml
@@ -6,7 +6,7 @@
|
|||||||
<file>functions.php</file>
|
<file>functions.php</file>
|
||||||
<file>index.php</file>
|
<file>index.php</file>
|
||||||
<file>src</file>
|
<file>src</file>
|
||||||
<file>templates</file>
|
<file>resources/views</file>
|
||||||
|
|
||||||
<!-- Show colors in console -->
|
<!-- Show colors in console -->
|
||||||
<arg value="-colors"/>
|
<arg value="-colors"/>
|
||||||
@@ -17,55 +17,55 @@
|
|||||||
<!-- Use PSR-2 as a base -->
|
<!-- Use PSR-2 as a base -->
|
||||||
<rule ref="PSR2"/>
|
<rule ref="PSR2"/>
|
||||||
|
|
||||||
<!-- Exclusions below are for templates/ folder -->
|
<!-- Exclusions below are for resources/views/ folder -->
|
||||||
|
|
||||||
<!-- Allow php files without any PHP in them -->
|
<!-- Allow php files without any PHP in them -->
|
||||||
<rule ref="Internal.NoCodeFound">
|
<rule ref="Internal.NoCodeFound">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Allow braces on same line for named functions -->
|
<!-- Allow braces on same line for named functions -->
|
||||||
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
|
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Allow closing braces to be on the same line -->
|
<!-- Allow closing braces to be on the same line -->
|
||||||
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace">
|
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Disable newline after opening brace -->
|
<!-- Disable newline after opening brace -->
|
||||||
<rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace">
|
<rule ref="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Allow multiple PHP statements in the same line -->
|
<!-- Allow multiple PHP statements in the same line -->
|
||||||
<rule ref="Generic.Formatting.DisallowMultipleStatements.SameLine">
|
<rule ref="Generic.Formatting.DisallowMultipleStatements.SameLine">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Disable PSR-2 indentation rules that are buggy with 2 spaces -->
|
<!-- Disable PSR-2 indentation rules that are buggy with 2 spaces -->
|
||||||
<rule ref="PSR2.ControlStructures.SwitchDeclaration.BreakIndent">
|
<rule ref="PSR2.ControlStructures.SwitchDeclaration.BreakIndent">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Don't require a blank line after the last `use` -->
|
<!-- Don't require a blank line after the last `use` -->
|
||||||
<rule ref="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse">
|
<rule ref="PSR2.Namespaces.UseDeclaration.SpaceAfterLastUse">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Allow long lines -->
|
<!-- Allow long lines -->
|
||||||
<rule ref="Generic.Files.LineLength.TooLong">
|
<rule ref="Generic.Files.LineLength.TooLong">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Ignore indentation rules -->
|
<!-- Ignore indentation rules -->
|
||||||
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
<rule ref="Generic.WhiteSpace.ScopeIndent">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- Allow PHP closing tags -->
|
<!-- Allow PHP closing tags -->
|
||||||
<rule ref="PSR2.Files.ClosingTag.NotAllowed">
|
<rule ref="PSR2.Files.ClosingTag.NotAllowed">
|
||||||
<exclude-pattern>templates</exclude-pattern>
|
<exclude-pattern>resources/views</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|||||||
@@ -9,5 +9,5 @@
|
|||||||
<footer>
|
<footer>
|
||||||
{!! wp_link_pages(['echo' => 0, 'before' => '<nav class="page-nav"><p>' . __('Pages:', 'sage'), 'after' => '</p></nav>']) !!}
|
{!! wp_link_pages(['echo' => 0, 'before' => '<nav class="page-nav"><p>' . __('Pages:', 'sage'), 'after' => '</p></nav>']) !!}
|
||||||
</footer>
|
</footer>
|
||||||
@php(comments_template('/templates/partials/comments.blade.php'))
|
@php(comments_template('/resources/views/partials/comments.blade.php'))
|
||||||
</article>
|
</article>
|
||||||
@@ -35,7 +35,7 @@ array_map(function ($type) {
|
|||||||
add_filter("{$type}_template_hierarchy", function ($templates) {
|
add_filter("{$type}_template_hierarchy", function ($templates) {
|
||||||
return call_user_func_array('array_merge', array_map(function ($template) {
|
return call_user_func_array('array_merge', array_map(function ($template) {
|
||||||
$transforms = [
|
$transforms = [
|
||||||
'%^/?(templates)?/?%' => config('sage.disable_option_hack') ? 'templates/' : '',
|
'%^/?(resources/views)?/?%' => config('sage.disable_option_hack') ? 'resources/views/' : '',
|
||||||
'%(\.blade)?(\.php)?$%' => ''
|
'%(\.blade)?(\.php)?$%' => ''
|
||||||
];
|
];
|
||||||
$normalizedTemplate = preg_replace(array_keys($transforms), array_values($transforms), $template);
|
$normalizedTemplate = preg_replace(array_keys($transforms), array_values($transforms), $template);
|
||||||
@@ -44,7 +44,7 @@ array_map(function ($type) {
|
|||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home',
|
'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home',
|
||||||
'frontpage', 'page', 'paged', 'search', 'single', 'singular', 'attachment'
|
'front_page', 'page', 'paged', 'search', 'single', 'singular', 'attachment'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -111,10 +111,12 @@ add_action('after_setup_theme', function () {
|
|||||||
'uri.stylesheet' => get_stylesheet_directory_uri(),
|
'uri.stylesheet' => get_stylesheet_directory_uri(),
|
||||||
'uri.template' => get_template_directory_uri(),
|
'uri.template' => get_template_directory_uri(),
|
||||||
];
|
];
|
||||||
$viewPaths = collect(preg_replace('%[\/]?(templates)?[\/.]*?$%', '', [STYLESHEETPATH, TEMPLATEPATH]))
|
$viewPaths = collect(preg_replace('%[\/]?(resources/views)?[\/.]*?$%', '', [STYLESHEETPATH, TEMPLATEPATH]))
|
||||||
->flatMap(function ($path) {
|
->flatMap(function ($path) {
|
||||||
return ["{$path}/templates", $path];
|
return ["{$path}/resources/views", $path];
|
||||||
})->unique()->toArray();
|
})->unique()->toArray();
|
||||||
|
|
||||||
|
// die(var_dump($viewPaths));
|
||||||
config([
|
config([
|
||||||
'assets.manifest' => "{$paths['dir.stylesheet']}/dist/assets.json",
|
'assets.manifest' => "{$paths['dir.stylesheet']}/dist/assets.json",
|
||||||
'assets.uri' => "{$paths['uri.stylesheet']}/dist",
|
'assets.uri' => "{$paths['uri.stylesheet']}/dist",
|
||||||
|
|||||||
Reference in New Issue
Block a user