wppaste
WordPress

Walker_Comment

Since
2.7.0
Source
wp-includes/class-walker-comment.php:17
Core walker class used to create an HTML list of comments.

Compatibility

WordPress
since 2.7.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 2

$tree_typestringpublic
What the class handles.
$db_fieldsstring[]public
Database fields to use.

Methods · 9

Source code

class Walker_Comment extends Walker { 	/**	 * What the class handles.	 *	 * @since 2.7.0	 * @var string	 *	 * @see Walker::$tree_type	 */	public $tree_type = 'comment'; 	/**	 * Database fields to use.	 *	 * @since 2.7.0	 * @var string[]	 *	 * @see Walker::$db_fields	 * @todo Decouple this	 */	public $db_fields = array(		'parent' => 'comment_parent',		'id'     => 'comment_ID',	); 	/**	 * Starts the list before the elements are added.	 *	 * @since 2.7.0	 *	 * @see Walker::start_lvl()	 * @global int $comment_depth	 *	 * @param string $output Used to append additional content (passed by reference).	 * @param int    $depth  Optional. Depth of the current comment. Default 0.	 * @param array  $args   Optional. Uses 'style' argument for type of HTML list. Default empty array.	 */	public function start_lvl( &$output, $depth = 0, $args = array() ) {		$GLOBALS['comment_depth'] = $depth + 1; 		switch ( $args['style'] ) {			case 'div':				break;			case 'ol':				$output .= '<ol class="children">' . "\n";				break;			case 'ul':			default:				$output .= '<ul class="children">' . "\n";				break;		}	} 	/**	 * Ends the list of items after the elements are added.	 *	 * @since 2.7.0	 *	 * @see Walker::end_lvl()	 * @global int $comment_depth	 *	 * @param string $output Used to append additional content (passed by reference).	 * @param int    $depth  Optional. Depth of the current comment. Default 0.	 * @param array  $args   Optional. Will only append content if style argument value is 'ol' or 'ul'.	 *                       Default empty array.	 */	public function end_lvl( &$output, $depth = 0, $args = array() ) {		$GLOBALS['comment_depth'] = $depth + 1; 		switch ( $args['style'] ) {			case 'div':				break;			case 'ol':				$output .= "</ol><!-- .children -->\n";				break;			case 'ul':			default:				$output .= "</ul><!-- .children -->\n";				break;

Changelog

Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/class-walker-comment.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.