[wp-trac] [WordPress Trac] #10936: Ability to add custom quicktags without modifying quicktags.js

WordPress Trac wp-trac at lists.automattic.com
Fri Oct 9 18:49:10 UTC 2009


#10936: Ability to add custom quicktags without modifying quicktags.js
-------------------------+--------------------------------------------------
 Reporter:  aldenta      |       Owner:            
     Type:  enhancement  |      Status:  new       
 Priority:  normal       |   Milestone:  Unassigned
Component:  Editor       |     Version:            
 Severity:  normal       |    Keywords:  has-patch 
-------------------------+--------------------------------------------------
 I've tried to figure out a way to add custom quicktags to the HTML editor
 to make inserting code easier for my clients but I can't seem to find a
 way without modifying core code.  All examples on the web also suggest
 editing the quicktags.js (which is compressed) but I'd prefer not to go
 that route.

 The simplest way I found to make this possible is adding a 'quicktags'
 action which is in the attached patch.  Then, you can do something like
 the following example to create a custom quicktag.

 {{{
 function custom_quicktags() {
         echo '<script type="text/javascript" charset="utf-8">';
         echo "edButtons[edButtons.length] =
                 new edButton('ed_caption'
                 ,'caption'
                 ,'<p class=\"wp-caption-text\">'
                 ,'</p>'
                 ,'caption'
                 );";
         echo '</script>';
 }
 add_action('quicktags', 'custom_quicktags');
 }}}

 It could also be enhanced to use a filter or other PHP function that
 utilizes the same parameters as edButton and prints a list of edButton
 objects before edToolbar() is called.

 Right now, I only updated the patch to include general-template.php.
 However, press-this.php also calls wp_print_scripts( 'quicktags' ); but no
 quicktags are shown in the html view.

 Thanks.

 John

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10936>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list