Walker_Comment::display_element()

最后更新于:2021-11-26 06:10:11

Walker_Comment::display_element( GC_Comment$element, array$children_elements, int$max_depth, int$depth, array$args, string$output)

Traverses elements to create list from elements.

参数

$element

(GC_Comment) (Required) Comment data object.

$children_elements

(array) (Required) List of elements to continue traversing. Passed by reference.

$max_depth

(int) (Required) Max depth to traverse.

$depth

(int) (Required) Depth of the current element.

$args

(array) (Required) An array of arguments.

$output

(string) (Required) Used to append additional content. Passed by reference.

源文件

文件: gc-includes/class-walker-comment.php

	public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
		if ( ! $element ) {
			return;
		}

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

		parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );

		/*
		 * If at the max depth, and the current element still has children, loop over those
		 * and display them at this level. This is to prevent them being orphaned to the end
		 * of the list.
		 */
		if ( $max_depth <= $depth + 1 && isset( $children_elements[ $id ] ) ) {
			foreach ( $children_elements[ $id ] as $child ) {
				$this->display_element( $child, $children_elements, $max_depth, $depth, $args, $output );
			}

			unset( $children_elements[ $id ] );
		}

	}