Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quicktags API Test
<?php
/*
Plugin Name: Quicktags API Test
Description: Testing a few different kinds of Quicktags buttons
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
*/
add_action( 'admin_print_footer_scripts', 'a_few_different_quicktags_buttons', 100 );
function a_few_different_quicktags_buttons() {
?>
<script type="text/javascript">
QTags.addButton( 'k_01', 'test 1', prompt_user );
function prompt_user(e, c, ed) {
prmt = prompt('Enter something');
if ( prmt === null ) return;
rtrn = '[short]' + prmt + '[/short]';
this.tagStart = rtrn;
QTags.TagButton.prototype.callback.call(this, e, c, ed);
}
QTags.addButton( 'k_02', 'test 2', simple_alert );
function simple_alert(e, c, ed) {
alert('hello');
}
QTags.addButton( 'k_03', 'test 3', '[selfclosing/]');
QTags.addButton( 'k_04', 'test 4', '[bookend]', '[/bookend]' );
</script>
<?php
}
@mattyrob

This comment has been minimized.

Copy link
Owner Author

@mattyrob mattyrob commented Dec 22, 2011

This adds another API test that implements a button for the HTML tag. It tags input for the title parameter and checks for open tags in QuickTags to make sure we close correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment