WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 2 times in this file.
| Line | Code |
|---|---|
| 3102 | * @param string $object_type The type of object for which we'll be retrieving ancestors. |
| 3103 | * @return array of ancestors from lowest to highest in the hierarchy. |
| 3104 | */ |
| 3105 | function get_ancestors($object_id = 0, $object_type = '') { |
| 3106 | $object_id = (int) $object_id; |
| 3107 | |
| 3108 | $ancestors = array(); |
| 3109 | |
| 3110 | if ( empty( $object_id ) ) { |
| 3111 | return apply_filters('get_ancestors', $ancestors, $object_id, $object_type); |
| 3112 | } |
| 3113 | |
| 3114 | if ( is_taxonomy_hierarchical( $object_type ) ) { |
| 3115 | $term = get_term($object_id, $object_type); |
| 3116 | while ( ! is_wp_error($term) && ! empty( $term->parent ) && ! in_array( $term->parent, $ancestors ) ) { |
| 3117 | $ancestors[] = (int) $term->parent; |
| 3118 | $term = get_term($term->parent, $object_type); |
| 3119 | } |
| 3120 | } elseif ( null !== get_post_type_object( $object_type ) ) { |
| Line | Code |
| 3123 | $ancestors = $object->ancestors; |
| 3124 | else { |
| 3125 | while ( ! is_wp_error($object) && ! empty( $object->post_parent ) && ! in_array( $object->post_parent, $ancestors ) ) { |
| 3126 | $ancestors[] = (int) $object->post_parent; |
| 3127 | $object = get_post($object->post_parent); |
| 3128 | } |
| 3129 | } |
| 3130 | } |
| 3131 | |
| 3132 | return apply_filters('get_ancestors', $ancestors, $object_id, $object_type); |
| 3133 | } |
| 3134 | |
| 3135 | /** |
| 3136 | * Returns the term's parent's term_ID |
| 3137 | * |
| 3138 | * @since 3.1.0 |
| 3139 | * |
| 3140 | * @param int $term_id |
| 3141 | * @param string $taxonomy |