Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add custom tags to TinyMCE in WordPress
* Our client needed some data sent in XML tags from Gravity Forms notifications to their system. These tags were being stripped by
* TinyMCE when the client would switch from HTML to Visual. This was my fix for it.
function sennza_add_custom_tinymce_tags( $init ) {
// Command separated string of extended elements
$ext = 'name[*],phone[*],src[*],ip[*],notes[*],email[*]';
// Add to extended_valid_elements if it alreay exists
if ( isset( $init['extended_valid_elements'] ) ) {
$init['extended_valid_elements'] .= ',' . $ext;
} else {
$init['extended_valid_elements'] = $ext;
// Super important: return $init!
return $init;
add_filter('tiny_mce_before_init', 'sennza_add_custom_tinymce_tags');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment