0

can i use html tags in shortcode attributes? like this:

function b_text( $atts, $content = null ) {
  extract( shortcode_atts( array(
    'text' => '<div class="myClass">DOM</div>'
  ), $atts ) );
  ob_start();
?> 

  <div>
    <div> <?php echo $text; ?></div>
  </div>

<?php 
  $content = ob_get_contents();
  ob_end_clean();
  return $content;
}

add_shortcode('b-text', 'b_text');

Probably i can use some actions or filters to redefine my html content in atts? it is at all possible? thanks!

1 Answer 1

0

While it is a technically possibility, it's most likely direction that isn't worth it.

Overuse of shortcodes for what is essentially (crappy) templating is problematic and has a history of security issues.

In recent months there has been ongoing planning and discussion about possibility of changes to shortocde syntax and mechanics in core. HTML in attributes is explicitly named as one of the problems that led to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.