Add name_like query to get_terms(). Use it in suggestCategories.

git-svn-id: http://svn.automattic.com/wordpress/trunk@5756 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-06-25 21:28:19 +00:00
parent 0e7483cc5a
commit 267997a4fd
2 changed files with 5 additions and 8 deletions

View File

@ -226,7 +226,7 @@ function &get_terms($taxonomies, $args = '') {
$defaults = array('orderby' => 'name', 'order' => 'ASC',
'hide_empty' => true, 'exclude' => '', 'include' => '',
'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
'hierarchical' => true, 'child_of' => 0, 'get' => '');
'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name_like' => '');
$args = wp_parse_args( $args, $defaults );
$args['number'] = (int) $args['number'];
if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) ||
@ -309,6 +309,9 @@ function &get_terms($taxonomies, $args = '') {
$where = " AND t.slug = '$slug'";
}
if ( !empty($name_like) )
$where = " AND t.name LIKE '{$name_like}%'";
if ( '' != $parent ) {
$parent = (int) $parent;
$where = " AND tt.parent = '$parent'";

View File

@ -546,13 +546,7 @@ class wp_xmlrpc_server extends IXR_Server {
$limit = "LIMIT {$max_results}";
}
$category_suggestions = $wpdb->get_results("
SELECT cat_ID category_id,
cat_name category_name
FROM {$wpdb->categories}
WHERE cat_name LIKE '{$category}%'
{$limit}
");
$category_suggestions = get_categories("get=all&number=$max_results&name_like=$category");
return($category_suggestions);
}