Ready to get started?Download WordPress


[resolved] Can I Add a Button to Visual Rich Editor? (11 posts)

  1. Copernicus
    Posted 7 years ago #


    I've searched & searched and cannot find a clear answer about how to do the following...

    I want to add some sort of option (probably a drop-down menu) for changing text in a post to have a headline tag of some kind (h1, h2, etc.). But, most of the forum posts regarding this simply have "why not do it by hand?" as the reply.

    The set-up of WP is for a friend that doesn't know anything about HTML and needs the benefit of the WYSIWYG editor. Is there any way to add buttons to the native visual rich editor?

    I've found this document http://tinymce.moxiecode.com/tinymce/docs/option_valid_elements.html
    but am not sure how one might use that within WP.

    Any other options or ideas?

    Thanks for any & all help!

  2. Copernicus
    Posted 7 years ago #

    OK, I may have found the solution (I'm not 100% on this, so verification from someone else would be greatly appreciated!) and am posting it here so that others searching for the same problem might find my solution helpful.

    1. Visit http://tinymce.moxiecode.com/tinymce/docs/reference_buttons.html to find the name of the button you are interested in added. In my case, I wanted to add a method for applying a format to a paragraph (h1, h2, etc.) this is called "formatselect."
    2. Open the file "tiny_mce_gzip.php" in the "tinymce" folder within the "js" folder that's within the "wp-includes" folder. So, it's wp-includes>js>tinymce>tiny_mce_gzip.php
    3. Find the code that reads:
      $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright' ,'separator', 'link', 'unlink', 'image', 'wordpress', 'separator', 'undo', 'redo', 'code', 'wphelp'));
    4. Add the button name that you wish to have show up in the button array. In my case, I wanted "formatselect" so I modified the code to display as:
      $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'formatselect', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright' ,'separator', 'link', 'unlink', 'image', 'wordpress', 'separator', 'undo', 'redo', 'code', 'wphelp')); (adding both "formatselect" and a separator)

    That's it!

  3. flush
    Posted 7 years ago #

    wow, you're a good friend!

  4. Best to not modify the core and instead make a mini-plugin like this one.

    Or if you want to add totally custom buttons like I've done, just use the great PHP class called ButtonSnap.

  5. Copernicus
    Posted 7 years ago #

    Viper007Bond: THANK YOU.

    Thank you, thank you, thank you.

    In all my searching, I never saw that "mini-plugin." It is absolutely perfect; and, from what I've seen in these support forums, a plug-in for which many more people are looking. Hopefully, this post will help them find it.

    (also: your video Quicktag plug-in looks quite good. I'll download that for future reference!)

  6. Ajay
    Posted 7 years ago #

    Hey Viper,

    Thanks for the link. Got really fed up searching for how exactly to add a button.

    Any clue on where to add it in the codex?

  7. Ajay
    Posted 7 years ago #

    I realize that Button Snap will not work with WP1.5 right?

  8. nolageek
    Posted 7 years ago #

    Does this not work in WP 2.0.5?

  9. Start1
    Posted 7 years ago #

    It does not work with WP 2.05 at my blog

  10. crunch42
    Posted 7 years ago #

    Why is this not in the core? H1 tags are a basic building block of the web.

  11. Chris_K
    Posted 7 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic