HTML Special Characters Helper

Author:Scott Reilly
Version:1.9.1
Last update:2012-12-16
Compatibility:WP 2.8 – 3.5.1
Comments:go here
Download:[ zip ]
Description:

Admin widget on the Write Post page for inserting HTML encodings of special characters into the post.

Extended Description

Admin widget on the Write Post page for inserting HTML encodings of special characters into the post.

The admin widget is labeled “HTML Special Characters” and is present in the admin Add/Edit Post and Add/Edit Page pages. Clicking on any special character in the widget causes its character encoding to be inserted into the post body text field at the current cursor location (or at the end of the post if the cursor isn’t located in the post body field). Hovering over any of the special characters causes a hover text box to appear that shows the HTML entity encoding for the character as well as the name of the character.

Note that when used in the visual editor mode the special character itself is added to the post body. Also note that the visual editor has its own special characters popup helper accessible via the advanced toolbar, which depending on your usage, may make this plugin unnecessary for you. In truth, the plugin is intended more for the non-visual (aka HTML) mode as that is the mode I (the plugin author) use.

Links: Plugin Homepage | Plugin Directory Page | Author Homepage

Find out more at the plugin’s WordPress Plugin Repository page.

Screenshots

Click to see full-size image.

  • html-special-characters-helper screenshot 1

    A screenshot of the HTML Special Characters admin widget in its default state

  • html-special-characters-helper screenshot 2

    A screenshot of the HTML Special Characters admin widget when “Toggle More” is clicked to display more special characters. Note all characters are categorized into labeled sections

  • html-special-characters-helper screenshot 3

    A screenshot of the HTML Special Characters admin widget after “Help?” is clicked

  • html-special-characters-helper screenshot 4

    A screenshot of the HTML Special Characters admin widget when the mouse is hovering over one of the special characters. The hover text that appears shows the HTML entity encoding for the character as well as the name of the character


Installation

  1. Unzip html-special-characters-helper.zip inside the /wp-content/plugins/ directory (or install via the built-in WordPress plugin installer)
  2. Activate the plugin through the ‘Plugins’ admin menu in WordPress
  3. An admin widget entitled “HTML Special Characters” will now be present in your write post and write page forms. Simply click on any character that you would like inserted into your post.

Filters

The plugin exposes two filters for hooking. Typically, customizations utilizing this hook would be put into your active theme’s functions.php file, or used by another plugin.

c2c_html_special_characters (filter)

The ‘c2c_html_special_characters’ hook allows you to remove existing characters or entire groups of characters, and/or add new characters or groups of characters.

Arguments:

  • $codes (array) : An association array in which the keys are a grouping name and the values are associative arrays themselves with the code as the key and the human-friendly descriptions as the values.

Example:

// Add a new grouping of characters (accented 'A's).
add_filter( 'c2c_html_special_characters', 'more_html_special_characters' );
function more_html_special_characters( $codes ) {
    $codes[''] = array(
        'char_a' => array(
            'À' => 'A grave accent',
            'Á' => 'A accute accent',
            'Â'  => 'A circumflex',
            'Ã' => 'A tilde',
            'Ä'   => 'A umlaut',
            'Å'  => 'A ring',
            'Æ'  => 'AE ligature'
        )
    );
    return $codes; // Important!
}

c2c_html_special_characters_post_type (filter)

The ‘c2c_html_special_characters_post_type’ hook allows you to specify which post_types for which the HTML Special Characters metabox should be shown.

Arguments:

  • $post_types (array) : An array of post types. By default, this value is array( 'page', 'post' )

Example:

// Show HTML Special Characters Helper for additional post_types
add_filter( 'c2c_html_special_characters_post_types', 'more_html_special_characters_post_types' );
function more_html_special_characters_post_types( $post_types ) {
    $post_types[] = 'products'; // Show for products
    unset( $post_types['page'] ); // Don't show for pages
    return $post_types;
}

Frequently Asked Questions

Q. How do I use the “HTML Special Characters” admin widget to insert special characters into other post fields (such as the post title)?
A. You can’t. The plugin only inserts the HTML character encodings into the post body. However, you can certainly hover over the character you want to use to see the HTML encoding for it (it’ll start with an ampersand, &, and end with a semi-color, ;) and type that into the field.

