Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_ancestors

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
4663  */
4664 function get_ancestors( $object_id = 0, $object_type = '', $resource_type = '' ) {
4665      $object_id = (int) $object_id;
4666
4667      $ancestors = array();
4668
4669      if ( empty( $object_id ) ) {
4670
4671           /** This filter is documented in wp-includes/taxonomy.php */
4672           return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
4673      }
4674
4675      if ( ! $resource_type ) {
4676           if ( is_taxonomy_hierarchical( $object_type ) ) {
4677                $resource_type = 'taxonomy';
4678           } elseif ( post_type_exists( $object_type ) ) {
4679                $resource_type = 'post_type';
4680           }
4681      }
 
Line Code
4695       *
4696       * @since 3.1.0
4697       * @since 4.1.1 Introduced the `$resource_type` parameter.
4698       *
4699       * @param int[]  $ancestors     An array of IDs of object ancestors.
4700       * @param int    $object_id     Object ID.
4701       * @param string $object_type   Type of object.
4702       * @param string $resource_type Type of resource $object_type is.
4703       */
4704      return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
4705 }
4706
4707 /**
4708  * Returns the term's parent's term_ID.
4709  *
4710  * @since 3.1.0
4711  *
4712  * @param int    $term_id  Term ID.
4713  * @param string $taxonomy Taxonomy name.