Support » Fixing WordPress » Can I Add a Button to Visual Rich Editor?

  • Resolved Copernicus

    (@copernicus)


    Hello,

    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!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Copernicus

    (@copernicus)

    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!

    wow, you’re a good friend!

    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.

    Thread Starter Copernicus

    (@copernicus)

    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!)

    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?

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

    Does this not work in WP 2.0.5?

    It does not work with WP 2.05 at my blog

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

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Can I Add a Button to Visual Rich Editor?’ is closed to new replies.