Download the PHP package wpfulcrum/template without Composer
On this page you can find all versions of the php package wpfulcrum/template. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wpfulcrum/template
More information about wpfulcrum/template
Files in wpfulcrum/template
Package template
Short Description Fulcrum Template Module - empowering your plugin to load templates.
License MIT
Homepage https://github.com/wpfulcrum/template
Informations about the package template
Template Module
Empowering your WordPress plugin to load templates.
Does your plugin create a custom post type or taxonomy? Or maybe you want to add a page template into the page's template selector? The Fulcrum Template Module makes it easy for you.
Features
- Theme override - if the template exists in the theme, it loads that one and not the plugin.
- Loads single, post type archive, and taxonomy templates from your plugin.
- Loads your custom template into the admin's page template select, allowing authors to select and assign your template to the page.
- If the page being loaded has a template assigned to it, it will load the plugin's template when available.
Installation
The best way to use this component is through Composer:
Dependencies
This module requires:
- at least PHP 5.6
- WordPress 4.8+
Configuration
There are 2 types of loaders, each requiring a separate configuration file in your plugin:
- Template loader - for the front-end
- Admin page template loader - for the back-end
Template Loader Configuration
The following example is for a "Book" custom post type with a "Genre" taxonomy:
The above configuration tells the module that this plugin has the following template files that should be loaded when needed:
single-book.php
archive-book.php
taxonomy-genre.php
- and page templates, which are configured next.
Admin (Back-end) Template Loader
When you're plugin needs to load custom page templates into the back-end, use the following configuration example:
The above configuration tells the module that the plugin has the following templates available for Pages:
template-books.php
What Happens?
When an author opens a page in the back-end admin area, the "Book Entry Template" is available for selection as the page's template. If that template is selected, the plugin's template file will load when that page is being rendered in the browser (on the front-end).
Making It Work
There are 2 ways to utilize this module:
- With the full Fulcrum plugin.
- Or on its own without Fulcrum.
With Fulcrum
In Fulcrum, your plugin is an Add-on. In your plugin's configuration file, you will have a parameter for the serviceProviders
, where you list each of the service providers you want to use. In this case, you'll use the provider.template
for the front-end loading and provider.adminTemplate
for the back-end admin loading.
For example, using our configurations above, this would be the configuration:
Without Fulcrum
Without Fulcrum, you'll need to instantiate each of the Loaders.
For the front-end template loader, you would do the following:
For the back-end admin template loader, you would do the following:
Contributing
All feedback, bug reports, and pull requests are welcome.
All versions of template with dependencies
wpfulcrum/config Version ^3
wpfulcrum/extender Version ^3
wpfulcrum/foundation Version ^3