c# Greenpeace Planet 4 Nordic Child Theme
The Planet 4 Nordic Child Theme is a child theme built for the Planet 4 project. It customizes the parent theme by adding unique features and styles specific to the Nordic region. This child theme customisez the Planet4 Master Theme following this Design System.
Make sure you have the following tools installed on your machine:
- Node.js (v16 recommended)
- npm (comes with Node.js)
- Composer (for PHP dependencies and coding standards)
- WordPress setup (parent theme and WordPress installation)
To install and set up the theme locally, follow these steps:
-
Clone the repository:
git clone https://github.com/greenpeace/planet4-child-theme-nordic.git
-
Navigate to the theme directory:
cd planet4-nordic-child-theme
-
Install the npm dependencies:
Run
npm install
to install all necessary Node.js packages:npm install
-
Install Composer dependencies:
Run
composer install
to install PHP dependencies (like coding standards):composer install
-
Activate the theme:
- Upload the child theme to your WordPress
/wp-content/themes
directory. - Activate the theme from the WordPress admin dashboard (
Appearance > Themes
).
- Upload the child theme to your WordPress
Once installed, the theme can be customized and extended as per the needs of the Nordic campaign. The child theme inherits most of its functionality from the parent theme, but you can add custom styles, templates, and features as needed.
To modify or add features to the theme, navigate to the planet4-nordic-child-theme
directory, make changes to the appropriate files, and use the provided npm scripts for development.
-
Build CSS: Compiles the SCSS files into a minified CSS file.
npm run build:css
-
Build: Compiles all assets for production using Webpack and outputs them to the
build/
directory.npm run build
-
Start: Launches a development server with live reloading and builds assets in development mode.
npm run start
-
Lint CSS: Lints the SCSS files to ensure coding standards are followed.
npm run lint:css
-
Fixes: Automatically fixes PHP code style issues.
composer run fixes
-
Sniffs: Runs PHP CodeSniffer (
phpcs
) to check PHP files against coding standards.composer run sniffs
Here's a brief overview of the key directories and files in the project:
planet4-nordic-child-theme/
├── assets/ # Compiled theme assets (CSS, JS)
│ ├── build/ # Output directory for compiled and minified production assets
│ └── src/ # Source SCSS and JS files
├── includes/ # Theme-specific PHP includes
├── page-templates/ # Theme-specific Twig templates
├── vendor/ # Composer dependencies
├── functions.php # Main theme functions
├── webpack.config.js # Webpack configuration for asset bundling
├── style.css # Main stylesheet (import parent theme styles)
├── package.json # Node.js dependencies and npm scripts
├── composer.json # PHP dependencies and Composer scripts
└── README.md # Project documentation (this file)
To override parent theme styles, place your custom SCSS files in the assets/src/scss/
directory. These files are automatically compiled and output to assets/build/
when running the build scripts.
We follow WordPress Coding Standards to ensure clean, readable, and maintainable code.
The coding standards are enforced through phpcs
(PHP CodeSniffer) and can be automatically corrected using phpcbf
. Composer handles both tools.
To check for coding standard violations:
composer run sniffs
To automatically fix issues:
composer run fixes
We welcome contributions! To contribute to this project:
- Fork the repository.
- Create a new branch (
git checkout -b feat/my-feature
). - Make your changes.
- Push your branch (
git push origin feat/my-feature
). - Open a Pull Request.
Please ensure that your code follows the project's coding standards. Use npm run lint:css
for CSS and composer run sniffs
for PHP.
This project is licensed under the GNU License. See the LICENSE file for details.