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
4954  */
4955 function get_ancestors( $object_id = 0, $object_type = '', $resource_type = '' ) {
4956      $object_id = (int) $object_id;
4957
4958      $ancestors = array();
4959
4960      if ( empty( $object_id ) ) {
4961
4962           /** This filter is documented in wp-includes/taxonomy.php */
4963           return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
4964      }
4965
4966      if ( ! $resource_type ) {
4967           if ( is_taxonomy_hierarchical( $object_type ) ) {
4968                $resource_type = 'taxonomy';
4969           } elseif ( post_type_exists( $object_type ) ) {
4970                $resource_type = 'post_type';
4971           }
4972      }
 
Line Code
4986       *
4987       * @since 3.1.0
4988       * @since 4.1.1 Introduced the `$resource_type` parameter.
4989       *
4990       * @param int[]  $ancestors     An array of IDs of object ancestors.
4991       * @param int    $object_id     Object ID.
4992       * @param string $object_type   Type of object.
4993       * @param string $resource_type Type of resource $object_type is.
4994       */
4995      return apply_filters( 'get_ancestors', $ancestors, $object_id, $object_type, $resource_type );
4996 }
4997
4998 /**
4999  * Returns the term's parent's term ID.
5000  *
5001  * @since 3.1.0
5002  *
5003  * @param int    $term_id  Term ID.
5004  * @param string $taxonomy Taxonomy name.