cluded from post purge * * @since 3.9.1 * * @param array $excluded_taxonomies Array of excluded taxonomies names. */ $excluded_taxonomies = apply_filters( 'rocket_exclude_post_taxonomy', [] ); foreach ( $taxonomies as $taxonomy ) { if ( ! $taxonomy->public || in_array( $taxonomy->name, $excluded_taxonomies, true ) ) { continue; } // Get the terms related to post. $terms = get_the_terms( $post->ID, $taxonomy->name ); if ( empty( $terms ) || is_wp_error( $terms ) ) { continue; } foreach ( $terms as $term ) { $term_url = get_term_link( $term->slug, $taxonomy->name ); if ( ! is_wp_error( $term_url ) ) { $urls[] = $term_url; } if ( ! is_taxonomy_hierarchical( $taxonomy->name ) ) { continue; } $ancestors = (array) get_ancestors( $term->term_id, $taxonomy->name ); foreach ( $ancestors as $ancestor ) { $ancestor_object = get_term( $ancestor, $taxonomy->name ); if ( ! $ancestor_object instanceof WP_Term ) { continue; } $ancestor_term_url = get_term_link( $ancestor_object->slug, $taxonomy->name ); if ( ! is_wp_error( $ancestor_term_url ) ) { $urls[] = $ancestor_term_url; } } } } // Remove entries with empty values in array. $urls = array_filter( $urls, 'is_string' ); /** * Filter the list of taxonomies URLs * * @since 1.1.0 * * @param array $urls List of taxonomies URLs */ return apply_filters( 'rocket_post_terms_urls', $urls ); } }