Walker_Nav_Menu_Checklist

Create HTML list of nav menu input items.

Defined (1)

The class is defined in the following location(s).

/wp-admin/includes/class-walker-nav-menu-checklist.php  
  1. class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { 
  2. /** 
  3. * @param array $fields 
  4. */ 
  5. public function __construct( $fields = false ) { 
  6. if ( $fields ) { 
  7. $this->db_fields = $fields; 
  8.  
  9. /** 
  10. * Starts the list before the elements are added. 
  11. * @see Walker_Nav_Menu::start_lvl() 
  12. * @since 3.0.0 
  13. * @param string $output Passed by reference. Used to append additional content. 
  14. * @param int $depth Depth of page. Used for padding. 
  15. * @param array $args Not used. 
  16. */ 
  17. public function start_lvl( &$output, $depth = 0, $args = array() ) { 
  18. $indent = str_repeat( "\t", $depth ); 
  19. $output .= "\n$indent<ul class='children'>\n"; 
  20.  
  21. /** 
  22. * Ends the list of after the elements are added. 
  23. * @see Walker_Nav_Menu::end_lvl() 
  24. * @since 3.0.0 
  25. * @param string $output Passed by reference. Used to append additional content. 
  26. * @param int $depth Depth of page. Used for padding. 
  27. * @param array $args Not used. 
  28. */ 
  29. public function end_lvl( &$output, $depth = 0, $args = array() ) { 
  30. $indent = str_repeat( "\t", $depth ); 
  31. $output .= "\n$indent</ul>"; 
  32.  
  33. /** 
  34. * Start the element output. 
  35. * @see Walker_Nav_Menu::start_el() 
  36. * @since 3.0.0 
  37. * @global int $_nav_menu_placeholder 
  38. * @param string $output Passed by reference. Used to append additional content. 
  39. * @param object $item Menu item data object. 
  40. * @param int $depth Depth of menu item. Used for padding. 
  41. * @param array $args Not used. 
  42. * @param int $id Not used. 
  43. */ 
  44. public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { 
  45. global $_nav_menu_placeholder; 
  46.  
  47. $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; 
  48. $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder; 
  49. $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0; 
  50.  
  51. $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; 
  52.  
  53. $output .= $indent . '<li>'; 
  54. $output .= '<label class="menu-item-title">'; 
  55. $output .= '<input type="checkbox" class="menu-item-checkbox'; 
  56.  
  57. if ( ! empty( $item->front_or_home ) ) 
  58. $output .= ' add-to-top'; 
  59.  
  60. $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> '; 
  61.  
  62. if ( ! empty( $item->label ) ) { 
  63. $title = $item->label; 
  64. } elseif ( isset( $item->post_type ) ) { 
  65. /** This filter is documented in wp-includes/post-template.php */ 
  66. $title = apply_filters( 'the_title', $item->post_title, $item->ID ); 
  67. if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title ) 
  68. $title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title ); 
  69.  
  70. $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title ); 
  71. $output .= '</label>'; 
  72.  
  73. // Menu item hidden fields 
  74. $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />'; 
  75. $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />'; 
  76. $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />'; 
  77. $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="'. esc_attr( $item->type ) .'" />'; 
  78. $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />'; 
  79. $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />'; 
  80. $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />'; 
  81. $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />'; 
  82. $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />'; 
  83. $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />'; 
  84.  
  85. } // Walker_Nav_Menu_Checklist