WordPress.org

Ready to get started?Download WordPress

Forums

Add custom button to TinyMCE? (10 posts)

  1. 3stripe
    Member
    Posted 8 years ago #

    Hi folks,

    I want to add a simple button to the WYSIWYG editor that wraps the selected text in a particular style (ie applies a span tag to it, with a class of say 'mp3link')

    I'm found a TinyMCE plugin called "tinyMCE div and have downloaded it from http://tincan.co.uk/?lid=1624 and put into the TinyMCE plugins folder.

    Now I'm trying to initiate this using my own plugin - but don't understand the syntax for the tinymce_plugins action.

    I know that I'm way off, but I'm using the code below for my plugin, how should I be doing it?

    'add_action('tinymce_plugins', 'add_divselect_to_tinyMCE');
    function add_divselect_to_tinyMCE()
    {
    plugins = new Array("divselect");
    return plugins;
    }'

    Thanks for your time.

  2. 3stripe
    Member
    Posted 8 years ago #

    According to the wiki:

    After you have inserted your javascript functions, you will need to modify the TinyMCE plugin list. This is done with the filter hook 'tinymce_plugins'. Your filter should take an array as its only argument, add your plugin's name to it and return it.

    But what does this mean exactly? I'm confused...

  3. 3stripe
    Member
    Posted 8 years ago #

    According to the wiki:

    After you have inserted your javascript functions, you will need to modify the TinyMCE plugin list. This is done with the filter hook 'tinymce_plugins'. Your filter should take an array as its only argument, add your plugin's name to it and return it.

    But what does this mean exactly? I'm confused...

  4. maerk
    Member
    Posted 8 years ago #

    Are you a particularly big fan of TinyMCE? It's just that I could really easily tell you how to do this with Quicktags, which works better :)

    There's another thing, Buttonsnap, which might do what you want:

    http://redalt.com/wiki/ButtonSnap

    I never worked out how to use that, though.

  5. 3stripe
    Member
    Posted 8 years ago #

    Hi thanks for the reply.

    I don't like it much, but I'v got users on my site who do, so I wanted this function to work!

    I've tried Buttonsnap as well, but have the same problem as you do - can't figure out how to use it! (My javascript isn't up to scratch)

    Didn't think this would be so hard!

  6. maerk
    Member
    Posted 8 years ago #

    Have a look at the actual javascript that TinyMCE uses. See if there's a way to customise it with buttons.

    If you look at the quicktags.js file (wp-includes/js) you can see it's actually quite easy to insert new buttons. Maybe tinyMCE is the same???

    It's a real shame that it's so hard to use this! It's very pretty, from what i recall (I disabled it almost instantly, too many bugs).

  7. 3stripe
    Member
    Posted 8 years ago #

    Maybe I should just wean the other users off it.

    But I've spent so much time on this I'm kinda tempted to figure this out!

  8. maerk
    Member
    Posted 8 years ago #

    It's definately possible. Keep trying and you'll get there.

    I'd wager that TinyMCE is an external thing that someone developped that was then got incorporated into WP. Try to find its site and maybe you can ask the developer -- but try to find his/her preferred method of being asked for support. Nothing worse than being pestered by emails :)

  9. 3stripe
    Member
    Posted 8 years ago #

    I've tried the TinyMCE forum, and the author of the plugin, no replies yet...

    Who knows, maybe we can build a nice plugin for WordPress to automate the process!

  10. maerk
    Member
    Posted 8 years ago #

    The guy that runs redalt is quite friendly, I think. I only ever emailed him once, but he seems nice ;)

    I have to say, I only tried to use TinyMCE once, but my javascript knowledge is minimal and I didn't really need it for what I was doing. But it looked like the sort of thing that once I'd worked out how to do it, it would leave me with a lot more javascript expertise, so it's worth going for, definately.

    You'll be writing your own wordpress plugins in no time!

Topic Closed

This topic has been closed to new replies.

About this Topic