Created
November 29, 2012 21:52
-
-
Save kzrl/4172164 to your computer and use it in GitHub Desktop.
AJAX autocomplete on wordpress admin pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /* From http://sudarmuthu.com/blog/using-wordpress-built-in-tag-auto-complete-script-in-your-plugins */ ?> | |
<?php | |
// Register hooks | |
add_action('admin_print_scripts', 'add_script'); | |
add_action('admin_head', 'add_script_config'); | |
/** | |
* Add script to admin page | |
*/ | |
function add_script() { | |
// Build in tag auto complete script | |
wp_enqueue_script( 'suggest' ); | |
} | |
/** | |
* add script to admin page | |
*/ | |
function add_script_config() { | |
?> | |
<script type="text/javascript" > | |
// Function to add auto suggest | |
function setSuggest(id) { | |
jQuery('#' + id).suggest("<?php echo get_bloginfo('wpurl'); ?>/wp-admin/admin-ajax.php?action=ajax-tag-search&tax=post_tag", {multiple:true, multipleSep: ","}); | |
} | |
</script> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment