#10936 closed enhancement (worksforme)
Ability to add custom quicktags without modifying quicktags.js
Reported by: | aldenta | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | has-patch |
Focuses: | Cc: |
Description
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
Attachments (1)
Change History (3)
#1
follow-up:
↓ 2
@
14 years ago
- Milestone Unassigned deleted
- Resolution set to worksforme
- Status changed from new to closed
But you already can: The Right Way To Add Custom Quicktags.
Allow custom quicktags to be inserted before edToolbar() is called with do_action( 'quicktags' )