The
develop
branch tracks development and it's not a stable code. For a stable version, use themaster
branch or the latest release.
Base WP Theme is a starter WordPress theme to use as a base to build WordPress themes from scratch.
Contains the configuration files for handling the assets files like Javascript, CSS, and images using Webpack and also handles WordPress Coding Standards through Composer. Some topics covered in the project:
- Webpack for managing, compiling, and optimizing the theme's asset files;
- ES6;
- Eslint;
- Babel;
- SASS;
- Stylelint;
- WordPress Coding Standards;
- PHP Namespaces;
- Autoload;
- Introduction
- Requirements
- Usage
- WordPress Hierarchy
- Assets
- Scripts
- Build
- Deploy
- Contributing and Support
- Changelog
- License
Base WP Theme follows WordPress recommended requirements. To work on this project you will need:
- WordPress >= 4.7
- PHP >= 7.4
- MySQL >= 5.7 or MariaDB >=10.3
- Nginx or Apache with mod_rewrite module
- HTTPS support
For WordPress local development, I strongly recommend using Docker. To see how to create a Docker environment, check my repository Docker WordPress. But feel free to work with the one you prefer, like XAMPP for example.
Clone the repository with git clone https://github.com/sarahcssiqueira/base-wp-theme
or download one of the latest releases. Paste in the /wp-content/themes/ folder of your WordPress installation.
On the Base WP Theme root folder, run the following commands to install the required dependencies:
npm install && composer install
To use WPCS, we have to tell the PHP Code Sniffer about the WordPress Coding Standards. For that run the command:
composer cstd
Remove the front-page.php and create your own, you can use the front-page-sample.php present in the root folder. Also, remove the front-page.scss partial. Remove the statement '/.front-page' of the index.scss file.
On the theme's root folder are the following WordPress .php files, on where you should work. On each file, you can see more info about their responsibilities. For additional information, please refer to WordPress Template Hierarchy documentation.
- index.php
- page.php
- privacy-policy.php
- single.php
- category.php
- tag.php
- author.php
- archive.php
- search.php
- 404.php
- attachment.php
- front-page.php
- header.php
- footer.php
The assets folder keeps the javascript, css, and images. This project uses scss.
There are scripts on package.json and in composer.json to help us with common routines.
To watch the assets with webpack run the command npm run dev
To lint Javascript using eslint, run npm run lint
To automatically fix Javascript with eslint it's necessary to add the flag --fix, for that run npm run lint:fix
To lint CSS using stylelint, run npm run lint-css
To automatically fix CSS with stylelint it's necessary to add the flag --fix, run npm run lint-css:fix
To generate a report for PHP code standards violations run the command:
composer cs
To automatically fix the coding standards violations run the:
composer cbf
The coding standards are defined in the .phpcs.xml file.
To create an optimized version of the assets, run the command npm run build
The assets on the build folder are the ones enqueued on the class-assets.php -> functions.php.
The Base WP Theme is deployed in a LAMP server on Digital Ocean. The deployment is handled by GitHub Actions. Update or replace the .github/worfklow/deployment.yml file according to your deployment needs.
In the Base WP Theme, the deployment workflow is triggered when a new tag is added to the master branch, so the deployed version will always correspond to the latest release version.
You can set the trigger for your workflow on push, on pull requests, on issues opened, etc. Please refer to GitHub documentation for more details.
For more workflows samples go to Reusable WordPress Workflows repository.
Contribute informing about issues or even through pull requests for improvements.
❤️ Support buying me a coffee.
All changes to this project are documented in CHANGELOG
The Base WP Theme is licensed under the GPL v2.