Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion js/shortcode-quicktag-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@ window.wp_sc_buttons = window.wp_sc_buttons || {};
return content;
};

/**
* Event handler to remove the custom Quicktags button
* from wysiwyg editor added to shortcode modal if "include_close" is set to true,
* by hooking into the "quicktags-init" event
*
* @param {document#event:quicktags-init} evt
* @param {object} ed - The current quicktags editor instance
* @see {@link https://github.com/WordPress/WordPress/blob/master/wp-includes/js/quicktags.js#L266-L325|WordPress Quicktags}
* @see {@link https://github.com/jtsternberg/Shortcode_Button/blob/master/lib/class-shortcode-button.php#L236-L247|Shortcode Button}
* @see {@link https://github.com/WebDevStudios/WDS-Shortcodes/issues/7|WDS-Shortcodes Issue #7}
*/
var removeQTagsButton = function( evt, ed ) {
if( ed.id === 'sccontent' && btns.qt ) {
for( var id in btns.qt ) {
// Remove the HTML element from the quicktags editor toolbar
ed.toolbar.removeChild( QTags.getInstance('sccontent').getButtonElement(id));
// Remove the custom button object from the quicktags editor
delete ed.theButtons[id];
}
}
};

btns.log = function() {
btns.log.history = btns.log.history || [];
btns.log.history.push( arguments );
Expand Down Expand Up @@ -517,6 +539,6 @@ window.wp_sc_buttons = window.wp_sc_buttons || {};
$c.body.trigger( 'shortcode_button:jquery_init_complete' );
};

$( btns.jQueryInit );
$( btns.jQueryInit ).on( 'quicktags-init', removeQTagsButton );

} )( window, document, jQuery, wp, QTags, shortcodeButtonsl10n, wp_sc_buttons );
Loading