mZoo
August 21, 2017, 11:14pm
1
I’m using Sage 9 without Bedrock. I’m actually Developing using this Docker-Compose repo .
I’m getting a stylesheet not found
error when I try to run the Wordpress container which kind of makes sense–maybe–since there isn’t a style.css
file in the main theme directory.
Running yarn run build
yields
yarn run v0.23.4
$ webpack --progress --config resources/assets/build/webpack.config.js
Asset Size Chunks Chunk Names
scripts/main.js 201 kB 0 [emitted] main
scripts/customizer.js 3.26 kB 1 [emitted] customizer
styles/main.css 205 kB 0 [emitted] main
scripts/main.js.map 327 kB 0 [emitted] main
styles/main.css.map 1.05 MB 0 [emitted] main
scripts/customizer.js.map 3.09 kB 1 [emitted] customizer
✨ Done in 6.64s.
The style.css
file is in the resources
directory, which I imagine is expected behavior, but how does this work in terms of wp theme compatibility?
2 Likes
mZoo
August 22, 2017, 3:05pm
2
I see that this issue is under discussion in Github which started here where there’s a workaround.
1 Like
ben
August 22, 2017, 3:50pm
3
Where are you seeing this?
WordPress properly supports this
WordPress doesn’t support this via zip file upload.
if ( is_wp_error($source) )
return $source;
// Check the folder contains a valid theme
$working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source);
if ( ! is_dir($working_directory) ) // Sanity check, if the above fails, let's not prevent installation.
return $source;
// A proper archive should have a style.css file in the single subdirectory
if ( ! file_exists( $working_directory . 'style.css' ) ) {
return new WP_Error( 'incompatible_archive_theme_no_style', $this->strings['incompatible_archive'],
/* translators: %s: style.css */
sprintf( __( 'The theme is missing the %s stylesheet.' ),
'<code>style.css</code>'
)
);
}
$info = get_file_data( $working_directory . 'style.css', array( 'Name' => 'Theme Name', 'Template' => 'Template' ) );
1 Like
ben
August 30, 2017, 3:34am
5
Report a bug upstream then? If WP.org isn’t consistent with how themes are structured within their codebase there isn’t much we can do about it
mZoo
December 31, 2017, 11:18pm
6
Hi Ben. A little tardy in getting back to this. It looks like it’s wp-cli that isn’t happy, via docker-compose:
wordpress_1 | + runuser www-data -s /bin/sh -c 'wp theme activate "villetheme"'
wordpress_1 | Error: Stylesheet is missing.
WP-CLI version: 1.4.1
1 Like
ben
January 1, 2018, 12:04am
7
You’ll probably need to activate the theme first via the WP admin. If that’s not possible for you, then take a look at https://github.com/roots/sage-installer/issues/3#issuecomment-337852956 to see what modifications to make to move the required files back to the theme root
2 Likes
is there any way to fix this by using the --path=<path>
argument?
so wp theme activate theme-name --path=sage9/theme/path
or something like that?
If you are using WP-CLI to activate Sage, you can just use:
wp theme activate theme-name/resources
5 Likes
This works great. Thanks!
MyNerv
June 19, 2018, 7:15am
11
Thanks @knowler - you’ve inspired me to create a task in roles/wordpress-install/main.yml to set the theme (when it’s been defined).
deploy-hooks/build-before (roots code):
---
- name: Clone project files
git:
repo: "{{ project_git_repo }}"
version: "{{ project_version }}"
dest: "{{ project_build_path }}"
force: yes
no_log: true
connection: local
- name: Install npm dependencies
command: yarn
connection: local
args:
chdir: "{{ project_build_path }}/web/app/themes/my-sage-9-theme"
- name: Install Composer dependencies
command: composer install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts
args:
chdir: "{{ deploy_helper.new_release_path }}/web/app/themes/my-sage-9-theme"
- name: Compile assets for production
command: yarn build:production
connection: local
args:
chdir: "{{ project_build_path }}/web/app/themes/my-sage-9-theme"
- name: Copy production assets
synchronize:
src: "{{ project_build_path }}/web/app/themes/my-sage-9-theme/dist"
dest: "{{ deploy_helper.new_release_path }}/web/app/themes/my-sage-9-theme"
group: no
owner: no
rsync_opts: --chmod=Du=rwx,--chmod=Dg=rx,--chmod=Do=rx,--chmod=Fu=rw,--chmod=Fg=r,--chmod=Fo=r
group_vars/all/helpers.yml :
wordpress_sites_common:
site_theme: my-sage-9-theme/resources # append /resources only if it's a Sage 9 theme
roles/wordpress-install/main.yml :
- name: Active WP Theme
command: wp theme activate {{ wordpress_sites_common.site_theme }} --allow-root
args:
chdir: "{{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }}/"
with_dict: "{{ wordpress_sites }}"
when: wordpress_sites_common.site_theme is defined
The conditional to check that the theme name has been defined makes it robust, so I think this will work for me until an official fix has been applied.
1 Like