I am Writing a plugin, with many shortcodes. Now I do not want to include all shortcodes source files to every page. So my questions are:
- Where should I include the source? Is it back-end or front-end
- How to add it on that specific page?
thanks HoGo
|
|
The pattern I use is:
Works for me, simplifies things greatly, especially for large sites where I have dozens of classes. No need to carefully manage what gets included where because the class autoloader handles that. |
|||
|
|
|
You cannot predict where shortcodes are rendered. Usually in front-end, but there is also AJAX or custom views in back-end. And if the source file is really that huge, there might be room for refactoring. |
||||
|
|
|
If its acceptable, I could suggest you to organize your shortcodes by renaming your all shortcodes to make them having the same name and putting old names into an attribute. For example, if you have 2 shortcodes Your plugin index file:
shortcodes.php:
By organizing your shortcodes like this, you will include php file with shortcode functions only when its really required and it doesn't matter if it is admin or frontend page. |
|||||
|
|