Extensible HTML Editor Buttons

I am currently no longer developing or supporting my WordPress plugins. I may resume development and support in the future, but I’m not sure when.

Extensible HTML Editor Buttons enhances the WordPress HTML Editor button bar in 5 ways:

  1. Gives you the option to replace the standard anchor and image buttons with new versions that provide modal input dialogs with more options (class, style, image width, height, etc.)
  2. Adds two new buttons: div and span, each with their own modal input dialogs, for class, style, etc. attributes (you can disable them if you wish)
  3. Provides a WYSIWYG settings form for adding your own custom buttons
  4. Provides an example HTML file, which you can follow to add your own custom modal input dialogs for your custom buttons, for setting tag attributes such as style, class, or any attributes you specify
  5. Provides an API for other plugins to add their own buttons and custom modal dialogs

It is multi-site compatible.

Get Help

Enter a post in the wordpress.org support forum for Post to Post Links II, and I’ll respond there.

Give Help

Adding your own buttons

To add your own buttons, just go to the Extensible HTML Editor Buttons settings menu and follow the instructions. If you want to create your own custom input dialogs, you need to create a file in your plugins/extensible-html-editor-buttons/display directory named “custom-dialogs.html” and put all of your custom dialogs there. Use the included custom-dialogs-example.html as a guide. As noted in the file comments, it’s crucial that you follow the naming conventions for the IDs in your form elements. You can see further details in this response I wrote to a support question.

Adding buttons from your own plugin

If you are a plugin author, and your plugin uses a shortcode, you can register a button for inserting your shortcode. In your PHP code you need to call Buttonable::registerButton(). I recommend doing this from your plugin’s function that is called by WordPress’ register_activation_hook. Here’s the phpDoc for the arguments it takes:

/**
 * For external plugins to register custom buttons. Registered
 * buttons are automatically set to active.
 *
 * @param string $handle the name of your custom button (eg: anchor)
 * @param string $tag the tag to insert, not including delimiters (eg: a)
 * @param string $title the title attribute for the button tag (eg: add anchor tag)
 * @param string $id the id attribute for the button tag; should start with ed_ (eg: ed_anchor)
 * @param string $selfClose 'y' if a self-closing tag (eg: an image tag) 'n' otherwise
 * @param string $shortcode 'y' if a WordPress shortcode tag, 'n' if an html tag
 * @param string $path optional path to the html file for the button's dialog, relative to the WP
 *     base dir (eg: /wp-content/plugins/your_plugin/anchor_dialog.html)
 * @static
 * @access public
 * @return true
 */

Here’s an example:

register_activation_hook(__FILE__, 'your_activation_function');

function your_activation_function() {
    if (method_exists('Buttonable', 'registerButton')) {
        return Buttonable::registerButton('blink', 'blink', 'Make annoying blink text', 'ed_blink', 'y', 'y', '/wp-content/plugins/your_plugin/blink_dialog.html');
    }

    return false;
}

You should call the deregister method from your plugin’s deactivation function. Here’s the phpDoc:

/**
 * To de-register a button. This should be called by your plugins deactivation hook
 *
 * @param string $handle the name of your custom button (eg: anchor)
 * @static
 * @access public
 * @return true
 */

And here’s an example:

register_deactivation_hook(__FILE__, 'your_deactivation_function');

function your_deactivation_function() {
    if (method_exists('Buttonable', 'deregisterButton')) {
        return Buttonable::deregisterButton('blink');
    }
    return false;
}