members
members copied to clipboard
Feature request: wrap shortcode output in <div> with classes
Hi Justin, thank you for a terrific plugin! We use it here to put admin-only notes (for various levels of members) at the top of hundreds of knowledgebase posts. (Picture basic info/warning/similar CSS Bootstrap-esque alert boxes.)
These notes need to be styled. Rather than force the non-technical post authors to add CSS code in addition to the member_access shortcode, I would prefer to have the output wrapped in a div with classes that match the roles. Then I can just set up the CSS to style them nicely and they can add notes without worrying about HTML.
Justin and community, thoughts?
(Spoiler alert: I've already done a quick version of this in my fork of the code and am happy to send it now as a pull request, but am creating this issue first for discussion, per the contributing guidelines.)
The major problem here is the same as outlined in https://github.com/justintadlock/members/issues/3#issuecomment-148420716
Essentially, shortcodes can be both inline and block-level elements. My guess is that most people use the shortcodes as blocks rather than inline. And, that was the original intention. However, there is some backward-compatibility concerns there. I'm not sure what problems it might cause to just start making the output always block-level.
Ideas:
-
One thing that I can definitely do is provide filter hooks for all of the shortcode output. That would allow you to add filters to do custom output.
-
With Gutenberg planned for integration into WordPress 5.0, Members should provide a "block" using the Gutenberg system for showing/hiding content. This would kind of give a bit of a reset on the problem with the shortcode by using a totally new system.
Sure, I get it. Obviously filter hooks would do the job fine (please pass both the content and the parameters entered with the shortcode, thanks!). And/or it could be a checkbox in the settings: "Wrap shortcodes in <div>
?" (or <span>
).
I would bet you could assume that a user advanced enough to turn that on understands the inline vs block issues and can tweak their CSS as they wish. The goal is just to general useful markup; inline vs. block is strictly styling, right?
Or hooks would work. :-)