[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog
  • #
  • &
  • A
  • B
  • C
  • D
  • E
  • F
  • G
  • H
  • I
  • J
  • L
  • M
  • N
  • O
  • P
  • Q
  • R
  • S
  • T
  • U
  • V
  • W
  • [

Shortcodes – requirements for syntax, formatting and editing

At the start of the development cycle for WordPress 4.4 and beyond there has been a lot of discussion about a roadmap for shortcodes. The most recent ( Shortcode Roadmap Extended Discussion ) is focussed on solutions. This post considers requirements; requirements for shortcode syntax, shortcode expansion, pre and post formatting of content in general and my requirements on the editor. Finally I’ll propose a couple of alternatives for solutions. In my opinion, if we can at least agree on the requirements and their priorities then we might be able to plan something.

Requirements – Syntax

Easy and intuitive, labour saving
RequirementPriority
Allow positional ( unnamed ) parametersH
Allow parameter values to contain HTMLM
Allow parameter values to contain shortcodesM
Provide some method for escaping shortcodesL
Allow shortcode expansion depending on contextH
Allow shortcodes in inner contentH
Allow mixed case parametersM
Allow nested shortcodes (multiple enclosures?)L
Notes:
  • Some of these requirements are already satisfied by WordPress
  • For others I already have an acceptable solution
  • The Priority column reflects my personal requirements
  • The Priority is lower in those cases where I already have a solution
  • In other cases I don’t have the requirement

Requirements – Formatting

Content generated by shortcodes should be respected by other filters
  • Allow user to control the filtering applied to their content
  • Allow fine grained selection of filtering options
  • Allow shortcodes to define what filtering can be applied
  • Shortcode expansion may have to cater for multiple passes
  • Provide pre and post content filtering to allow for content enhancement
  • Allow shortcode expansion depending on filtering context
  • Allow pre and post processing of shortcodes and their parameters

Requirements – Editor

Editors shouldn’t change my hand crafted content
  • Switching between Text and Visual editors should never change the source content
  • Cutting and pasting and dragging and dropping should not filter out text based content
  • The Editor should be able to assist in the creation and editing of shortcodes
  • Allow shortcodes to define their expected parameters
  • Allow selective expansion of shortcodes in the Visual editor, depending on context
  • Allow user control of selective expansion

Requirements – Non Functional

Security
Solution should clearly explain how security will be achieved
Security
Known security issues should be clearly communicated
Security
Perceived security issues should be openly discussed
Scalability
Solution should be scalable: support hundreds of registered shortcodes and thousands of uses
Performance
Solution should be highly performant in normal use: many shortcodes defined but few used
User Experience
No surprises – What You Get Is What You Wanted
Errors
Solution should cater for error situations
Documentation
Clearly defined conventions for shortcode names

Proposed solutions

  • Revisit the parser
  • Revisit the filter functions and the sequence in which they’re invoked
  • Extend the shortcode API to allow shortcodes to better define their rules of engagement
    • Syntax, help, examples, links to documentation
    • Contextual behaviour in content, filter context
  • Develop shortcodes that will implement requirements for mixing different markup styles in source
  • Improve the visual editor
  • Lots and lots of test cases, including complicated but sensible ones

Additional notes

  • I didn’t have time to flesh out these requirements
  • Some of them will need explaining
  • Some are already covered in WordPress TRACs
  • Solving some of the problems may require a little bit of lateral thinking
  • In my opinion it should not be necessary to deprecate any of the existing logic
You can’t get what you want until you know what you want
Joe Jackson, 1984

Further reading

  • Shortcode Roadmap Extended Discussion
  • Testing compatibility with Shortcake v0.5.0
  • APIs:
    • bw_add_shortcode() – Add a shortcode that safely expands in admin page titles but is properly expanded in content and widget text
    • bw_add_shortcode_event() – Add a shortcode function for a specific set of events
  • Sample shortcodes: All used in this post: [bw_link], [bw_blockquote], [bw_csv], [apis]

Published: September 9, 2015 | Last updated: December 4, 2020

Filed Under: shortcode Tagged With: requirements, shortcodes

Information

Component:

Recent plugin updates

oik-weight-zone-shipping v0.2.6 oik-weight-zone-shipping v0.2.6 has been tested with WooCommerce 7.4.0. ...
sb-chart-block v1.2.3 SB Chart Block v1.2.3 contains a fix for an Uncaught Error: Call to undefined function bw_trace2()  ...
SB Chart Block v1.2.1 Update to SB Chart Block v1.2.0 for custom colors, font size options and multiple y-axis charts.  ...
oik-css v2.1.0 Update to oik-css v2.1.0 for the ability to style CSS and GeSHi output in documentation. ...
oik-types v2.3.0 Update to oik-types v2.3.0 for improved control over sort order on archives ...

Plugins

  • All Plugins
  • oik base plugin
  • FREE oik plugins
  • WordPress plugins
  • Premium oik plugins

Themes

  • FREE themes
  • Bespoke themes
  • Premium themes

Blocks

  • All Blocks
  • Block examples
  • About Blocks

Shortcodes

  • All Shortcodes
  • Shortcode examples
  • About Shortcodes

Reference

  • About APIs
  • All APIs
  • All Classes
  • All Files
  • All Hooks

Support

  • Contact
  • Cookies policy
  • Get API key
  • Privacy
  • Request support
  • Sitemap
  • Stay informed
  • Terms and Conditions
oik-plugins
Email: oikplug@oik-plugins.com

Weight shipping plugins

Find out which cart weight shipping plugin you need for your WooCommerce site.
Which cart weight based plugin do I need?

Site:  www.oik-plugins.com
© Copyright oik-plugins 2011-2023. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins
WordPress 6.2. PHP: 7.4.33. Memory limit: 768M