wp-kit/shortcodes
This is a wp-kit component that handles shortcodes., (*1)
This component was built to run within an Illuminate\Container\Container so is perfect for frameworks such as Themosis, Assely and wp-kit/theme., (*2)
Often, WordPress developers want an OOP approach to shortcodes, this is exactly what this repo delivers., (*3)
Installation
If you're using Themosis, install via Composer in the root of your Themosis installation, otherwise install in your Composer driven theme folder:, (*4)
composer require "wp-kit/shortcodes"
Setup
Add Service Provider
Just register the service provider and facade in the providers config and theme config:, (*5)
//inside themosis-theme/resources/config/providers.config.php
return [
WPKit\Shortcodes\ShortcodeServiceProvider::class
];
Add PRS4 Class Reference (Themosis Only)
Just add the following line to resources/config/loading.config.php in the Themosis theme folder:, (*6)
'Theme\\Shortcodes\\' => themosis_path('theme.resources').'shortcodes',
Add Config & View File
The recommended method of installing config files for wp-kit components is via wp kit vendor:publish command., (*7)
First, install WP CLI, and then install this component, wp kit vendor:publish will automatically be installed with wp-kit/utils, once installed you can run:, (*8)
wp kit vendor:publish, (*9)
For more information, please visit wp-kit/utils., (*10)
Alternatively, you can place the config file(s), shortcode file(s) and view file(s) in your theme/resources/config, theme/resources/shortcodes and theme/resources/views directories manually., (*11)
Usage
Adding Classes
wp-kit\shortcodes comes with a class WPKit\Shortcodes\Shortcode which can be extended by your own shortcode classes which should be added inside resources/shortcodes within the namespace Theme\Shortcodes., (*12)
Here is an example Shortcode class., (*13)
Adding Views
When you add a shortcode class, be sure to add a template view file within resources\views\shortcodes with the same name as the $tag you have set in the shortcode class., (*14)
You may use whatever either twig or php file types. We always recommend twig., (*15)
Here is an example view files., (*16)
Get Involved
To learn more about how to use wp-kit check out the docs:, (*17)
View the Docs, (*18)
Any help is appreciated. The project is open-source and we encourage you to participate. You can contribute to the project in multiple ways by:, (*19)
- Reporting a bug issue
- Suggesting features
- Sending a pull request with code fix or feature
- Following the project on GitHub
- Sharing the project around your community
For details about contributing to the framework, please check the contribution guide., (*20)
Requirements
Wordpress 4+, (*21)
PHP 5.6+, (*22)
License
wp-kit/shortcodes is open-sourced software licensed under the MIT License., (*23)