Walker::unset_children()publicWP 2.7.0

Unsets all the children for a given top level element.

{} It's a method of the class: Walker{}

No Hooks.

Return

null. Nothing.

Usage

$Walker = new Walker();
$Walker->unset_children( $element, $children_elements );
$element(object) (required)
The top level element.
$children_elements(array) (required) (passed by reference — &)
The children elements.

Changelog

Since 2.7.0 Introduced.

Code of Walker::unset_children() WP 6.0.2

public function unset_children( $element, &$children_elements ) {
	if ( ! $element || ! $children_elements ) {
		return;
	}

	$id_field = $this->db_fields['id'];
	$id       = $element->$id_field;

	if ( ! empty( $children_elements[ $id ] ) && is_array( $children_elements[ $id ] ) ) {
		foreach ( (array) $children_elements[ $id ] as $child ) {
			$this->unset_children( $child, $children_elements );
		}
	}

	unset( $children_elements[ $id ] );
}