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

Shortcodes Service

PreviousScoped HandlerNextTemplating Service

Last updated 4 years ago

Was this helpful?

The shortcodes service is actually extremely similar described previously. It's a with . It provides the following public methods:

  • add_shortcode - registers a shortcode with the handler

  • remove_shortcode - removes a shortcode registered with the handler

  • remove_all_shortcodes - removes all shortcodes registered with the handler

It accepts any handler implementing the and, just like the hooks service, comes with a default handler that first stores all registered shortcodes in an array and registers them with WP on the run action.

The similarities don't end there though! All the traits and interfaces mentioned for the hooks service are also available for the shortcodes service:

  • and for a getter/setter pair

  • and for injecting the service externally

  • for automagically setting the instance on the objec

  • for automagically calling the register_shortcodes method on setup

to the hooks service
single-handler service
a runnable and a resettable action
ShortcodesHandlerInterface
ShortcodesServiceAwareInterface
ShortcodesServiceAwareTrait
ShortcodesServiceRegisterInterface
ShortcodesServiceRegisterTrait
InitializeShortcodesTrait
SetupShortcodesTrait