Allow 'slug' param of get_terms() to accept an array.

Props jfarthing84, dlh.
Fixes #23636.

git-svn-id: https://develop.svn.wordpress.org/trunk@30042 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2014-10-28 14:56:33 +00:00
parent 6cbc9e03e1
commit c6de5dfec5
2 changed files with 38 additions and 3 deletions
+8 -3
View File
@@ -1594,7 +1594,7 @@ function get_term_to_edit( $id, $taxonomy ) {
* @type string $fields Term fields to query for. Accepts 'all' (returns an array of
* term objects), 'ids' or 'names' (returns an array of integers
* or strings, respectively. Default 'all'.
* @type string $slug Slug to return term(s) for. Default empty.
* @type string|array $slug Optional. Slug(s) to return term(s) for. Default empty.
* @type bool $hierarchical Whether to include terms that have non-empty descendants (even
* if $hide_empty is set to true). Default true.
* @type string $search Search criteria to match terms. Will be SQL-formatted with
@@ -1804,8 +1804,13 @@ function get_terms( $taxonomies, $args = '' ) {
}
if ( ! empty( $args['slug'] ) ) {
$slug = sanitize_title( $args['slug'] );
$where .= " AND t.slug = '$slug'";
if ( is_array( $args['slug'] ) ) {
$slug = array_map( 'sanitize_title', $args['slug'] );
$where .= " AND t.slug IN ('" . implode( "', '", $slug ) . "')";
} else {
$slug = sanitize_title( $args['slug'] );
$where .= " AND t.slug = '$slug'";
}
}
if ( ! empty( $args['name__like'] ) ) {