Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_check_term_hierarchy_for_loops [ WordPress Function ]

wp_check_term_hierarchy_for_loops ( $parent, $term_id, $taxonomy )
Parameters:
  • (int) $parent term_id of the parent for the term we're checking.
  • (int) $term_id The term we're checking.
  • (string) $taxonomy The taxonomy of the term we're checking.
Uses:
Returns:
  • (int) The new parent for the term.
Defined at:



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' => ) );

    return 
$parent;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics