diff --git src/wp-includes/taxonomy-functions.php src/wp-includes/taxonomy-functions.php
index a20ce7c..bd69ae9 100644
|
|
|
function get_taxonomies( $args = array(), $output = 'names', $operator = 'and' )
|
| 153 | 153 | |
| 154 | 154 | $field = ('names' == $output) ? 'name' : false; |
| 155 | 155 | |
| 156 | | return wp_filter_object_list($wp_taxonomies, $args, $operator, $field); |
| | 156 | // Handle 'object_type' separately. |
| | 157 | if ( isset( $args['object_type'] ) ) { |
| | 158 | $object_type = (array) $args['object_type']; |
| | 159 | unset( $args['object_type'] ); |
| | 160 | } |
| | 161 | |
| | 162 | $taxonomies = wp_filter_object_list( $wp_taxonomies, $args, $operator ); |
| | 163 | |
| | 164 | if ( isset( $object_type ) ) { |
| | 165 | foreach ( $taxonomies as $tax => $tax_data ) { |
| | 166 | if ( ! array_intersect( $object_type, $tax_data->object_type ) ) { |
| | 167 | unset( $taxonomies[ $tax ] ); |
| | 168 | } |
| | 169 | } |
| | 170 | } |
| | 171 | |
| | 172 | if ( $field ) { |
| | 173 | $taxonomies = wp_list_pluck( $taxonomies, $field ); |
| | 174 | } |
| | 175 | |
| | 176 | return $taxonomies; |
| 157 | 177 | } |
| 158 | 178 | |
| 159 | 179 | /** |
diff --git tests/phpunit/tests/taxonomy.php tests/phpunit/tests/taxonomy.php
index 5a6af2e..fbdebaa 100644
|
|
|
class Tests_Taxonomy extends WP_UnitTestCase {
|
| 482 | 482 | |
| 483 | 483 | $this->assertFalse( is_tax( 'wptests_tax' ) ); |
| 484 | 484 | } |
| | 485 | |
| | 486 | /** |
| | 487 | * @ticket 27918 |
| | 488 | */ |
| | 489 | public function test_get_taxonomies_filtered_by_object_type() { |
| | 490 | register_post_type( 'wptests_pt' ); |
| | 491 | register_taxonomy( 'wptests_tax_1', 'wptests_pt' ); |
| | 492 | register_taxonomy( 'wptests_tax_2', array( 'wptests_pt', 'post' ) ); |
| | 493 | register_taxonomy( 'wptests_tax_3', 'post' ); |
| | 494 | |
| | 495 | $taxonomies = get_taxonomies( array( |
| | 496 | 'object_type' => array( 'wptests_pt' ), |
| | 497 | ) ); |
| | 498 | |
| | 499 | $this->assertContains( 'wptests_tax_1', $taxonomies ); |
| | 500 | $this->assertContains( 'wptests_tax_2', $taxonomies ); |
| | 501 | $this->assertNotContains( 'wptests_tax_3', $taxonomies ); |
| | 502 | } |
| 485 | 503 | } |