[wp-hackers] WP Ideas: API for adding simple buttons to TinyMCE

Otto otto at ottodestruct.com
Fri Mar 19 18:09:38 UTC 2010


If you don't want to go the full tinyMCE plugin route, you could use
the "setup" trick to add simple button code:
http://tinymce.moxiecode.com/examples/example_20.php

To do this in a WP plugin, you'd hook to mce_buttons_2 (or 3, or 4) to
add your button to the list. Then you'd hook up a filter on
tiny_mce_before_init to add your javascript code to the
$initArray['setup']. That should be pretty much that, really.


-Otto



On Fri, Mar 19, 2010 at 12:01 PM, Jeremy Clarke <jer at simianuprising.com> wrote:
> Basic idea: Add a wrapper function to WP that can be called in a
> theme's functions.php (or a plugin) to add simple buttons to the
> Visual Editor. Things like <p class="translation">  or <p
> class="update"> that correspond with classes in the theme CSS. There
> are a lot of times when a button just needs to wrap a tag around a bit
> of text and it seems to me a general function that sets the before and
> after text (i.e. <p class="..."> and </p>) would be useful to almost
> every site with carefully considered CSS styles for posts.
>
> It's possible to add buttons like this to TinyMCE yourself manually in
> a plugin but its really, really complicated. Last time I checked it
> involved creating several files and basically becoming skilled at the
> TinyMCE API, something most theme/plugin devs would obviously rather
> avoid. For this reason I think it would make sense for WP to have a
> built-in way of adding simple buttons with only PHP. I am no good at
> javascript so I won't be the one to add it but someone out there who
> knows how to add buttons already could probably do it relatively
> easily.
>
> I posted about this on the Ideas Forum about a year ago:
> http://wordpress.org/extend/ideas/topic/create-easy-api-for-adding-simple-html-tag-buttons-to-tinymce
>
> Jane is cleaning out the ideas and will delete this one unless it gets
> some more traction so if you think its a good idea please go vote or
> leave a comment about it. I suppose if it gets enough votes in the
> next little while I'll create a Trac ticket out of it and we can deal
> with it in that format instead, otherwise we can delete it from ideas
> and let it fade into the annals of features that time forgot.
>
> --
> Jeremy Clarke | http://jeremyclarke.org
> Code and Design | http://globalvoicesonline.org
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list