| @@ -1,35 +1,35 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace WPDeveloper\BetterDocs\Utils; |
| 3 | 3 | |
| 4 | 4 | class Node { |
| 5 | - public $title; | |
| 6 | - public $tag; | |
| 7 | - public $tag_number; | |
| 8 | - public $key; | |
| 9 | - /** | |
| 10 | - * Summary of $items | |
| 11 | - * @var array | |
| 12 | - */ | |
| 13 | - public $items; | |
| 5 | + public $title; | |
| 6 | + public $tag; | |
| 7 | + public $tag_number; | |
| 8 | + public $key; | |
| 9 | + /** | |
| 10 | + * Summary of $items | |
| 11 | + * @var array | |
| 12 | + */ | |
| 13 | + public $items; | |
| 14 | 14 | |
| 15 | - public function print( $items, $toc_hierarchy, $level ) { | |
| 16 | - $html = ''; | |
| 17 | - if ( ! empty( $items ) ) { | |
| 18 | - $toc_hierarchy_class = ( $toc_hierarchy != 'off' && $toc_hierarchy != '' ) ? 'toc-list betterdocs-hierarchial-toc' : 'toc-list'; | |
| 19 | - $html .= $level === 1 ? '<ul class = "' . $toc_hierarchy_class . '">' : '<ul class = "betterdocs-toc-list-level-' . $level . '">'; | |
| 20 | - foreach ( $items as $item ) { | |
| 21 | - $html .= '<li class = "betterdocs-toc-heading-level-' . ( $item->key ) . '">'; | |
| 22 | - $html .= '<a href="#' . $item->tag_number . '">' . strip_tags( $item->title ) . '</a>'; | |
| 23 | - if ( ! empty( $items ) ) { | |
| 24 | - $html .= $this->print( $item->items, $toc_hierarchy, ++$level ); | |
| 25 | - } else { | |
| 26 | - $level = 1; | |
| 27 | - break; | |
| 28 | - } | |
| 29 | - $html .= '</li>'; | |
| 30 | - } | |
| 31 | - $html .= '</ul>'; | |
| 32 | - } | |
| 33 | - return $html; | |
| 34 | - } | |
| 15 | + public function print( $items, $toc_hierarchy, $level ) { | |
| 16 | + $html = ''; | |
| 17 | + if ( ! empty( $items ) ) { | |
| 18 | + $toc_hierarchy_class = ( $toc_hierarchy != 'off' && $toc_hierarchy != '' ) ? 'toc-list betterdocs-hierarchial-toc' : 'toc-list'; | |
| 19 | + $html .= $level === 1 ? '<ul class = "' . $toc_hierarchy_class . '">' : '<ul class = "betterdocs-toc-list-level-' . $level . '">'; | |
| 20 | + foreach ( $items as $item ) { | |
| 21 | + $html .= '<li class = "betterdocs-toc-heading-level-' . ( $item->key ) . '">'; | |
| 22 | + $html .= '<a href="#' . $item->tag_number . '">' . strip_tags( $item->title ) . '</a>'; | |
| 23 | + if ( ! empty( $items ) ) { | |
| 24 | + $html .= $this->print( $item->items, $toc_hierarchy, ++$level ); | |
| 25 | + } else { | |
| 26 | + $level = 1; | |
| 27 | + break; | |
| 28 | + } | |
| 29 | + $html .= '</li>'; | |
| 30 | + } | |
| 31 | + $html .= '</ul>'; | |
| 32 | + } | |
| 33 | + return $html; | |
| 34 | + } | |
| 35 | 35 | } |