Q. I’ve activated the plugin and don’t see the “HTML Special Characters” admin widget when I go to write a post; where is it?
A. It is in the sidebar, most likely at the sidebar’s bottom.

Q. Have any references?
A. Try:


Release Log

1.9.1

  • Add check to prevent execution of code if file is directly accessed
  • Note compatibility through WP 3.5+
  • Update copyright date (2013)
  • Move screenshots into repo’s assets directory

1.9

  • Fix to show HTML entity encoding in tooltip instead of the character
  • Change how scripts and styles are enqueued
  • Add version() to return plugin version
  • Re-license as GPLv2 or later (from X11)
  • Add ‘Text Domain’, ‘License’, and ‘License URI’ header tags to readme.txt and plugin file
  • Add banner image for plugin page
  • Remove ending PHP close tag
  • Note compatibility through WP 3.4+

1.8

  • Add new filter ‘c2c_html_special_characters_post_type’ to allow support for other post types
  • Enqueue CSS
  • Enqueue JS
  • Add register_styles(), enqueue_admin_css(), enqueue_admin_js()
  • Remove insert_admin_css(), insert_admin_js()
  • Add support for localization
  • Add .pot
  • Update readme with example and documentation for new filter
  • Minor code reformatting (spacing)
  • Note compatibility through WP 3.3+
  • Drop support for versions of WP older than 2.8
  • Update all four screenshots (now based on WP 3.3)
  • Add ‘Domain Path’ directive to top of main plugin file
  • Add link to plugin directory page to readme.txt
  • Update copyright date (2012)

1.7.1

  • Add Filters section to readme.txt and document ‘c2c_html_special_characters’ filter
  • Note compatibility through WP 3.2+
  • Tiny code formatting change (spacing)
  • Fix plugin homepage and author links in description in readme.txt

1.7

  • Switch from object instantiation to direct class invocation
  • Explicitly declare all functions public|protected static and class variable public static
  • Output CSS statements in a collapsed, one-line per block format
  • Rename class function admin_init() to do_init()
  • Documentation tweaks
  • Note compatibility through WP 3.1+
  • Update copyright date (2011)

1.6

  • Extract all inline JavaScript into add_admin_js() and output via admin_print_footer_scripts action
  • Extract all inline CSS into add_admin_css()
  • Only output CSS on the add/edit post/page pages
  • Remove all references to $for (which was context variable that lingered from former rte popup)
  • Remove JavaScript related to inserting text into editor and just use send_to_editor()
  • Change the ‘Toggle more?’ link to ‘See more’/'See less’ (JavaScript toggles between the two as appropriate)
  • Move hooking of actions out of constructor and into class’s admin_init()
  • Rename add_css() to add_admin_css()
  • Assign object instance to global variable, $c2c_html_special_characters_helper, to allow for external manipulation
  • Rename class from ‘HTMLSpecialCharactersHelper’ to ‘c2c_HTMLSpecialCharactersHelper’
  • Don’t define class unless within admin section
  • Note compatibility with WP 3.0+
  • Minor code reformatting (spacing)
  • Remove documentation and instructions from top of plugin file (all of that and more are contained in readme.txt)
  • Add PHPDoc documentation
  • Add package info to top of file
  • Update copyright date
  • Add Upgrade Notice section to readme.txt

1.5

  • Added 78 new characters to extended characters listing: left-right arrow, carriage return arrow, lozenge, clubs, hearts, diamonds, spades, for all, there exists, empty set, intersection, union, backward difference, angle, logical and, logical or, 49 Greek characters, 5 double arrows, plus, minus, dot operator, orthogonal to, feminine ordinal indicator, masculine ordinal indicator, fraction slash, cedilla
  • Tweaked description of a few existing special characters
  • Reordered some of the existing special characters
  • Removed rich text editor toolbar button and all related code and files (including html-special-characters.php, and tinymce/*)
  • Added title attribute to links for Help and Toggle More
  • Removed create_dbx_box variable from class, since it controlled what is now the sole behavior of the plugin
  • Minor reformatting (spacing)
  • Updated screenshots
  • Updated copyright date
  • Noted compatibility through 2.8+
  • Dropped compatibility with versions of WP older than 2.6

1.0

  • Initial release

Copyright & Disclaimer

Copyright © 2009-2012 by Scott Reilly (aka coffee2code)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.