mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Allow get_object_taxonomies to return taxonomy objects. props scribu, fixes #13109.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14479 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6c69044070
commit
90a0883b12
@ -101,9 +101,10 @@ function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' )
|
||||
* @uses $wp_taxonomies
|
||||
*
|
||||
* @param array|string|object $object Name of the type of taxonomy object, or an object (row from posts)
|
||||
* @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
|
||||
* @return array The names of all taxonomy of $object_type.
|
||||
*/
|
||||
function get_object_taxonomies($object) {
|
||||
function get_object_taxonomies($object, $output = 'names') {
|
||||
global $wp_taxonomies;
|
||||
|
||||
if ( is_object($object) ) {
|
||||
@ -115,9 +116,9 @@ function get_object_taxonomies($object) {
|
||||
$object = (array) $object;
|
||||
|
||||
$taxonomies = array();
|
||||
foreach ( (array) $wp_taxonomies as $taxonomy ) {
|
||||
if ( array_intersect($object, (array) $taxonomy->object_type) )
|
||||
$taxonomies[] = $taxonomy->name;
|
||||
foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {
|
||||
if ( array_intersect($object, (array) $tax_obj->object_type) )
|
||||
$taxonomies[$tax_name] = ('names' == $output) ? $tax_name : $tax_obj;
|
||||
}
|
||||
|
||||
return $taxonomies;
|
||||
|
Loading…
Reference in New Issue
Block a user