![]() Refer to the brightnucleus/view documentation on how to go about configuring a ViewBuilder instance. This makes overriding the views later on very flexible, in that you can not only override shortcode markup in your theme that was defined in your plugin, but you can also use a different engine than was originally use. They do not even need to contain the extension, as long as that can be inferred by the engines that are known to the view builder. Once you've added one or more locations in this way, you can use relative URIs in your config file. To adapt the locations that the view engine looks in for relative view URIs or to configure the available rendering engines, you can either adapt the instance centrally available through the Facade, or, preferably, inject your own custom ViewBuilder instance into the ShortcodeManager as the third constructor argument. If no specific instance of a ViewBuilder was injected, then the ShortcodeManager will rely on the one provided by the Views Facade. The default behavior already deals with absolute paths and can render any type of views that the Views engine being used can handle. The underlying implementation uses the brightnucleus/view package to render the actual views for each shortcode. When using a callable, the arguments that are passed to that callable are the same as the constructor gets for the default implementation of each of these. You can pass either a fully qualified class name or a callable that acts as a factory. The Config files accepts a key for overriding each of these. BrightNucleus\Shortcode\ShortcodeUIInterface.BrightNucleus\Shortcode\ShortcodeAttsParserInterface.BrightNucleus\Shortcode\ShortcodeInterface.The actual implementations to be used for the following interfaces can be changed through the Config files: \add_action( 'init', ) Using Custom Classes Hook Shortcode Manager up to WordPress action. getSubConfig( PLUGIN_PREFIX, SHORTCODE_MANAGER_PREFIX ) Then, we'll need to write a template that can be rendered by the shortcode. 'Target URL where the button will lead to when pressed.', 'The caption that is shown on the button.', We also need to configure the Shortcake input fields. */ 'is_needed' => function ( $context ) , If this is a callable, it gets * executed and its result evaluated to boolean. * Whether the shortcode UI (along with its dependencies) is needed * within the current context or not. * Refer to the Shortcake documentation for details about the syntax: * */ 'ui' => [ * Besides one additional keys that ShortcodeManager recognizes, the * 'ui' subkey gets passed as is to the Shortcake UI plugin. */ 'custom_ui' => '\BrightNucleus\Shortcodes\ShortcodeUI', ![]() * This can be either a fully qualified class name or a callable. * Omit to use default `ShortcodeUI` class. (optional) * You can use this to completely customize the standard shortcode * user interface class behavior. * Customised ShortcodeUIInterface implementation. * Provided that you use the default `ShortcodeAttsParser` * implementation, you can define a `default` value for each * attribute, as well as an optional `validate` callable that * gets evaluated to a boolean. ![]() * NB: lower-cased by WP, so no camelCase or UPPER_CASE. * These are the optional attributes that you can append to your * shortcode within the WP editor. * These attributes will be processed by the * `ShortcodeAttsParserInterface` implementation that is being used. * Collection of attributes that can be used with the shortcode. */ 'custom_atts_parser' => '\BrightNucleus\Shortcodes\ShortcodeAttsParser', * Omit to use default `ShortcodeAttsParser` class. (optional) * You can use this to completely customize the way shortcode attributes * are parsed. * Customised ShortcodeAttsParserInterface implementation. ![]() */ 'custom_class' => '\BrightNucleus\Shortcodes\Shortcode', (optional) * You can use this to completely customize the standard shortcode * class behavior. * Customised ShortcodeInterface implementation. * The path is relative to the configuration file. * Path to a template that is used to render the shortcode. The name of that * entry is used as the shortcode tag. * For each shortcode you wish to define, you'll need one separate entry at * the root config entry passed in to ShortcodeManager. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |