wppaste
WordPress

Walker_Nav_Menu_Checklist

Since
3.0.0
Source
wp-admin/includes/class-walker-nav-menu-checklist.php:16
Create HTML list of nav menu input items.

Compatibility

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

Hooks and filters fired · 1

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

Methods · 4

Source code

class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {	/**	 * @param array|false $fields Database fields to use.	 */	public function __construct( $fields = false ) {		if ( $fields ) {			$this->db_fields = $fields;		}	} 	/**	 * Starts the list before the elements are added.	 *	 * @see Walker_Nav_Menu::start_lvl()	 *	 * @since 3.0.0	 *	 * @param string   $output Used to append additional content (passed by reference).	 * @param int      $depth  Depth of page. Used for padding.	 * @param stdClass $args   Not used.	 */	public function start_lvl( &$output, $depth = 0, $args = null ) {		$indent  = str_repeat( "\t", $depth );		$output .= "\n$indent<ul class='children'>\n";	} 	/**	 * Ends the list of after the elements are added.	 *	 * @see Walker_Nav_Menu::end_lvl()	 *	 * @since 3.0.0	 *	 * @param string   $output Used to append additional content (passed by reference).	 * @param int      $depth  Depth of page. Used for padding.	 * @param stdClass $args   Not used.	 */	public function end_lvl( &$output, $depth = 0, $args = null ) {		$indent  = str_repeat( "\t", $depth );		$output .= "\n$indent</ul>";	} 	/**	 * Start the element output.	 *	 * @see Walker_Nav_Menu::start_el()	 *	 * @since 3.0.0	 * @since 5.9.0 Renamed `$item` to `$data_object` and `$id` to `$current_object_id`	 *              to match parent class for PHP 8 named parameter support.	 *	 * @global int        $_nav_menu_placeholder A placeholder for the nav menu item ID.	 * @global int|string $nav_menu_selected_id  The ID of the selected nav menu.	 *	 * @param string   $output            Used to append additional content (passed by reference).	 * @param WP_Post  $data_object       Menu item data object.	 * @param int      $depth             Depth of menu item. Used for padding.	 * @param stdClass $args              Not used.	 * @param int      $current_object_id Optional. ID of the current menu item. Default 0.	 */	public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) {		global $_nav_menu_placeholder, $nav_menu_selected_id; 		// Restores the more descriptive, specific name for use within this method.		$menu_item = $data_object; 		$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1;		$possible_object_id    = isset( $menu_item->post_type ) && 'nav_menu_item' === $menu_item->post_type ? $menu_item->object_id : $_nav_menu_placeholder;		$possible_db_id        = ( ! empty( $menu_item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $menu_item->ID : 0; 		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; 		$output .= $indent . '<li>';		$output .= '<label class="menu-item-title">';		$output .= '<input type="checkbox"' . wp_nav_menu_disabled_check( $nav_menu_selected_id, false ) . ' class="menu-item-checkbox'; 		if ( ! empty( $menu_item->front_or_home ) ) {			$output .= ' add-to-top';		}

Changelog

Introduced in 3.0.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 7.0.4 tag, from src/wp-admin/includes/class-walker-nav-menu-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.