On this page
wp_find_hierarchy_loop( callable $callback, int $start, int $start_parent, array $callback_args = array() ): array
This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Finds hierarchy loops using a callback function that maps object IDs to parent IDs.
Parameters
$callbackcallable Required-
Function that accepts ( ID, $callback_args ) and outputs parent_ID.
$startint Required-
The ID to start the loop check at.
$start_parentint Required-
The parent_ID of $start to use instead of calling $callback( $start ).
Use null to always use $callback $callback_argsarray Optional-
Additional arguments to send to $callback.
Default:
array()
Return
array IDs of all members of loop.
Source
File: wp-includes/functions.php. View all references
function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
$override = is_null( $start_parent ) ? array() : array( $start => $start_parent );
$arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args );
if ( ! $arbitrary_loop_member ) {
return array();
}
return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true );
}
Related
Uses
| Uses | Description |
|---|---|
| wp_find_hierarchy_loop_tortoise_hare() wp-includes/functions.php | Uses the “The Tortoise and the Hare” algorithm to detect loops. |
Used By
| Used By | Description |
|---|---|
| wp_check_term_hierarchy_for_loops() wp-includes/taxonomy.php | Checks the given subset of the term hierarchy for hierarchy loops. |
| wp_check_post_hierarchy_for_loops() wp-includes/post.php | Checks the given subset of the post hierarchy for hierarchy loops. |
Changelog
| Version | Description |
|---|---|
| 3.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_find_hierarchy_loop