Templating Service
The templating service is the only service that does NOT use a handler. That might change in the future if we decide to support different templating systems like Twig, but for now we only plan to support WordPress' templating system for the time being.
It's a smart wrapper around WordPress' own locate_template
and load_template
functions inspired by WooCommerce's own methods for this purpose. There are 5 public methods:
load_template_part
- for loading parts of a larger template fileload_template
- for loading a whole template filelocate_template
- for figuring out which template was used; theme overrides take priority to the plugin's default filesget_template_html
- for returning the HTML content of a template file as stringget_template_part_html
- for returning the HTML content of a template part file as string
This service is supposed to offer an easy way to support WordPress best practices when it comes to loading template files. That means giving first priority to the child theme, and then to the template theme, before loading the plugin's bundled file and providing enough hooks all around for extending the service.
If you're new to WP templating, we recommend you read the Codex for more information. Of particular interest is this article about the template hierarchy.
Last updated