In partnership with the principle of developing lazy code is the principle of developing smart code for smart shortcodes.
Smart shortcodes understand the context in which they’re being executed and adjust their behaviour accordingly.
Many of the lazy smart shortcodes in oik plugins exhibit smart behaviour of one form or another. Examples:
- Smart shortcodes provide help, syntax, example(s), generated code snippets and extended help. See bw_codes – display the currently available shortcodes
- Smart shortcodes can apply context sensitive values. [bw_posts] alters its behaviour depending upon the
post_typein which it’s being used. This is also true of many of the dynamic shortcodes in the oik base plugin.
- Smart shortcodes can control when a shortcode will get expanded. You may not want a shortcode to be expanded when it’s being used in a title, but do want it expanded when it’s being used in the content of a page, an excerpt or widget.
- Smart shortcodes can also apply special processing to remove any HTML from tooltips.
- AND obviously, smart shortcodes reuse functionality that has already been developed. This is the main reason for many of the oik plugins being dependent upon oik.
- By definition lazy, smart shortcodes are implemented with code that is definitely NOT bloatware.