Alert: 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.

wp_find_hierarchy_loop() WordPress Function

The wp_find_hierarchy_loop() function is used to find a hierarchy loop in the WordPress database. It is useful for debugging purposes.

wp_find_hierarchy_loop( callable $callback, int $start, int $start_parent, array $callback_args = array() ) #

Find hierarchy loops using a callback function that maps object IDs to parent IDs.


Parameters

$callback

(callable)(Required)Function that accepts ( ID, $callback_args ) and outputs parent_ID.

$start

(int)(Required)The ID to start the loop check at.

$start_parent

(int)(Required)The parent_ID of $start to use instead of calling $callback( $start ). Use null to always use $callback

$callback_args

(array)(Optional) Additional arguments to send to $callback.

Default value: array()


Top ↑

Return

(array) IDs of all members of loop.


Top ↑

Source

File: wp-includes/functions.php

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 );
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More