Last active
August 29, 2015 14:04
-
-
Save adamsilverstein/7741b38133fe3a593382 to your computer and use it in GitHub Desktop.
Allow on* JS handlers for IMG elements in WordPress / TinyMCE 4
This file contains 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
add_filter( 'tiny_mce_before_init', 'my_mce_init', 20 ); | |
function my_mce_init( $init ) { | |
if ( current_user_can('unfiltered_html') ) { | |
if ( ! empty( $init['extended_valid_elements'] ) ) { | |
$init['extended_valid_elements'] .= ','; | |
} else { | |
$init['extended_valid_elements'] = ''; | |
} | |
$init['extended_valid_elements'] .= 'img[id|accesskey|class|dir|lang|style|tabindex|title|contenteditable|contextmenu|draggable|dropzone|hidden|spellcheck|translate|src|alt=|usemap|ismap|width|height|name|longdesc|align|border|hspace|vspace|crossorigin|onclick|ondblclick|onmousedown|onmouseenter|onmouseleave|onmousemove|onmouseover|onmouseout|onmouseup|onkeydown|onkeypress|onkeyup]'; | |
} | |
return $init; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment