wppaste
WordPress

Walker_Category_Checklist

Since
2.5.1
Source
wp-admin/includes/class-walker-category-checklist.php:19
Core walker class to output an unordered list of category checkbox input elements.

Compatibility

WordPress
since 2.5.1
  • 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).

Hooks and filters fired · 2

Every hook that fires from inside Walker_Category_Checklist, in the order it appears in the class, grouped by the method that fires it.

Properties · 2

$tree_typepublic
$db_fieldspublic

Methods · 4

  • start_lvl()Starts the list before the elements are added.
  • end_lvl()Ends the list of after the elements are added.
  • start_el()Start the element output.
  • end_el()Ends the element output, if needed.

Source code

class Walker_Category_Checklist extends Walker {	public $tree_type = 'category';	public $db_fields = array(		'parent' => 'parent',		'id'     => 'term_id',	); // TODO: Decouple this. 	/**	 * Starts the list before the elements are added.	 *	 * @see Walker::start_lvl()	 *	 * @since 2.5.1	 *	 * @param string $output Used to append additional content (passed by reference).	 * @param int    $depth  Depth of category. Used for tab indentation.	 * @param array  $args   An array of arguments. See {@see wp_terms_checklist()}.	 */	public function start_lvl( &$output, $depth = 0, $args = array() ) {		$indent  = str_repeat( "\t", $depth );		$output .= "$indent<ul class='children'>\n";	} 	/**	 * Ends the list of after the elements are added.	 *	 * @see Walker::end_lvl()	 *	 * @since 2.5.1	 *	 * @param string $output Used to append additional content (passed by reference).	 * @param int    $depth  Depth of category. Used for tab indentation.	 * @param array  $args   An array of arguments. See {@see wp_terms_checklist()}.	 */	public function end_lvl( &$output, $depth = 0, $args = array() ) {		$indent  = str_repeat( "\t", $depth );		$output .= "$indent</ul>\n";	} 	/**	 * Start the element output.	 *	 * @see Walker::start_el()	 *	 * @since 2.5.1	 * @since 5.9.0 Renamed `$category` to `$data_object` and `$id` to `$current_object_id`	 *              to match parent class for PHP 8 named parameter support.	 *	 * @param string  $output            Used to append additional content (passed by reference).	 * @param WP_Term $data_object       The current term object.	 * @param int     $depth             Depth of the term in reference to parents. Default 0.	 * @param array   $args              An array of arguments. See {@see wp_terms_checklist()}.	 * @param int     $current_object_id Optional. ID of the current term. Default 0.	 */	public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {		// Restores the more descriptive, specific name for use within this method.		$category = $data_object; 		if ( empty( $args['taxonomy'] ) ) {			$taxonomy = 'category';		} else {			$taxonomy = $args['taxonomy'];		} 		if ( 'category' === $taxonomy ) {			$name = 'post_category';		} else {			$name = 'tax_input[' . $taxonomy . ']';		} 		$args['popular_cats'] = ! empty( $args['popular_cats'] ) ? array_map( 'intval', $args['popular_cats'] ) : array(); 		$class = in_array( $category->term_id, $args['popular_cats'], true ) ? ' class="popular-category"' : ''; 		$args['selected_cats'] = ! empty( $args['selected_cats'] ) ? array_map( 'intval', $args['selected_cats'] ) : array(); 		if ( ! empty( $args['list_only'] ) ) {			$aria_checked = 'false';			$inner_class  = 'category';

Changelog

Introduced in 2.5.1. 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 7.1.0 tag, from src/wp-admin/includes/class-walker-category-checklist.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.