Make WordPress Core

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#10936 closed enhancement (worksforme)

Ability to add custom quicktags without modifying quicktags.js

Reported by: aldenta's profile aldenta Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch
Focuses: Cc:


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'
		,'<p class=\"wp-caption-text\">'
	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.



Attachments (1)

general-template.diff (405 bytes) - added by aldenta 15 years ago.
Allow custom quicktags to be inserted before edToolbar() is called with do_action( 'quicktags' )

Download all attachments as: .zip

Change History (3)

15 years ago

Allow custom quicktags to be inserted before edToolbar() is called with do_action( 'quicktags' )

#1 follow-up: @scribu
15 years ago

  • Milestone Unassigned deleted
  • Resolution set to worksforme
  • Status changed from new to closed

#2 in reply to: ↑ 1 @aldenta
15 years ago

Replying to scribu:
Thanks so much scribu. I searched all around and never found that.

Note: See TracTickets for help on using tickets.