Ticket #15029: determine_ancestor_resource_type.15029.2.diff
| File determine_ancestor_resource_type.15029.2.diff, 2.2 KB (added by filosofo, 3 years ago) |
|---|
-
wp-includes/taxonomy.php
2795 2795 /** 2796 2796 * Get an array of ancestor IDs for a given object. 2797 2797 * 2798 * @since 3.0.0 2799 * 2798 2800 * @param int $object_id The ID of the object 2799 2801 * @param string $object_type The type of object for which we'll be retrieving ancestors. 2802 * @param string $resource_type. (Optional). Forces the resorce type used (post_type or taxonomy) 2803 * to overcome ambiguities. 2800 2804 * @return array of ancestors from lowest to highest in the hierarchy. 2801 2805 */ 2802 function get_ancestors($object_id = 0, $object_type = '' ) {2806 function get_ancestors($object_id = 0, $object_type = '', $resource_type = null ) { 2803 2807 $object_id = (int) $object_id; 2804 2808 2805 2809 $ancestors = array(); … … 2808 2812 return apply_filters('get_ancestors', $ancestors, $object_id, $object_type); 2809 2813 } 2810 2814 2811 if ( is_taxonomy_hierarchical( $object_type ) ) { 2815 if ( 2816 'taxonomy' == $resource_type || 2817 ( null === $resource_type && is_taxonomy_hierarchical( $object_type ) ) 2818 ) { 2812 2819 $term = get_term($object_id, $object_type); 2813 2820 while ( ! is_wp_error($term) && ! empty( $term->parent ) && ! in_array( $term->parent, $ancestors ) ) { 2814 2821 $ancestors[] = (int) $term->parent; 2815 2822 $term = get_term($term->parent, $object_type); 2816 2823 } 2817 } elseif ( null !== get_post_type_object( $object_type ) ) { 2824 } elseif ( 2825 'post_type' == $resource_type || 2826 null === $resource_type && null !== get_post_type_object( $object_type ) 2827 ) { 2818 2828 $object = get_post($object_id); 2819 2829 if ( ! is_wp_error( $object ) && isset( $object->ancestors ) && is_array( $object->ancestors ) ) 2820 2830 $ancestors = $object->ancestors; -
wp-admin/admin-ajax.php
560 560 561 561 $level = 0; 562 562 if ( is_taxonomy_hierarchical($taxonomy) ) { 563 $level = count( get_ancestors( $tag->term_id, $taxonomy ) );563 $level = count( get_ancestors( $tag->term_id, $taxonomy, 'taxonomy' ) ); 564 564 ob_start(); 565 565 $wp_list_table->single_row( $tag, $level ); 566 566 $noparents = ob_get_clean();
