SimpleShortcodes is a simple PHP class that lets you add shortcode functionality to your PHP projects. Check below for the examples to learn how to use this class in your current PHP project.
Include the class to your PHP file
Next, create an instance of the class
Build an array of your shortcodes
Now pass in the shortcodes to the class
As the class makes use of predefined variables, so the variables should be defined in your project already before you call the read object
Now compose a message
Printing the message without the class:
Now print the message using the class’ read() object
This shortcodes class can be used in various requirements. Here is an ideal example where you will find this class extremely handy.
Say you are going to send out marketing or other emails to your mailing list from your own PHP script. Now using this class, you can personalize the message for each user. This example explains how to use this shortcode class in a scenario like this.
As we have seen above that you need to add shortcodes after creating the class’ instance, but if you don’t want to do this again and again, then there is yet another option for you. Simply create an array of the shortcodes like we have used above, assign the array to a variable and then use that variable in the __construct() object of the class. This way, you will not need to add the shortcodes again and again. For more clarification, please check the __construct() object of the class.