Download the PHP package stellarwp/templates without Composer
On this page you can find all versions of the php package stellarwp/templates. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stellarwp/templates
More information about stellarwp/templates
Files in stellarwp/templates
Package templates
Short Description A library for templating in WordPress.
License GPL-2.0
Informations about the package templates
StellarWP Templates
A library for including templates in a WordPress plugin that users can choose to override within a specific directory of a theme or child theme.
Installation
It's recommended that you install Templates as a project dependency via Composer:
We actually recommend that this library gets included in your project using Strauss.
Luckily, adding Strauss to your
composer.json
is only slightly more complicated than adding a typical dependency, so checkout our strauss docs.
Notes on examples
Since the recommendation is to use Strauss to prefix this library's namespaces, all examples will be using the Boomshakalaka
namespace prefix.
Configuration
This library requires some configuration before its features can be used. The configuration is done via the Config
class.
Once you've configured the library, extend the Template class to define the location of templates for your plugin.
With your class extension, manually define where the base folder for templates is in the class' plugin_path
property. Here is an example of what that class may look like:
Once you've done that, you can instantiate your class instance and define a few other settings:
With the template class set up, calling $template->template('template-file')
will include the template looking for it in:
-
child theme
-
parent theme
- the plugin