Created
September 26, 2023 17:18
-
-
Save aslamatwebdevstudios/22f57900c964adba054f4d33a3c81cc0 to your computer and use it in GitHub Desktop.
Allow specific tags to be added in the Wordpress content editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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