wp_check_term_hierarchy_for_loops [ WordPress Function ]
wp_check_term_hierarchy_for_loops ( $parent, $term_id, $taxonomy )
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: wp_check_post_hierarchy_for_loops, _get_term_hierarchy, wp_find_hierarchy_loop, wp_find_hierarchy_loop_tortoise_hare, wp_check_browser_version
Checks the given subset of the term hierarchy for hierarchy loops.
Prevents loops from forming and breaks those that it finds.
Attached to the wp_update_term_parent filter.
Source
<?php
function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
// Nothing fancy here - bail
if ( !$parent )
return 0;
// Can't be its own parent
if ( $parent == $term_id )
return 0;
// Now look for larger loops
if ( !$loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ) )
return $parent; // No loop
// Setting $parent to the given value causes a loop
if ( isset( $loop[$term_id] ) )
return 0;
// 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 ) );
return $parent;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Ticket #14662 - WordPress Trac
add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 ) ; add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', ...
core.trac.wordpress.org - #20635 (_pad_term_count get's stuck if there is a loop in the ...
May 8, 2012 ... We currently hook wp_check_term_hierarchy_for_loops on wp_update_term_parent and I wonder if there are other places we should be doing ...
core.trac.wordpress.org - #7267 (Infinite recursion in get_category_parents() and _children ...
... Milestone changed from 2.6 to Future Release. This should be able to leverage wp_check_term_hierarchy_for_loops() now. Note: See TracTickets for help on ...
core.trac.wordpress.org - Detail view of taxonomy.php - yukei.net
get_post_taxonomies() is_object_in_term() is_object_in_taxonomy() get_ancestors() wp_get_term_taxonomy_parent_id() wp_check_term_hierarchy_for_loops() ...
lab.yukei.net