wp_check_post_hierarchy_for_loops [ WordPress Function ]
wp_check_post_hierarchy_for_loops ( $post_parent, $post_ID )
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: wp_check_term_hierarchy_for_loops, wp_find_hierarchy_loop, wp_check_post_lock, wp_check_browser_version, wp_find_hierarchy_loop_tortoise_hare
Checks the given subset of the post hierarchy for hierarchy loops.
Prevents loops from forming and breaks those that it finds.
Attached to the wp_insert_post_parent filter.
Source
<?php
function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) {
// Nothing fancy here - bail
if ( !$post_parent )
return 0;
// New post can't cause a loop
if ( empty( $post_ID ) )
return $post_parent;
// Can't be its own parent
if ( $post_parent == $post_ID )
return 0;
// Now look for larger loops
if ( !$loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ) )
return $post_parent; // No loop
// Setting $post_parent to the given value causes a loop
if ( isset( $loop[$post_ID] ) )
return 0;
// There's a loop, but it doesn't contain $post_ID. Break the loop.
foreach ( array_keys( $loop ) as $loop_member )
wp_update_post( array( 'ID' => $loop_member, 'post_parent' => 0 ) );
return $post_parent;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- <?php /** * Sets up the default filters and actions for most * of the ...
... 'wp_check_post_hierarchy_for_loops', 10, 2 ); add_filter( ' wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); // Display filters add_filter( ...
core.svn.wordpress.org - 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 - PHPXRef 0.7 : WordPress : Detail view of post.php
wp_delete_post_revision() wp_get_post_revisions() _set_preview() _show_post_preview() wp_get_post_parent_id() wp_check_post_hierarchy_for_loops() ...
phpxref.ftwr.co.uk - Noodle and Meatball
function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) { // Nothing fancy here - bail if ( !$post_parent ) return 0; // New post can't cause a loop if ...
noodleandmeatball.com