The pattern I use is:
- break code into modules using classes
- use spl_autoload_register() to load classes (thereby only included when used)
- have a class that is the plugin controller, with a method for each shortcode
- those methods generally do nothing but create instance of shortcode class and pass params
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.
Related Posts:
- Looking for a way to include/embed text from a file on a page so that the short codes are processed
- Push Shortcode parameter to template
- Show shortcode without executing it
- How to create a shortcode with 1 parameter (atts)
- How does a shortcode work?
- Run visual composer code in php page
- Remove wptexturize from a shortcode?
- Using shortcode in Post title
- WordPress adds br in between my shortcode
- Audio or playlist shortcode condition according to the amount of files on attachment page
- WP_enqueue_script inside shortcode?
- Shortcode to Gutenberg-block: additional text on front-end and conditional display
- template_redirect to accompany with a shortcode
- Tinymce shortcodes within shortcode contents
- passing multiple parents value into a shortcode
- How do I preview the result of a shortcode in the TinyMCE editor?
- Conditionally loading Facebook PHP SDK in shortcode
- WordPress shortcode doesn’t working on HomePage
- Why are Shortcodes Disabled in Widgets by Default?
- Add attribute to shortcode dynamically
- Execute shortcode twice in the same page
- How to parse this shortcode?
- Add custom setting that uses radio button to WP Gallery
- Shortcode with hyphen doesn’t work
- Shortcode parsed incorrectly because of heredoc
- WordPress Gallery shortcode: Display one category ID only
- How to get gallery id inserted to a post?
- WordPress Shortcode show database row
- Shortcode “post_per_page” not working
- Shortcode is running in page editor
- Creating shortcode with parameter
- Shortcodes won’t work on live environment
- Create shortcode in Child Theme?
- Create a short code to display a specific loop
- How to add shortcode to HTML file (not showing on website)
- How to wp_redirect on ‘init’ hook on condition of current post id?
- Buddypress shortcode for tabs [closed]
- Image Shortcode from ACF ID
- Page code showing in WP Dashboard
- How to create a shortcode with html and php code
- PHP Running On CMS Side of WordPress
- Insert shortcode between ”
- do_shortcode doesn’t work on some pages
- Custom youtube shortcode that uses $content
- When are Shortcode Attributes Available in Template
- Regenerating WordPress shortcodes based on value with AJAX
- Custom shortcode to display posts, first post is full
- Form shortcode with multiple options as attributes
- How to add data attributes to the wordpress audio shortcode
- Shortcode inside text widget do not call enqueue style
- How to create a dropdown of shortcodes in edit mode for posts
- Multiple instances of the shortcode on the same page
- do_shortcode() won’t return PHP Array
- get data with shortcode
- Replace shortcode with output in database?
- Use full size images in a specific gallery
- contact form 7 database short codes [closed]
- how to create a fav icon shortcode?
- How to deal with WordPress bug: can’t use wrapped and unwrapped shortcode on same post
- Execute Shortcodes when submitting post
- Substituting value via shortcode
- Video shortcode, option are not rendered
- Create shortcode for each form field in contact form 7
- Auto embeds don’t work for attachment descriptions
- Shortcode to appear and show the date not code in Title and description of Social Media sites
- Date Shortcode in Image alt and title tags
- access shortcode atts in template part
- how to add shortcode widget at end of main blog page
- Shortcode result appears above page content
- Shortcode is not showing content when placed in editor (post_type = page)
- May an attribute have no value?
- How to set up posts per page on WP
- How to insert a short code into Contact Form 7 in WordPress that will call a function once the submit button is pressed
- SQL query to bulk change short code in all posts
- Display shortcode in text field with wordpress settings api
- Unable to make shortcode, what is wrong?
- How to display a page dependent on a url parameter supplied by a form/button page?
- How do i remove Business feeds Shortcode fatal error
- latest posts shortcode with image
- WordPress plugin shortcodes not outputting anything
- WordPress Gallery with ID’s Shortcode not Working
- Featured image with link to post shortcode, image displaying above the post
- Video shortcode inside tabs shorcode NOT working
- How to stop unwanted splits in excerpts when using shortcodes for sliders or players
- How to add meta slider lite or other slider to main page header in pinboard theme
- Str_replace using shortcode with multiple changes
- Escaping a shortcode so it displays as-is [duplicate]
- WordPress do_shortcode first iteration
- If do_shortcode is blank, return some message
- Add a short code to a plugin
- Previous/Next with the same category
- I’ve broken the short code for Contact Form 7!
- echo a shortcode in a shortcode code?
- Applying if (get_post_meta) to new shortcode
- Add widget/shortcode to sidebar OUTSIDE of the theme
- Shortcode to include PHP file, pass various parameters to include?
- How to remove https:// from shortcode generated url
- Working with Shortcode, AJAX, Elementor
- How to exclude some cats from wp_list_categories using shortcut
- How can I create a shortcode that shows a list of categories on the single product page?