# betterdocs/4.2.0/includes/Utils/Node.php

BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ &amp; Chatbot, version 4.2.0. 36 lines.

- Page: https://pluginprobe.com/plugins/betterdocs/4.2.0/code/includes/Utils/Node.php
- Raw: https://pluginprobe.com/plugins/betterdocs/4.2.0/raw/includes/Utils/Node.php
- Modified: 2024-12-09T12:10:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/betterdocs/4.2.0/code/includes/Utils/Node.php#L10-L20`.

```php
<?php
namespace WPDeveloper\BetterDocs\Utils;

class Node {
	public $title;
	public $tag;
	public $tag_number;
	public $key;
	/**
	 * Summary of $items
	 * @var array
	 */
	public $items;

	public function print( $items, $toc_hierarchy, $level ) {
		$html = '';
		if ( ! empty( $items ) ) {
			$toc_hierarchy_class = ( $toc_hierarchy != 'off' && $toc_hierarchy != '' ) ? 'toc-list betterdocs-hierarchial-toc' : 'toc-list';
			$html               .= $level === 1 ? '<ul class = "' . $toc_hierarchy_class . '">' : '<ul class = "betterdocs-toc-list-level-' . $level . '">';
			foreach ( $items as $item ) {
				$html .= '<li class = "betterdocs-toc-heading-level-' . ( $item->key ) . '">';
				$html .= '<a href="#' . $item->tag_number . '">' . strip_tags( $item->title ) . '</a>';
				if ( ! empty( $items ) ) {
					$html .= $this->print( $item->items, $toc_hierarchy, ++$level );
				} else {
					$level = 1;
					break;
				}
				$html .= '</li>';
			}
			$html .= '</ul>';
		}
		return $html;
	}
}

```
