3

The TinyMCE Editor has a great button in the kitchen sink to insert custom characters / symbols.

Is there a way to control what symbols show up in this pop-up? (Specifically I need some unique Hawaiian language characters 'okina and macrons).

Code    Character
Ā  Ā
ā  ā
Ē  Ē
ē  ē
Ī  Ī
ī  ī
Ō  Ō
ō  ō
Ū  Ū
ū  ū
ʻ  ʻ

Hawaiian Diacritical mark reference: http://manoa.hawaii.edu/site/hawaiian_language.html

3 Answers 3

3

This has to do with your character map for tinyMCE it's located inside:

wp-includes/js/tinymce/themes/advanced/js/charmap.js

Although I wouldn't recommend editing the WP-Core you could theoretically just add new characters there like so:

['Ī',     'Ī',  true,'I kahako'],
['Ō',     'Ō',  true,'O kahako'],

and so on...

However when you update Wordpress this will overwrite those changes. So it's not the best solution but it would work.

1
  • Thanks. I'm going to hold out hope that someone chimes in with a filter or something to control it or I'll try to hit up Ozz.
    – jb510
    Commented Oct 24, 2012 at 20:29
1

WordPress and TinyMCE both recently have been updated to allow you to modify the special characters (charmap) without having to hack the core. You can lookup the symbols you want from https://dev.w3.org/html5/html-author/charref and then either add the following code to your theme's functions.php or make a plugin:

add_filter( 'tiny_mce_before_init', 'tinymce_add_chars' );
function tinymce_add_chars( $settings ) {
    $new_chars = json_encode( array(
        array( '8224', 'Dagger' ),
        array( '8230', 'Horizontal ellipsis' ),
        array( '8539', '1/8 Fraction' ),
        array( '8730', 'Square Root' ),
        array( '8818', 'Less than or equivalent to' ),
        array( '8819', 'Greater than or equivalent to' ),
        array( '0963', 'Sigma' ),
        array( '0956', 'Mu' ),
    ) );
    $settings['charmap_append'] = $new_chars;
    return $settings;
}

This modification relies on the tiny_mce_before_init hook in WordPress and TinyMCE's charmap_append settings. When adding elements you add each symbol as an array where the first item is the HTML entity code and the second is the description.

You can see in the screenshot below that my symbols have been appended to the existing list of symbols.

enter image description here

It looks like it's possible to also override the default list of symbols by using TinyMCE's charmap setting and listing the symbols you want.

0

Its not that hard to write a plugin to replace something like !U !u !' with the Hawaiian characters. That way you can just type a bang in front of the letter while typing your post to get the character you want.

I did this for suit symbols for card playing sites and it works beautifully and was very easy to do. See http://bridgeteaching.com/2011/09/we-have-created-a-suit-symbol-plugin-for-wordpress/

3
  • Looking at your plugin page you're inserting images for the suit symbols. That's an awful solution for accented characters as it breaks and changes the word for search and screen readers. Even for card suits inline in text I'd suggest using the unicode characters J♠J♣J♥J♦ inline would be prefered to image replacement.
    – jb510
    Commented Aug 11, 2013 at 23:18
  • For card symbols, the supplied characters in a font are not good sizes for showing a hand of cards and the diamonds and hearts are not red. Far better looking to insert images. What are computer caches for if not to speed that up? Commented Aug 31, 2013 at 0:00
  • You can change font sizes and colors linline, and there are colored Unicode characters for hearts and diamonds.
    – jb510
    Commented Aug 31, 2013 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.