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
4989  */
4990 function get_ancestors( $object_id = 0, $object_type = '', $resource_type = '' ) {
4991      $object_id = (int) $object_id;
4992
4993      $ancestors = array();
4994
4995      if ( empty( $object_id ) ) {
4996
4997           /** This filter is documented in wp-includes/taxonomy.php */
4998           return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
4999      }
5000
5001      if ( ! $resource_type ) {
5002           if ( is_taxonomy_hierarchical( $object_type ) ) {
5003                $resource_type = 'taxonomy';
5004           } elseif ( post_type_exists( $object_type ) ) {
5005                $resource_type = 'post_type';
5006           }
5007      }
 
Line Code
5021       *
5022       * @since 3.1.0
5023       * @since 4.1.1 Introduced the `$resource_type` parameter.
5024       *
5025       * @param int[]  $ancestors     An array of IDs of object ancestors.
5026       * @param int    $object_id     Object ID.
5027       * @param string $object_type   Type of object.
5028       * @param string $resource_type Type of resource $object_type is.
5029       */
5030      return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
5031 }
5032
5033 /**
5034  * Returns the term's parent's term ID.
5035  *
5036  * @since 3.1.0
5037  *
5038  * @param int    $term_id  Term ID.
5039  * @param string $taxonomy Taxonomy name.