Changeset 30141 for trunk/src/wp-includes/taxonomy.php
- Timestamp:
- 11/01/2014 02:57:31 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/taxonomy.php
r30122 r30141 4055 4055 if ( $t->rewrite['hierarchical'] ) { 4056 4056 $hierarchical_slugs = array(); 4057 $ancestors = get_ancestors( $term->term_id, $taxonomy);4057 $ancestors = get_ancestors( $term->term_id, $taxonomy, 'taxonomy' ); 4058 4058 foreach ( (array)$ancestors as $ancestor ) { 4059 4059 $ancestor_term = get_term($ancestor, $taxonomy); … … 4280 4280 * Get an array of ancestor IDs for a given object. 4281 4281 * 4282 * @param int $object_id The ID of the object 4283 * @param string $object_type The type of object for which we'll be retrieving ancestors. 4284 * @return array of ancestors from lowest to highest in the hierarchy. 4285 */ 4286 function get_ancestors($object_id = 0, $object_type = '') { 4282 * @since 3.1.0 4283 * @since 4.1.0 Introduced the 'resource_type' parameter. 4284 * 4285 * @param int $object_id The ID of the object. 4286 * @param string $object_type The type of object for which we'll be retrieving ancestors. 4287 * Accepts a post type or a taxonomy name. 4288 * @param string $resource_type Optional. Type of resource $object_type is. Accepts 'post_type' or 'taxonomy'. 4289 * @return array An array of ancestors from lowest to highest in the hierarchy. 4290 */ 4291 function get_ancestors( $object_id = 0, $object_type = '', $resource_type = '' ) { 4287 4292 $object_id = (int) $object_id; 4288 4293 … … 4292 4297 4293 4298 /** This filter is documented in wp-includes/taxonomy.php */ 4294 return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type ); 4295 } 4296 4297 if ( is_taxonomy_hierarchical( $object_type ) ) { 4299 return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type ); 4300 } 4301 4302 if ( ! $resource_type ) { 4303 if ( is_taxonomy_hierarchical( $object_type ) ) { 4304 $resource_type = 'taxonomy'; 4305 } else if ( post_type_exists( $object_type ) ) { 4306 $resource_type = 'post_type'; 4307 } 4308 } 4309 4310 if ( 'taxonomy' === $resource_type ) { 4298 4311 $term = get_term($object_id, $object_type); 4299 4312 while ( ! is_wp_error($term) && ! empty( $term->parent ) && ! in_array( $term->parent, $ancestors ) ) { … … 4301 4314 $term = get_term($term->parent, $object_type); 4302 4315 } 4303 } elseif ( post_type_exists( $object_type )) {4316 } elseif ( 'post_type' === $resource_type ) { 4304 4317 $ancestors = get_post_ancestors($object_id); 4305 4318 } … … 4310 4323 * @since 3.1.0 4311 4324 * 4312 * @param array $ancestors An array of object ancestors. 4313 * @param int $object_id Object ID. 4314 * @param string $object_type Type of object. 4325 * @param array $ancestors An array of object ancestors. 4326 * @param int $object_id Object ID. 4327 * @param string $object_type Type of object. 4328 * @param string $resource_type Type of resource $object_type is. 4315 4329 */ 4316 4330 return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type );
Note: See TracChangeset
for help on using the changeset viewer.