Skip to content

Instantly share code, notes, and snippets.

@mattyrob
Forked from trepmal/qtags.php
Created December 22, 2011 19:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattyrob/1511571 to your computer and use it in GitHub Desktop.
Save mattyrob/1511571 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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