Walker::unset_children( object $element, array $children_elements )

In this article

Unsets all the children for a given top level element.

Parameters

$elementobjectrequired
The top level element.
$children_elementsarrayrequired
The children elements.

Source

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

Changelog

VersionDescription
2.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.