Ready to get started?Download WordPress


Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

id:Quicktags API

Halaman ini berisi garis besar dari untuk API Quicktag (tombol pada editor HTML), yang ditambahkan setelah WP 3.3.

Ini adalah cuplikan yang diambil dari berkas quicktags.js, cukup berguna dan bisa dikembangkan sesuai keinginan:

 * 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.
 * To be able to add button(s) to Quicktags, your script should be enqueued as dependent
 * 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 )
 * If echoing the addButton calls directly instead of enqueing with the 'quicktags' dependency
 * make sure to check that the QTags object is defined first, otherwise your code will throw errors 
 * when no editor is present:
 *	if ( typeof QTags != 'undefined' ) { QTags.addButton(...) } 
 * Minimum required to add a button that calls an external function:
 *     QTags.addButton( 'my_id', 'my button', my_callback );
 *     function my_callback() { alert('yeah!'); }
 * Minimum required to add a button that inserts a tag:
 *     QTags.addButton( 'my_id', 'my button', '<span>', '</span>' );
 *     QTags.addButton( 'my_id2', 'my button', '<br />' );
 * @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 "<span>" or a callback that is executed when the button is clicked.
 * @param arg2 string optional Ending tag like "</span>"
 * @param access_key string optional Access key for the button.
 * @param title string optional Button's title="..." 
 * @param priority int optional Number representing the desired position of the button in the toolbar. 1 - 9 = first, 11 - 19 = second, 21 - 29 = third, etc.
 * @param instance string optional Limit the button to a specifric instance of Quicktags, add to all instances if not present.
 * @return mixed null or the button object that is needed for back-compat.
	qt.addButton = function( id, display, arg1, arg2, access_key, title, priority, instance ) {