Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Feature request: wrap shortcode output in <div> with classes #177

Open
pnoeric opened this issue Jan 25, 2018 · 2 comments
Open

Feature request: wrap shortcode output in <div> with classes #177

pnoeric opened this issue Jan 25, 2018 · 2 comments

Comments

@pnoeric
Copy link

pnoeric commented Jan 25, 2018

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.)

@justintadlock
Copy link
Owner

The major problem here is the same as outlined in #3 (comment)

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:

  1. 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.

  2. 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.

@pnoeric
Copy link
Author

pnoeric commented Jan 25, 2018

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. :-)

@justintadlock justintadlock added this to the 3.0.0 milestone Jan 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants