WordPress.org

Ready to get started?Download WordPress

Forums

CKEditor For WordPress
[resolved] Adding Custom Plugins / Buttons to CKEditor 4.0 WordPress 3.5 Toolbar (6 posts)

  1. own3mall
    Member
    Posted 1 year ago #

    Hi All,

    I tried following these guides to add custom buttons to the CKEditor toolbars that perform custom functions.

    I followed these guides and all attempts failed:

    http://ckeditor.com/forums/Plugins/HTML-Buttons.-Buttons-insert-any-HTML-you-want.

    https://ajithmanmadhan.wordpress.com/2009/12/16/customizing-ckeditor-and-adding-a-new-toolbar-button/

    http://stackoverflow.com/questions/1957156/ckeditor-how-to-add-a-custom-button-to-the-toolbar-that-calls-a-javascript-func

    Is there any easy way to add buttons in CKEditor 4.0 paired with WordPress 3.5? Have the steps changed that the guides mention? I've tried so many things. Any help is greatly appreciated.

    http://wordpress.org/extend/plugins/ckeditor-for-wordpress/

  2. msrosyidi
    Member
    Posted 1 year ago #

  3. solagirl
    Member
    Posted 1 year ago #

    @own3mall Hey, I think what you mentioned are dealing with how to create ckeditor plugins or add a plugin in the ckeditor way. But to add buttons to CKEditor For WordPress plugin's toolbar, you need to use the WordPress way.

    There are two filters you can use to load your custom ckeditor plugin and button.
    ckeditor_external_plugins - load custom plugins
    ckeditor_buttons - load custom buttons

    Use them together you can add your plugin, here is an example. But beware that this only adds buttons to the editor in back end. It can't change anything for comment area editor. To modify the comment editor, it's better to use ckeditor.config.js in my opinion.

    add_action('init', 'custom_ckeditor_interface');
    function custom_ckeditor_interface(){
    	add_filter( 'ckeditor_external_plugins', 'register_custom_ckeditor_plugins' );
    	add_filter( 'ckeditor_buttons', 'register_custom_ckeditor_buttons' );
    }
    //Load external ckeditor plugins
    function register_custom_ckeditor_plugins( $plugins ){
    	$plugins['your_plugin_name_1'] = 'your_plugin_uri_1';
    	$plugins['your_plugin_name_2'] = 'your_plugin_uri_2';
    	return $plugins;
    }
    //Add more buttons
    function register_custom_ckeditor_buttons( $buttons ){
    	$buttons[] = array('button_1');
    	$buttons[] = array('button_2');
    	return $buttons;
    }

    The plugin name and button name are defined in your ckeditor plugin scripts(eg. plugin.js)

  4. own3mall
    Member
    Posted 1 year ago #

    Hey Solagirl,

    I tried a variant of your solution, and it didn't work. My buttons didn't show up.

    Here's what I have:

    In ckeditor_wordpress.php:

    [Large code excerpt removed by moderator per forum rules. Please use the pastebin for all large code excerpts. It works better anyway.]

    The buttons don't show up. Any idea why? This is really frustrating!

  5. own3mall
    Member
    Posted 1 year ago #

    Forget my last post.

    I actually noticed that using the HTMLButtons plugin works fine for the comments, but I need this button in the full post editor.

    http://pastebin.com/p8KsE3NM

    So again, the basic works fine, but how do I add button1, button2, button3 to the full editor?

  6. own3mall
    Member
    Posted 1 year ago #

    I finally got it to work. I followed this blog:

    http://blog.eamster.tk/?p=100

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic