jtsternberg / Shortcode_Button

Tinymce and Quicktag buttons for outputting shortcodes. Built to work with CMB2.
81 stars 7 forks source link

Add shortcode atts to _before_send filters #17

Closed JiveDig closed 7 years ago

JiveDig commented 7 years ago

Thanks for this class, it's awesome.

I have a complex shortcode that is way overkill to try to display correctly in the admin. I'm using these filters https://github.com/jtsternberg/Shortcode_Button/blob/master/lib/class-shortcode-button.php#L463-L464 to just render a clean block with some text in the admin as a pseudo-placeholder, mostly so I can utilize the built-in Edit/Remove functionality.

If I had access to the original or sanitized shortcode atts, I could better customize the admin display/HTML according to a few key parameters in my shortcode.

Hope that makes sense. Thanks.

JiveDig commented 7 years ago

I can't think of a way to get the atts passed to this class, so totally okay if you wanna close this issue. Just figured I'd mention it cause it would be cool if you can think of a way.

jtsternberg commented 7 years ago

I did a bit of refactoring. Now the 2nd param to those filters is an instance of Shortcode_Button_MCE and has 4 accessible properties:

$mce_handler->full_shortcode - The full shortcode being parsed in the tinymce instance. $mce_handler->post_id - The admin post being edited. $mce_handler->atts - The parsed shortcode attributes. $mce_handler->btn - The original Shortcode_Button object.

Will release an update once i get #19 in.