Description
Prevents loops from forming and breaks those that it finds.
Attached to the ‘wp_update_term_parent’ filter.
Parameters
- $parent
-
(int) (Required) term_id
of the parent for the term we're checking.
- $term_id
-
(int) (Required) The term we're checking.
- $taxonomy
-
(string) (Required) The taxonomy of the term we're checking.
Return
(int) The new parent for the term.
Source
File: wp-includes/taxonomy.php
function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
if ( ! $parent ) {
return 0;
}
if ( $parent === $term_id ) {
return 0;
}
$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) );
if ( ! $loop ) {
return $parent;
}
if ( isset( $loop[ $term_id ] ) ) {
return 0;
}
foreach ( array_keys( $loop ) as $loop_member ) {
wp_update_term( $loop_member, $taxonomy, array( 'parent' => 0 ) );
}
return $parent;
}
Changelog
Version | Description |
3.1.0 | Introduced. |