项目作者: gregrickaby

项目描述 :
A classic PHP-based theme, with modern tooling and support for Gutenberg blocks.
高级语言: PHP
项目地址: git://github.com/gregrickaby/classic-wordpress-theme.git
创建时间: 2021-07-02T18:38:03Z
项目社区:https://github.com/gregrickaby/classic-wordpress-theme

开源协议:GNU General Public License v2.0

下载


Classic WordPress Theme

A classic PHP-based theme, with modern tooling and support for Gutenberg blocks.

Table of Contents


Features


Why?

This isn’t a block theme and does not support full-site editing on purpose.

There’s no doubt that block-based themes are the future of WordPress; however, PHP-based themes with deep integration with Gutenberg and modern tooling are still as relevant as ever.

I wanted to create a “classic” theme that gave developers world class support for tooling and the latest Gutenberg block features like theme.json. Plus, I love to tinker and being on the bleeding edge is fun!


Setup

Requirements

Install

Clone this theme into wp-content/themes:

  1. git clone git@github.com:gregrickaby/classic-wordpress-theme.git

Install dependencies:

  1. composer install && npm i --legacy-peer-deps

Run a build to bundle all theme assets:

  1. npm run build

Finally, activate the theme in the WordPress dashboard.


Development

Asset Structure

The src directory is where all theme assets should be placed. Webpack is configured to bundle them into the /build directory.

  1. ├── src
  2. index.js
  3. ├── css
  4. ├── index.css
  5. └── tailwind.css
  6. ├── fonts
  7. └── OpenSans-Regular.woff2
  8. ├── images
  9. └── placeholder.png
  10. └── js
  11. └── placeholder.js

Styling

This theme includes support for TailwindCSS. It uses the JIT compiler, so live reloads are ⚡️ fast.

To get started, open index.css and start adding your styles. To customize further, open tailwind.config.js or theme.json.

JavaScript

This theme uses Webpack 5 and Babel and is ready for anything esnext. Simply create your JS files and place them in /src/js/ then use ES6 imports in src/index.js.

Theme Files

It can frustrating to “tear down” a theme just to get started. I tried to keep the theme files and use of template tags to the bare minimum.

theme.json

WordPress 5.8 comes with a new mechanism to configure the editor that enables a finer-grained control and introduces the first step in managing styles for future WordPress releases: the theme.json file.

The theme.json kinda mimics the config workflow for tailwind.config.js:

  1. // theme.json
  2. {
  3. "version": 1,
  4. "settings": {
  5. "color": {},
  6. "layout": {}
  7. },
  8. "styles": {
  9. "color": {},
  10. "typography": {},
  11. "elements": {},
  12. "blocks": {}
  13. },
  14. "templateParts": {},
  15. "customTemplates": {}
  16. }

You can learn more about theme.json in the Block Editor Handbook and check out the theme-experiments repo on Github.

NPM Scripts

Live Reload

Watch for changes and LiveReload:

  1. npm run dev

Now open your browser and click the LiveReload extension.

Going to Production

Bundle assets for production:

  1. npm run build

Linting

Format files:

  1. npm run format

Lint files:

  1. npm run lint