Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aslamatwebdevstudios/22f57900c964adba054f4d33a3c81cc0 to your computer and use it in GitHub Desktop.

Select an option

Save aslamatwebdevstudios/22f57900c964adba054f4d33a3c81cc0 to your computer and use it in GitHub Desktop.
Allow specific tags to be added in the Wordpress content editor
function mysite_allow_form_tags( $tags, $context) {
$tags['form'] = array(
'action' => true,
'method' => true,
'enctype' => true,
'name' => true,
'id' => true,
'class' => true,
'target' => true
);
$tags['input'] = array(
'type' => true,
'name' => true,
'value' => true,
'placeholder' => true,
'required' => true,
'autocomplete' => true,
'autofocus' => true,
'min' => true,
'max' => true,
'step' => true,
'pattern' => true,
'title' => true,
'class' => true,
'id' => true,
'style' => true,
// Allow JavaScript events
'onblur' => true,
'onchange' => true,
'onclick' => true,
'ondblclick' => true,
'onfocus' => true,
'onkeydown' => true,
'onkeypress' => true,
'onkeyup' => true,
'onmousedown' => true,
'onmousemove' => true,
'onmouseout' => true,
'onmouseover' => true,
'onmouseup' => true,
'onreset' => true,
'onselect' => true,
'onsubmit' => true,
'oninvalid' => true,
);
return $tags;
}
add_filter( 'wp_kses_allowed_html', 'mysite_allow_form_tags', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment