Skip to content

Commit

Permalink
Add CodeColorer options to the list of allowed attributes of the <cod…
Browse files Browse the repository at this point in the history
…e> tag in TinyMCE
  • Loading branch information
kpumuk committed Jul 30, 2017
1 parent a018b55 commit d14843c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions codecolorer.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public static function adminInit()
// add_filter('mce_external_plugins', array('CodeColorerLoader', 'addTinyMCEPlugin'));
// add_filter('mce_buttons', array('CodeColorerLoader', 'registerTinyMCEButton'));
// }
add_filter('tiny_mce_before_init', array('CodeColorerLoader', 'addTinyMCEValidElements'));
add_filter('teeny_mce_before_init', array('CodeColorerLoader', 'addTinyMCEValidElements'));
}
}

Expand Down Expand Up @@ -216,6 +218,19 @@ public static function addTinyMCEPlugin($plugins)
return $plugins;
}

public static function addTinyMCEValidElements($init) {
$knownOptions = CodeColorerOptions::parseOptions('');
$ext = 'code[' . implode('|', array_keys($knownOptions)) . ']';

if (isset($init['extended_valid_elements'])) {
$init['extended_valid_elements'] .= ',' . $ext;
} else {
$init['extended_valid_elements'] = $ext;
}

return $init;
}

public static function callShowOptionsPage()
{
$codecolorer = &CodeColorer::getInstance();
Expand Down

0 comments on commit d14843c

Please sign in to comment.