Comments (8)
I just made an attempt (successful for now) to move required files to root directory. I'd like to share steps to reproduce this modified setup and issues I've come across. Maybe this will help with development.
Sage setup with required theme files in top-level directory
-
Move
index.php
,functions.php
,style.css
andscreenshot.png
to theme's root directory. -
Move
resources/views
to root (/views
). This is required for Page Templates to work because WordPress is looking for them only one level deeper thanstyle.css
is located.
Then, tell Sage where to look for view files. In config/views.php
:
'paths' => [
- get_theme_file_path().'/resources/views',
- get_parent_theme_file_path().'/resources/views',
+ get_theme_file_path().'/views',
+ get_parent_theme_file_path().'/views',
],
Additionally, until roots/sage#1980 is merged, fix template hierarchy in app/helpers.php
:
function filter_templates($templates)
return [
"{$path}/{$template}.blade.php",
"{$path}/{$template}.php",
- "{$template}.blade.php",
- "{$template}.php",
];
- });
+ })
+ ->concat([
+ "{$template}.blade.php",
+ "{$template}.php",
+ ]);
})
->filter()
->unique()
- In
functions.php
fix paths to loaded files:
Composer autoloader:
/**
* Ensure dependencies are loaded
*/
if (!class_exists('Roots\\Sage\\Container')) {
- if (!file_exists($composer = __DIR__.'/../vendor/autoload.php')) {
+ if (!file_exists($composer = __DIR__.'/vendor/autoload.php')) {
$sage_error(
__('You must run <code>composer install</code> from the Sage directory.', 'sage'),
__('Autoloader not found.', 'sage')
Sage required files:
/**
* Add or remove files to the array as needed. Supports child theme overrides.
*/
array_map(function ($file) use ($sage_error) {
- $file = "../app/{$file}.php";
+ $file = "./app/{$file}.php";
if (!locate_template($file, true, true)) {
$sage_error(sprintf(__('Error locating <code>%s</code> for inclusion.', 'sage'), $file), 'File not found');
}
Disable filter correcting paths to theme in default Sage setup:
-array_map(
- 'add_filter',
- ['theme_file_path', 'theme_file_uri', 'parent_theme_file_path', 'parent_theme_file_uri'],
- array_fill(0, 4, 'dirname')
-);
Paths to config files:
Container::getInstance()
->bindIf('config', function () {
return new Config([
- 'assets' => require dirname(__DIR__).'/config/assets.php',
- 'theme' => require dirname(__DIR__).'/config/theme.php',
- 'view' => require dirname(__DIR__).'/config/view.php',
+ 'assets' => require __DIR__.'/config/assets.php',
+ 'theme' => require __DIR__.'/config/theme.php',
+ 'view' => require __DIR__.'/config/view.php',
]);
}, true);
- Fix paths to controllers and models (if used).
Default directory in soberwp/controller and soberwp/models assume that required files are in resources
directory. This might change in future (soberwp/controller#54) but for now in app/setup.php
add:
/**
* Soberwp Models
*/
add_filter('sober/models/path', function () {
return get_theme_file_path() . '/app/models';
});
/**
* Soberwp Controller
*/
add_filter('sober/controller/path', function () {
return get_theme_file_path() . '/app/controllers';
});
That's it. Everything should be working now as expected. Hope this helps :-)
from sage-installer.
It would be great if a task to package theme (of using the WordPress installer) with all required dependencies is added so it can be directly invoked using yarn run (example: yarn run build:wordpress-installer-production).
from sage-installer.
Everyone who is interested in uploading roots-built sage theme to a normal wp-install on shared hosting ftp server setups should have a look at this script by @knowler. It's super neat tool for this. as easy as using one yarn command, uploading via ftp and activating the theme. voila.
https://github.com/knowler/sage-prep
from sage-installer.
Found it.
Update config/views.php
.
'paths' => [
get_theme_file_path().'/resources/views',
get_parent_theme_file_path().'/resources/views',
],
Remove /resources
from the paths.
from sage-installer.
@dmgawel Does this fix work at this point? From your EDIT note above I am gathering not.
from sage-installer.
@MikeiLL I've just updated my previous post. It now contains working solution :-)
from sage-installer.
Hey thanks @dmgawel I'm almost there.
However, illuminate/view/FileViewFinder.php
is looking for blades in
partials.page-headerArray
(
[0] => /var/www/html/wp-content/themes/MyTheme/resources/views
[1] => /var/www/html/wp-content/themes/MyTheme/resources/views
)
If I copy the views directory back there the theme loads, but that's obviously not the answer.
Is there config somewhere I missed? Asking at Roots Discourse as well. Thanks.
from sage-installer.
@MikeiLL thanks! Indeed, I have this change also in my code but forgot to include it. I'm going to edit my post and add it for future reference.
from sage-installer.
Related Issues (17)
- Laravel Mix HOT 12
- Tailwind CSS Preset
- Material Design Lite option HOT 2
- postCreateProject not executing HOT 2
- Add OpenCollective message after project creation
- Sage color needs updating
- Composer Installation on Windows HOT 6
- Prompt for user to open the theme folder before running yarn
- React and Vue presets
- Invalid scss in bulma preset HOT 4
- PHP cURL extension missing as required dependency
- stats.roots.io not found/down
- Failures during installation, but still installs
- Illuminate/Support composer suggestion for symfony/var-dumper
- postCreateProject interactivity on Windows platform non-existent HOT 2
- postCreateProject: Show warning/more info about local dev HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sage-installer.