From 649a1fad73c8461ddd2288ed2cf9f0a17ad488d4 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Sat, 23 Apr 2011 09:27:37 +0000 Subject: [PATCH] Prevent $taxonony->object_type containing duplicate values. Initial patch props kevinB. Fixes #16951 git-svn-id: https://develop.svn.wordpress.org/trunk@17688 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/taxonomy.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 3ed69bfdbb..1d368e3359 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -354,7 +354,7 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { unset( $args['capabilities'] ); $args['name'] = $taxonomy; - $args['object_type'] = (array) $object_type; + $args['object_type'] = array_unique( (array)$object_type ); $args['labels'] = get_taxonomy_labels( (object) $args ); $args['label'] = $args['labels']->name; @@ -437,7 +437,8 @@ function register_taxonomy_for_object_type( $taxonomy, $object_type) { if ( ! get_post_type_object($object_type) ) return false; - $wp_taxonomies[$taxonomy]->object_type[] = $object_type; + if ( ! in_array( $object_type, $wp_taxonomies[$taxonomy]->object_type ) ) + $wp_taxonomies[$taxonomy]->object_type[] = $object_type; return true; }