YahnisElsts / wp-update-server

A custom update API for WordPress plugins and themes. Intended to be used in conjunction with my plugin-update-checker library.
MIT License
824 stars 176 forks source link

Is compatible with sage? #69

Closed bilalmalkoc closed 5 years ago

bilalmalkoc commented 5 years ago

Hello. Is your project works with sage roots themes? https://roots.io/sage/

YahnisElsts commented 5 years ago

I've never tested it with that particular starter theme but I don't see any reason why it wouldn't work. If you notice any compatibility problems, please report them in a new issue.

caineboelhouwer commented 3 years ago

@YahnisElsts i tried, but i get the following error: Package "harpedon" exists, but it is not a valid plugin or theme. Make sure it has the right format (Zip) and directory structure.

YahnisElsts commented 3 years ago

Is this also related to the "Sage" theme or a separate issue?

The most common error for that error message is probably incorrect directory structure in the ZIP archive. The plugin or theme files must be inside a directory whose name matches the plugin/theme slug. Note that if you're on a Mac, the default Zip file handler can make it look like files are in a directory when they're actually not. You may need to use a third-party Zip archiver in that case.

caineboelhouwer commented 3 years ago

Yes I use the sage theme. I already used this package for plugins and it works perfectly, thanks for that :). It's not the zip file handler, I think it's the sage directory structure, because de style.css is contained in the "resources" folder.

themes/your-theme-name/ # → Root of your Sage based theme ├── app/ # → Theme PHP │ ├── controllers/ # → Controller files │ ├── admin.php # → Theme customizer setup │ ├── filters.php # → Theme filters │ ├── helpers.php # → Helper functions │ └── setup.php # → Theme setup ├── config/ # → Theme configuration ├── composer.json # → Autoloading for app/ files ├── composer.lock # → Composer lock file (never edit) ├── dist/ # → Built theme assets (never edit) ├── node_modules/ # → Node.js packages (never edit) ├── package.json # → Node.js dependencies and scripts ├── 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 │ ├── functions.php # → Composer autoloader, theme includes │ ├── index.php # → Never manually edit │ ├── screenshot.png # → Theme screenshot for WP admin │ ├── style.css # → Theme meta information │ └── views/ # → Theme templates │ ├── layouts/ # → Base templates │ └── partials/ # → Partial templates └── vendor/ # → Composer packages (never edit)

caineboelhouwer commented 3 years ago

For example I zipped the default wordpress theme(twentynineteen) and uploaded in the packages directory. This is working.

YahnisElsts commented 3 years ago

I briefly skimmed the theme documentation and it looks like you might need to run a build script before you can deploy the theme. This should put the built theme in the dist subdirectory, which is then what you would upload to a site. Could it be that this also puts the style.css file in the right place?

caineboelhouwer commented 3 years ago

yarn build:production only compiles the assets from the resource directory. The style.css is not in the /dist folder.

YahnisElsts commented 3 years ago

Hmm. When you use this theme in WordPress - without a style.css in the root directory - does WordPress show the correct information from style.css, like the theme name, version number, author name, and so on? If it does, I might need to look at the WordPress source code to figure out how it manages to find that file in a subdirectory.

caineboelhouwer commented 3 years ago

Sage doesn't have a style.css in the root, only in the resource directory.

YahnisElsts commented 3 years ago

Right, you mentioned that. So where do you put theme metadata like name and version number? And does that information show up in "Appearance -> Themes"?

The WordPress documentation about theme development says:

The style.css is a stylesheet (CSS) file required for every WordPress theme.

And also:

In order for WordPress to recognize the set of theme template files as a valid theme, the style.css file needs to be located in the root directory of your theme, not a subdirectory.

That's why I'm curious if/how a theme works without that file.

caineboelhouwer commented 3 years ago

https://roots.io/docs/sage/9.x/configuration/#theme-structure at the bottom of the page you can see there is no style.css in the root of the theme. The theme works without style.css in the root and the meta data is shown in Wordpress.

YahnisElsts commented 3 years ago

Could I have a copy of the theme for testing purposes? Alternatively, any other theme that also doesn't have a style.css file in the root directory but still works an shows the meta data could be useful.

caineboelhouwer commented 3 years ago

https://drive.google.com/file/d/1RdaFEwPc1jWItavPYGi79dF21CqhN9Uz/view?usp=sharing

YahnisElsts commented 3 years ago

Thank you. I've tested it and it looks like WordPress does search subdirectories for style.css files (though only one level deep). This makes WordPress think that resources contains the actual theme and the rest of the files are unrelated. However, Sage then does some filter shenanigans in functions.php to make WordPress look in different subdirectories for templates and other theme files.

I retract my earlier comment about compatibility. This is not going to work with wp-update-server. I'm also reluctant to add any special case code for a specific theme/framework.

There is some good news - it looks like Sage 10 might move the style.css file to the root directory, which should work better for the update server.

caineboelhouwer commented 3 years ago

Thanks. Im going to give Sage 10 a try. But there is another option. You can move your files from resource to the theme root directory. https://github.com/roots/sage-installer/issues/3#issuecomment-337852956

YahnisElsts commented 3 years ago

Yes, that could also work. I wasn't aware that it was possible with this theme.