<?php

/**
 * Use Bootstrap's media object for listing comments
 *
 * @link http://getbootstrap.com/components/#media
 */
class School_Time_Walker_Comment extends Walker_Comment {
	function start_lvl( &$output, $depth = 0, $args = array() ) {
		$GLOBALS['comment_depth'] = $depth + 1; ?>
		<ul <?php comment_class( 'media list-unstyled comment-' . get_comment_ID() ); ?>>
	<?php
	}

	function end_lvl( &$output, $depth = 0, $args = array() ) {
		$GLOBALS['comment_depth'] = $depth + 1;
		echo '</ul>';
	}

	function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
		$depth ++;
		$GLOBALS['comment_depth'] = $depth;
		$GLOBALS['comment']       = $comment;

		if ( ! empty( $args['callback'] ) ) {
			call_user_func( $args['callback'], $comment, $args, $depth );

			return;
		}

		extract( $args, EXTR_SKIP ); ?>

	<li id="comment-<?php esc_attr( comment_ID() ); ?>" <?php comment_class( 'media comment-' . get_comment_ID() ); ?>>
		<?php include get_theme_file_path( '/templates/comment.php' ); ?>
	<?php
	}

	function end_el( &$output, $comment, $depth = 0, $args = array() ) {
		if ( ! empty( $args['end-callback'] ) ) {
			call_user_func( $args['end-callback'], $comment, $args, $depth );

			return;
		}
		// Close ".media-body" <div> located in templates/comment.php, and then the comment's <li>
		echo "</div></li>\n";
	}
}
