Adding more buttons to the WordPress post editor

For years, I’ve found the fact that the integrated in WordPress WYSIWYG editor(TinyMCE) has so much buttons cut out by default, with no native way for the user to enable them(Font select, Font size select, Charmap, Cut, Copy, Paste, Format select, Style select, Forecolor, Backcolorpicker etc.). Here I showed you how you can enable Fontsize and Fontselect, but this snippet doesn’t seem to work for the new versions of WordPress(Since 3.7.x maybe), So I’ll give you a new plugin with the help of which you’ll be able to unlock various buttons and extend the functionality of the great WordPress editor even further.

 

<?php 
/**  
* Plugin Name: Expand WordPress editor By WebBamboo  
* Plugin URI: http://awordpress.net  
* Description: Adding the missing buttons in the TinyMCE Post Editor(Font select, Font size select, Charmap, Cut, Copy, Paste, Format select, Style select, Forecolor, Backcolorpicker)  
* Version: 0.0.1  * Author: Web Bamboo Ltd.  
* Author URI: http://webbamboo.net  
* License: GPL2  
*/  
class ExpandTinyMCEButtons  {     
    private static $instance;     
    private static $options;     
    /**      
    * Get active object instance      
    *      
    * @since 1.0      
    *      
    * @access public      
    * @static      
    * @return object      
    */     
    public static function get_instance() {         
        if (!self::$instance)             
            self::$instance = new ExpandTinyMCEButtons();         
        return self::$instance;     
    }     
    /**      
    * Class constructor.  Includes constants, includes and init method.      
    *      
    * @since 1.0      
    *      
    * @access public      
    * @return void      
    */     
    public function __construct() {         
        $this->init();
    }

    /**
     * Run action and filter hooks.
     *
     * @since 1.0
     *
     * @access private
     * @return void
     */
    private function init() {
        add_filter("mce_buttons_3", array($this, "wb_add_tinymce_buttons"));//mce_buttons_3 will add a third row of buttons in the editor, if you want to add the buttons to the second row use mce_buttons_2
    }
    public static function wb_add_tinymce_buttons($buttons)
    {
        $buttons[] = 'charmap';
        $buttons[] = 'cut';
        $buttons[] = 'copy';
        $buttons[] = 'paste';
        $buttons[] = 'formatselect';
        $buttons[] = 'fontselect';
        $buttons[] = 'fontsizeselect';
        $buttons[] = 'styleselect';
        $buttons[] = 'forecolor';
        $buttons[] = 'backcolorpicker';
        $buttons[] = 'charmap';
        return $buttons;
    }
}
ExpandTinyMCEButtons::get_instance();

The full list of buttons is (of course some of them are already enabled by default):

  • bold
  • italic
  • underline
  • strikethrough
  • justifyleft
  • justifycenter
  • justifyright
  • justifyfull
  • bullist
  • numlist
  • outdent
  • indent
  • cut
  • copy
  • paste
  • undo
  • redo
  • link
  • unlink
  • image
  • cleanup
  • help
  • code
  • hr
  • removeformat
  • formatselect
  • fontselect
  • fontsizeselect
  • styleselect
  • sub
  • sup
  • forecolor
  • backcolor
  • forecolorpicker
  • backcolorpicker
  • charmap
  • visualaid
  • anchor
  • newdocument
  • blockquote
  • separator ( | is possible as separator, too)