diff --git a/wp-includes/js/quicktags.dev.js b/wp-includes/js/quicktags.dev.js
index 6c5fff236d..6a36385135 100644
--- a/wp-includes/js/quicktags.dev.js
+++ b/wp-includes/js/quicktags.dev.js
@@ -48,7 +48,7 @@ function edInsertContent(bah, txt) {
/**
* Adds a button to all instances of the editor
*
- * Added for back compatibility
+ * Added for back compatibility, use QTags.addButton() as it gives more flexibility like type of button, button placement, etc.
* @see QTags.addButton()
*/
function edButton(id, display, tagStart, tagEnd, access, open) {
@@ -232,6 +232,10 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
tb.attachEvent('onclick', onclick);
}
+ t.getButton = function(id) {
+ return buttons[id];
+ };
+
if ( !qt.instances[0] )
qt.instances[0] = t;
@@ -252,7 +256,7 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
* Main API function for adding a button to Quicktags
*
* Adds qt.Button or qt.TagButton depending on the args. The first three args are always required.
- * For TagButton arg2 is also required. To be able to add button(s) to Quicktags, your script
+ * For TagButton the 4th or the 5th argument is also required. To be able to add button(s) to Quicktags, your script
* should be enqueued as dependant on "quicktags" and outputted in the footer. If you are echoing JS
* directly from PHP, use add_action( 'admin_print_footer_scripts', 'output_my_js', 100 ) or add_action( 'wp_footer', 'output_my_js', 100 )
*
@@ -263,21 +267,21 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
* Minimun required to add a button that inserts a tag:
* QTags.addButton( 'my_id', 'my button', '', '' );
*
- * @param id string required button HTML ID
- * @param display string required button's value="..."
- * @param arg1 string || function required either a starting tag to be inserted like "" or a callback that is executed when the button is pressed
- * @param arg2 string ending tag like ""
- * @param arg3 int set to -1 if the inserted tag is self-closing
- * @param access string access key for the button
- * @param title string button's title="..."
- * @param priority int number representing the desired position of the button in the toolbar. 1 - 9 = first, 11 - 19 = second, 21 - 29 = third, etc.
- * @return bool TRUE on success FALSE on failure
+ * @param id string required Button HTML ID
+ * @param display string required Button's value="..."
+ * @param arg1 string || function required Either a starting tag to be inserted like "" or a callback that is executed when the button is pressed
+ * @param arg2 string Ending tag like ""
+ * @param arg3 int Set to -1 if the inserted tag is self-closing
+ * @param access string Access key for the button
+ * @param title string Button's title="..."
+ * @param priority int Number representing the desired position of the button in the toolbar. 1 - 9 = first, 11 - 19 = second, 21 - 29 = third, etc.
+ * @return null This is needed for back-compat as the common method of adding a button was to manually add it to the buttons array
*/
qt.addButton = function( id, display, arg1, arg2, arg3, access, title, priority ) {
var btn;
if ( !id || !display )
- return false;
+ return;
if ( typeof(arg1) == 'function' ) {
btn = new qt.Button(id, display, access, title);
@@ -285,7 +289,7 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
} else if ( typeof(arg1) == 'string' && arg1 && arg2 ) {
btn = new qt.TagButton(id, display, arg1, arg2, access, arg3, title);
} else {
- return false;
+ return;
}
if ( priority ) {
@@ -297,8 +301,6 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
} else {
edButtons[edButtons.length] = btn;
}
-
- return true;
};
qt.insertContent = function(content) {
@@ -343,7 +345,7 @@ function edButton(id, display, tagStart, tagEnd, access, open) {
var access = this.access ? ' accesskey="' + this.access + '"' : '';
return '';
};
- qt.Button.prototype.callback = function(canvas) {};
+ qt.Button.prototype.callback = function(){};
// a button that inserts HTML tag
qt.TagButton = function(id, display, tagStart, tagEnd, access, open, title) {
diff --git a/wp-includes/js/quicktags.js b/wp-includes/js/quicktags.js
index c1dc21a9ee..c6e5268b1b 100644
--- a/wp-includes/js/quicktags.js
+++ b/wp-includes/js/quicktags.js
@@ -1 +1 @@
-var QTags,edButtons=[],edCanvas;function quicktags(a){return new QTags(a)}function edInsertContent(b,a){return QTags.insertContent(a)}function edButton(f,e,c,b,a,d){return QTags.addButton(f,e,c,b,d,a)}(function(){var c=function(h){var g,f,e;if(typeof jQuery!="undefined"){jQuery(document).ready(h)}else{g=c;g.funcs=[];g.ready=function(){if(!g.isReady){g.isReady=true;for(f=0;f'};d.Button.prototype.callback=function(e){};d.TagButton=function(l,j,g,f,e,h,k){var i=this;d.Button.call(i,l,j,e,k);i.tagStart=g;i.tagEnd=f;i.open=h};d.TagButton.prototype=new d.Button();d.TagButton.prototype.openTag=function(h,f){var g=this;if(!f.openTags){f.openTags=[]}if(g.tagEnd){f.openTags.push(g.id);h.value="/"+h.value}};d.TagButton.prototype.closeTag=function(j,f){var h=this,g=h.isOpen(f);if(g!==false){f.openTags.splice(g,1)}j.value=h.display};d.TagButton.prototype.isOpen=function(e){var h=this,g=0,f=false;if(e.openTags){while(f===false&&g0){g.text=u.tagStart+g.text+u.tagEnd}else{if(u.isOpen(q)===false||u.tagEnd===""){g.text=u.tagStart;u.openTag(o,q)}else{g.text=u.tagEnd;u.closeTag(o,q)}}j.focus()}else{if(j.selectionStart||j.selectionStart=="0"){p=j.selectionStart;f=j.selectionEnd;m=f;h=j.scrollTop;k=s.substring(0,p);e=s.substring(f,s.length);n=s.substring(p,f);if(p!=f){j.value=k+u.tagStart+n+u.tagEnd+e;if(u.tagEnd===""){m=p}m+=u.tagStart.length+u.tagEnd.length}else{if(u.isOpen(q)===false||u.tagEnd===""){j.value=k+u.tagStart+e;u.openTag(o,q);m=p+u.tagStart.length}else{j.value=k+u.tagEnd+e;m=p+u.tagEnd.length;u.closeTag(o,q)}}j.focus();j.selectionStart=m;j.selectionEnd=m;j.scrollTop=h}else{if(u.isOpen(q)!==false||u.tagEnd===""){j.value+=u.tagStart;u.openTag(o,q)}else{j.value+=u.tagEnd;u.closeTag(o,q)}j.focus()}}};d.SpellButton=function(){d.Button.call(this,"spell",quicktagsL10n.lookup,"",quicktagsL10n.dictionaryLookup)};d.SpellButton.prototype=new d.Button();d.SpellButton.prototype.callback=function(h,g,i){var k="",j,f,e;if(document.selection){g.focus();j=document.selection.createRange();if(j.text.length>0){k=j.text}}else{if(g.selectionStart||g.selectionStart=="0"){f=g.selectionStart;e=g.selectionEnd;if(f!=e){k=g.value.substring(f,e)}}}if(k===""){k=prompt(quicktagsL10n.wordLookup,"")}if(k!==null&&/^\w[\w ]*$/.test(k)){window.open("http://www.answers.com/"+encodeURIComponent(k))}};d.CloseButton=function(){d.Button.call(this,"close",quicktagsL10n.closeTags,"",quicktagsL10n.closeAllOpenTags)};d.CloseButton.prototype=new d.Button();d.CloseButton.prototype.callback=function(j,k,f){var h,g,i=f.openTags;if(i){while(i.length>0){h=f.getButton(i[i.length-1]);g=document.getElementById(f.name+"_"+h.id);h.callback.call(h,g,k,f)}}};d.prototype.closeAllTags=function(){var e=this.getButton("close");e.callback.call(e,"",this.canvas,this.toolbar)};d.LinkButton=function(){d.TagButton.call(this,"link","link","","","a")};d.LinkButton.prototype=new d.TagButton();d.LinkButton.prototype.callback=function(j,k,h,g){var f,i=this;if(typeof(wpLink)!="undefined"){wpLink.open();return}if(!g){g="http://"}if(i.isOpen(h)===false){f=prompt(quicktagsL10n.enterURL,g);if(f){i.tagStart='';d.TagButton.prototype.callback.call(i,j,k,h)}}else{d.TagButton.prototype.callback.call(i,j,k,h)}};d.ImgButton=function(){d.TagButton.call(this,"img","img","","","m",-1)};d.ImgButton.prototype=new d.TagButton();d.ImgButton.prototype.callback=function(i,k,g,f){if(!f){f="http://"}var j=prompt(quicktagsL10n.enterImageURL,f),h;if(j){h=prompt(quicktagsL10n.enterImageDescription,"");this.tagStart='';d.TagButton.prototype.callback.call(this,i,k,g)}};d.FullscreenButton=function(){d.Button.call(this,"fullscreen",quicktagsL10n.fullscreen,"f",quicktagsL10n.toggleFullscreen)};d.FullscreenButton.prototype=new d.Button();d.FullscreenButton.prototype.callback=function(f,g){if(g.id!="content"||typeof(fullscreen)=="undefined"){return}fullscreen.on()};edButtons[10]=new d.TagButton("strong","b","","","b");edButtons[20]=new d.TagButton("em","i","","","i"),edButtons[30]=new d.LinkButton(),edButtons[40]=new d.TagButton("block","b-quote","\n\n