DWS WP Framework
  • Welcome
  • Primary goals
    • Modular design
    • No 3rd-party dependencies
  • Key concepts and dev tools
    • PHP and WP requirements
    • Object-Oriented Programming
    • Semantic Versioning
    • Version Control (git / GitHub)
    • Dependency Management (Composer)
    • Automated Testing (Codeception + Github Actions)
    • Dependency Injection (PHP-DI)
    • Coding Standards (PHPCS and PHPMD)
    • Dependencies Scoping (PHP-Scoper)
    • TypeScript and Sass
    • Task Runners (Grunt)
  • Setting up your dev environment
    • Windows
  • Your first plugin
    • Multiple plugins using the framework on the same site
  • Frequently Asked Questions
  • Bootstrapper Module
    • Motivation
    • How it works
    • How to use
    • White Labeling
  • Helpers Module
    • Motivation
    • How to use
  • Foundations Module
    • Motivation and How to use
    • Actions
      • Local action traits
      • Extension action traits
      • Integration action traits
    • States
    • Utilities
      • Stores
      • Handlers and Services
        • Logging Service
  • Plugin
    • Main Plugin Instance
    • Plugin Components
  • Hierarchies
  • Helpers
  • Utilities Module
    • Motivation and How to use
    • Hooks Service
      • Scoped Handler
    • Shortcodes Service
    • Templating Service
    • Assets Service
      • Scripts Handler
      • Styles Handler
    • CRON Events Service
      • Action Scheduler Handler
    • Admin Notices Service
    • Dependencies Service
    • Validation Service
  • Core Module
    • Motivation and How to use
    • Plugin Tree
      • Plugin Root
      • Plugin Functionality
    • Plugin Components
      • Internationalization
      • Installation / Upgrade / Uninstallation
  • Settings Module
    • Motivation and How to use
    • Settings Service
      • WordPress Handler
      • MetaBox Handler
      • ACF Handler
    • Validated Settings
  • WooCommerce Module
    • Motivation and How to use
    • Extended WC Logger
    • WC Settings Handler
Powered by GitBook
On this page

Was this helpful?

  1. Utilities Module

Templating Service

PreviousShortcodes ServiceNextAssets Service

Last updated 4 years ago

Was this helpful?

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 file

  • load_template - for loading a whole template file

  • locate_template - for figuring out which template was used; theme overrides take priority to the plugin's default files

  • get_template_html - for returning the HTML content of a template file as string

  • get_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 for more information. Of particular interest is .

read the Codex
this article about the template hierarchy