tomorrow / wp-bootstrap
A WordPress bootstrap for Tomorrow Studio projects using Timber/Twig
Requires
- php: ^8.0
- timber/timber: ^2.0
- vlucas/phpdotenv: ^5.6
README
This Composer package extends the functionality of timber/timber
by bootstrapping essential functions and configurations commonly used within a WordPress theme. It streamlines theme development by automating key tasks, such as loading environment variables, setting up Timber contexts, and applying custom Twig filters.
Installation
To install this package, run the following command using Composer:
composer require tomorrow/wp-bootstrap
Usage
Once installed, include this package in your theme's functions.php
file to automatically initialize the main functionality:
<?php
use Tomoorrow\Bootstrap;
// Load Composer's autoloader
require_once get_template_directory() . '/vendor/autoload.php';
// Load the main site class instance
new Bootstrap();
Configuration
While the Tomorrow\Bootstrap
package works out-of-the-box, you can customize its behavior by extending the class and methods.
Environment Variables
The package looks for a .env
file located outside the WordPress directory (one level above ABSPATH
). If found, it loads the environment variables automatically. Use $_ENV to access these variables in your theme.
Twig Filters
Custom Twig filters can be added or modified by extending the add_to_twig()
method.
Contributing
Contributions are welcome! If you have an idea for improving this package or find a bug, feel free to submit a pull request or open an issue on GitHub.
Steps to Contribute
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Write your code, along with tests if applicable.
- Submit a pull request with a clear description of your changes.
License
This package is licensed under the MIT license