| | 2565 | $ancestors = array(); |
| | 2566 | |
| | 2567 | if ( empty( $object_id ) ) { |
| | 2568 | return apply_filters('get_ancestors', $ancestors, $object_id, $object_type); |
| | 2569 | } |
| | 2570 | |
| | 2571 | if ( is_taxonomy_hierarchical( $object_type ) ) { |
| | 2572 | $term = get_term($object_id, $object_type); |
| | 2573 | while ( ! is_wp_error($term) && ! empty( $term->parent ) ) { |
| | 2574 | $ancestors[] = (int) $term->parent; |
| | 2575 | $term = get_term($term->parent, $object_type); |
| | 2576 | } |
| | 2577 | } elseif ( null !== get_post_type_object( $object_type ) ) { |
| | 2578 | $object = get_post($object_id); |
| | 2579 | while ( ! is_wp_error($object) && ! empty( $object->post_parent ) ) { |
| | 2580 | $ancestors[] = (int) $object->post_parent; |
| | 2581 | $object = get_post($object->post_parent); |
| | 2582 | } |
| | 2583 | } |
| | 2584 | |
| | 2585 | return apply_filters('get_ancestors', $ancestors, $object_id, $object_type); |
| | 2586 | } |