Add name_like query to get_terms(). Use it in suggestCategories.
git-svn-id: https://develop.svn.wordpress.org/trunk@5756 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b692c7395f
commit
66ec9bee20
|
@ -226,7 +226,7 @@ function &get_terms($taxonomies, $args = '') {
|
||||||
$defaults = array('orderby' => 'name', 'order' => 'ASC',
|
$defaults = array('orderby' => 'name', 'order' => 'ASC',
|
||||||
'hide_empty' => true, 'exclude' => '', 'include' => '',
|
'hide_empty' => true, 'exclude' => '', 'include' => '',
|
||||||
'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
|
'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 = wp_parse_args( $args, $defaults );
|
||||||
$args['number'] = (int) $args['number'];
|
$args['number'] = (int) $args['number'];
|
||||||
if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) ||
|
if ( !$single_taxonomy || !is_taxonomy_hierarchical($taxonomies[0]) ||
|
||||||
|
@ -309,6 +309,9 @@ function &get_terms($taxonomies, $args = '') {
|
||||||
$where = " AND t.slug = '$slug'";
|
$where = " AND t.slug = '$slug'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !empty($name_like) )
|
||||||
|
$where = " AND t.name LIKE '{$name_like}%'";
|
||||||
|
|
||||||
if ( '' != $parent ) {
|
if ( '' != $parent ) {
|
||||||
$parent = (int) $parent;
|
$parent = (int) $parent;
|
||||||
$where = " AND tt.parent = '$parent'";
|
$where = " AND tt.parent = '$parent'";
|
||||||
|
|
|
@ -546,13 +546,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||||
$limit = "LIMIT {$max_results}";
|
$limit = "LIMIT {$max_results}";
|
||||||
}
|
}
|
||||||
|
|
||||||
$category_suggestions = $wpdb->get_results("
|
$category_suggestions = get_categories("get=all&number=$max_results&name_like=$category");
|
||||||
SELECT cat_ID category_id,
|
|
||||||
cat_name category_name
|
|
||||||
FROM {$wpdb->categories}
|
|
||||||
WHERE cat_name LIKE '{$category}%'
|
|
||||||
{$limit}
|
|
||||||
");
|
|
||||||
|
|
||||||
return($category_suggestions);
|
return($category_suggestions);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue