Shortcodes Service

The shortcodes service is actually extremely similar to the hooks service described previously. It's a single-handler service with a runnable and a resettable action. 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 ShortcodesHandlerInterface 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:

Last updated