| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Navigation Menu API: Walker_Nav_Menu_Checklist class | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @package WordPress | 
					
						
							|  |  |  |  * @subpackage Administration | 
					
						
							|  |  |  |  * @since 4.4.0 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Create HTML list of nav menu input items. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @since 3.0.0 | 
					
						
							|  |  |  |  * @uses Walker_Nav_Menu | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * @param array $fields | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	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 array  $args   Not used. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	public function start_lvl( &$output, $depth = 0, $args = array() ) { | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 		$indent  = str_repeat( "\t", $depth ); | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 		$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 array  $args   Not used. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	public function end_lvl( &$output, $depth = 0, $args = array() ) { | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 		$indent  = str_repeat( "\t", $depth ); | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 		$output .= "\n$indent</ul>"; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/** | 
					
						
							|  |  |  | 	 * Start the element output. | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @see Walker_Nav_Menu::start_el() | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @since 3.0.0 | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @global int $_nav_menu_placeholder | 
					
						
							|  |  |  | 	 * | 
					
						
							|  |  |  | 	 * @param string $output Used to append additional content (passed by reference). | 
					
						
							|  |  |  | 	 * @param object $item   Menu item data object. | 
					
						
							|  |  |  | 	 * @param int    $depth  Depth of menu item. Used for padding. | 
					
						
							|  |  |  | 	 * @param array  $args   Not used. | 
					
						
							|  |  |  | 	 * @param int    $id     Not used. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { | 
					
						
							|  |  |  | 		global $_nav_menu_placeholder; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 		$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval( $_nav_menu_placeholder ) - 1 : -1; | 
					
						
							|  |  |  | 		$possible_object_id    = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder; | 
					
						
							|  |  |  | 		$possible_db_id        = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$output .= $indent . '<li>'; | 
					
						
							|  |  |  | 		$output .= '<label class="menu-item-title">'; | 
					
						
							|  |  |  | 		$output .= '<input type="checkbox" class="menu-item-checkbox'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 		if ( ! empty( $item->front_or_home ) ) { | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 			$output .= ' add-to-top'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 		$output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="' . esc_attr( $item->object_id ) . '" /> '; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		if ( ! empty( $item->label ) ) { | 
					
						
							|  |  |  | 			$title = $item->label; | 
					
						
							|  |  |  | 		} elseif ( isset( $item->post_type ) ) { | 
					
						
							|  |  |  | 			/** This filter is documented in wp-includes/post-template.php */ | 
					
						
							|  |  |  | 			$title = apply_filters( 'the_title', $item->post_title, $item->ID ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 			if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title ) { | 
					
						
							|  |  |  | 				/* translators: %s: front page title */ | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 				$title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title ); | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 		$output .= '</label>'; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// Menu item hidden fields
 | 
					
						
							|  |  |  | 		$output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />'; | 
					
						
							| 
									
										
										
										
											2019-04-16 20:56:22 +01:00
										 |  |  | 		$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $item->object ) . '" />'; | 
					
						
							|  |  |  | 		$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 ) . '" />'; | 
					
						
							|  |  |  | 		$output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="' . esc_attr( $item->type ) . '" />'; | 
					
						
							|  |  |  | 		$output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="' . esc_attr( $item->title ) . '" />'; | 
					
						
							|  |  |  | 		$output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="' . esc_attr( $item->url ) . '" />'; | 
					
						
							|  |  |  | 		$output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="' . esc_attr( $item->target ) . '" />'; | 
					
						
							|  |  |  | 		$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 ) . '" />'; | 
					
						
							|  |  |  | 		$output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr( implode( ' ', $item->classes ) ) . '" />'; | 
					
						
							|  |  |  | 		$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $item->xfn ) . '" />'; | 
					
						
							| 
									
										
										
										
											2019-03-12 09:27:46 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // Walker_Nav_Menu_Checklist
 |