: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param int $term_id Term ID.
* @param string $taxonomy Taxonomy name.
* @return int|false Parent term ID on success, false on failure.
function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) {
$term = get_term( $term_id, $taxonomy );
if ( ! $term || is_wp_error( $term ) ) {
return (int) $term->parent;
* Checks the given subset of the term hierarchy for hierarchy loops.
* Prevents loops from forming and breaks those that it finds.
* Attached to the {@see 'wp_update_term_parent'} filter.
* @param int $parent_term `term_id` of the parent for the term we're checking.
* @param int $term_id The term we're checking.
* @param string $taxonomy The taxonomy of the term we're checking.
* @return int The new parent for the term.
function wp_check_term_hierarchy_for_loops( $parent_term, $term_id, $taxonomy ) {
// Nothing fancy here - bail.
// Can't be its own parent.
if ( $parent_term === $term_id ) {
// Now look for larger loops.
$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent_term, array( $taxonomy ) );
return $parent_term; // No loop.
// Setting $parent_term to the given value causes a loop.
if ( isset( $loop[ $term_id ] ) ) {
// There's a loop, but it doesn't contain $term_id. Break the loop.
foreach ( array_keys( $loop ) as $loop_member ) {
wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
* Determines whether a taxonomy is considered "viewable".
* @param string|WP_Taxonomy $taxonomy Taxonomy name or object.
* @return bool Whether the taxonomy should be considered viewable.
function is_taxonomy_viewable( $taxonomy ) {
if ( is_scalar( $taxonomy ) ) {
$taxonomy = get_taxonomy( $taxonomy );
return $taxonomy->publicly_queryable;
* Determines whether a term is publicly viewable.
* A term is considered publicly viewable if its taxonomy is viewable.
* @param int|WP_Term $term Term ID or term object.
* @return bool Whether the term is publicly viewable.
function is_term_publicly_viewable( $term ) {
$term = get_term( $term );
return is_taxonomy_viewable( $term->taxonomy );
* Sets the last changed time for the 'terms' cache group.
function wp_cache_set_terms_last_changed() {
wp_cache_set_last_changed( 'terms' );
* Aborts calls to term meta if it is not supported.
* @param mixed $check Skip-value for whether to proceed term meta function execution.
* @return mixed Original value of $check, or false if term meta is not supported.
function wp_check_term_meta_support_prefilter( $check ) {
if ( get_option( 'db_version' ) < 34370 ) {