From 4177b48b1e30856083b49c4488d08fb4dbc7cf1f Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Tue, 28 Oct 2014 14:57:22 +0000 Subject: [PATCH] Allow 'slug' param of `get_terms()` to accept an array. Props jfarthing84, dlh. Fixes #23636. Built from https://develop.svn.wordpress.org/trunk@30042 git-svn-id: http://core.svn.wordpress.org/trunk@30042 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 11 ++++++++--- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index b8261dfeec..fffc05f986 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -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'] ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index f227fe22ed..e3ac4bdeaf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.1-alpha-30041'; +$wp_version = '4.1-alpha-30042'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.