Taxonomies: make sure taxonomy functions work correctly with taxonomy names with special characters

The codex says that taxonomy names "should only contain lowercase letters and the underscore character", but that's not enforced. It's too late to enforce it, since some plugins haven't been following it and the official phpdoc doesn't mention this restriction.

Merge of [37133] to the 3.9 branch.

Built from https://develop.svn.wordpress.org/branches/3.9@37140


git-svn-id: http://core.svn.wordpress.org/branches/3.9@37107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Nikolay Bachiyski 2016-03-30 17:38:15 +00:00
parent 594a9e14e7
commit 7da57d4ef3

View File

@ -595,7 +595,7 @@ function get_objects_in_term( $term_ids, $taxonomies, $args = array() ) {
$term_ids = array_map('intval', $term_ids );
$taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
$taxonomies = "'" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "'";
$term_ids = "'" . implode( "', '", $term_ids ) . "'";
$object_ids = $wpdb->get_col("SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tt.term_id IN ($term_ids) ORDER BY tr.object_id $order");
@ -1396,7 +1396,7 @@ function get_terms($taxonomies, $args = '') {
if ( '' !== $order && !in_array( $order, array( 'ASC', 'DESC' ) ) )
$order = 'ASC';
$where = "tt.taxonomy IN ('" . implode("', '", $taxonomies) . "')";
$where = "tt.taxonomy IN ('" . implode("', '", array_map( 'esc_sql', $taxonomies ) ) . "')";
$inclusions = '';
if ( ! empty( $include ) ) {
$exclude = '';
@ -2254,7 +2254,7 @@ function wp_get_object_terms($object_ids, $taxonomies, $args = array()) {
if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) )
$order = 'ASC';
$taxonomies = "'" . implode("', '", $taxonomies) . "'";
$taxonomies = "'" . implode("', '", array_map( 'esc_sql', $taxonomies ) ) . "'";
$object_ids = implode(', ', $object_ids);
$select_this = '';
@ -3931,4 +3931,4 @@ function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
return $parent;
}
}