You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, hopefully this is the right place to come with suggestions for Timber, since the guidelines encourage only bugs.
I was just implementing some custom shortcodes for a theme, and was thinking that having a TimberShortcode class to handle basic things you need to do on your content (escaping content, default parameters, normalizing the attribute key-case, etc.) would be a great addition.
I'll keep it short because I want to gauge the interest for such a feature, and I can look into specifics if you agree it's a step in the right direction.
I've slept on the idea, and maybe creating a TimberShortcode class is not the best approach here -- mainly because other Timber classes are convenience wrappers over 'physical' concepts in Wordpress (Post, Menu, Term, etc.), and in the case of shortcodes, I'm not really sure what you would wrap.
Normalize / sanitize $atts / pass them through the appropriate filters -- not sure how you would provide defaults in the constructor
Possibly differentiate between $shortcode.content (passed through the_content filter) and $shortcode.shortcode_content (in the raw form), much like TimberPost -- however, I don't have a particular use-case where I'd need the raw content
Possibly expand out $atts so that they can be accessed via $shortcode->some_attribute, etc.
On the other hand, the problems that have actually hindered implementing shortcodes are mostly around wpautop behavior and the limitation in nesting the same shortcode inside itself.
Hi, hopefully this is the right place to come with suggestions for Timber, since the guidelines encourage only bugs.
I was just implementing some custom shortcodes for a theme, and was thinking that having a TimberShortcode class to handle basic things you need to do on your content (escaping content, default parameters, normalizing the attribute key-case, etc.) would be a great addition.
I'll keep it short because I want to gauge the interest for such a feature, and I can look into specifics if you agree it's a step in the right direction.
A "proper" shortcode creation snippet from here:
The text was updated successfully, but these errors were encountered: