Gheek.net

November 7, 2008

How to add a button to your wordpress default WYSIWYG

Filed under: javascript, wordpress — Tags: , — lancevermilion @ 12:33 pm

First you will need to edit your default javascript file called “quicktags.js”.

vi /wp-includes/js/quicktags.js

Find something that looks like the entry below. This will be your Bold or if you prefer HTML language strong button.

edButtons[edButtons.length] =
new edButton('ed_strong'
,'b'
,''
,''
,'b'
);

You can add anything after that or before that. For example I use WP-CodeBox for all of my code entries. It puts them in these pretty boxes with some nice features if I encase my code in a pre statement and tell it what type of language. So I simply added a new button called pre and adds the pre statement to the beginning and to the end of the highlighted text. I also told it to define the language by default as just text.

Please note WP-CodeBox will not handle HTML pre syntax so I have modified it like so.

 

.

edButtons[edButtons.length] =
new edButton('ed_pre'
,'pre'
,'
'
,'

'
,'c'
);

Blog at WordPress.com.