[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/includes/ -> class-walker-nav-menu-checklist.php (source)

   1  <?php
   2  /**
   3   * Navigation Menu API: Walker_Nav_Menu_Checklist class
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   * @since 4.4.0
   8   */
   9  
  10  /**
  11   * Create HTML list of nav menu input items.
  12   *
  13   * @since 3.0.0
  14   * @uses Walker_Nav_Menu
  15   */
  16  class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
  17      /**
  18       * @param array $fields
  19       */
  20  	public function __construct( $fields = false ) {
  21          if ( $fields ) {
  22              $this->db_fields = $fields;
  23          }
  24      }
  25  
  26      /**
  27       * Starts the list before the elements are added.
  28       *
  29       * @see Walker_Nav_Menu::start_lvl()
  30       *
  31       * @since 3.0.0
  32       *
  33       * @param string $output Used to append additional content (passed by reference).
  34       * @param int    $depth  Depth of page. Used for padding.
  35       * @param array  $args   Not used.
  36       */
  37  	public function start_lvl( &$output, $depth = 0, $args = array() ) {
  38          $indent  = str_repeat( "\t", $depth );
  39          $output .= "\n$indent<ul class='children'>\n";
  40      }
  41  
  42      /**
  43       * Ends the list of after the elements are added.
  44       *
  45       * @see Walker_Nav_Menu::end_lvl()
  46       *
  47       * @since 3.0.0
  48       *
  49       * @param string $output Used to append additional content (passed by reference).
  50       * @param int    $depth  Depth of page. Used for padding.
  51       * @param array  $args   Not used.
  52       */
  53  	public function end_lvl( &$output, $depth = 0, $args = array() ) {
  54          $indent  = str_repeat( "\t", $depth );
  55          $output .= "\n$indent</ul>";
  56      }
  57  
  58      /**
  59       * Start the element output.
  60       *
  61       * @see Walker_Nav_Menu::start_el()
  62       *
  63       * @since 3.0.0
  64       *
  65       * @global int $_nav_menu_placeholder
  66       *
  67       * @param string $output Used to append additional content (passed by reference).
  68       * @param object $item   Menu item data object.
  69       * @param int    $depth  Depth of menu item. Used for padding.
  70       * @param array  $args   Not used.
  71       * @param int    $id     Not used.
  72       */
  73  	public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
  74          global $_nav_menu_placeholder;
  75  
  76          $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1;
  77          $possible_object_id    = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
  78          $possible_db_id        = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
  79  
  80          $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  81  
  82          $output .= $indent . '<li>';
  83          $output .= '<label class="menu-item-title">';
  84          $output .= '<input type="checkbox" class="menu-item-checkbox';
  85  
  86          if ( ! empty( $item->front_or_home ) ) {
  87              $output .= ' add-to-top';
  88          }
  89  
  90          $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr( $item->object_id ) . '" /> ';
  91  
  92          if ( ! empty( $item->label ) ) {
  93              $title = $item->label;
  94          } elseif ( isset( $item->post_type ) ) {
  95              /** This filter is documented in wp-includes/post-template.php */
  96              $title = apply_filters( 'the_title', $item->post_title, $item->ID );
  97          }
  98  
  99          $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
 100  
 101          if ( empty( $item->label ) && isset( $item->post_type ) && 'page' === $item->post_type ) {
 102              // Append post states.
 103              $output .= _post_states( $item, false );
 104          }
 105  
 106          $output .= '</label>';
 107  
 108          // Menu item hidden fields
 109          $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
 110          $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $item->object ) . '" />';
 111          $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 ) . '" />';
 112          $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="' . esc_attr( $item->type ) . '" />';
 113          $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . esc_attr( $item->title ) . '" />';
 114          $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_attr( $item->url ) . '" />';
 115          $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr( $item->target ) . '" />';
 116          $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 ) . '" />';
 117          $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr( implode( ' ', $item->classes ) ) . '" />';
 118          $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $item->xfn ) . '" />';
 119      }
 120  
 121  } // Walker_Nav_Menu_Checklist


Generated: Tue Oct 22 08:20:01 2019 Cross-referenced by PHPXref 0.7