Enable tag auto-suggest for multiple tags at once (without having to hit enter and send each one "down below"). fixes #5580

git-svn-id: http://svn.automattic.com/wordpress/trunk@8214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
markjaquith
2008-06-30 00:04:22 +00:00
parent eb3a3bae78
commit b45101a5d5
4 changed files with 33 additions and 8 deletions

View File

@@ -13,9 +13,14 @@ if ( isset($_GET['action']) && 'ajax-tag-search' == $_GET['action'] ) {
$s = $_GET['q']; // is this slashed already?
if ( strstr( $s, ',' ) )
die; // it's a multiple tag insert, we won't find anything
$results = $wpdb->get_col( $wpdb->prepare("SELECT name FROM $wpdb->terms WHERE name LIKE (%s)", '%' . $s . '%') );
if ( strstr( $s, ',' ) ) {
$s = explode( ',', $s );
$s = $s[count( $s ) - 1];
}
$s = trim( $s );
if ( strlen( $s ) < 2 )
die; // require 2 chars for matching
$results = $wpdb->get_col( "SELECT name FROM $wpdb->terms WHERE name LIKE ('%". $s . "%')" );
echo join( $results, "\n" );
die;
}