wp/wp-includes/class-walker-nav-menu.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    48 	 *
    48 	 *
    49 	 * @param string   $output Used to append additional content (passed by reference).
    49 	 * @param string   $output Used to append additional content (passed by reference).
    50 	 * @param int      $depth  Depth of menu item. Used for padding.
    50 	 * @param int      $depth  Depth of menu item. Used for padding.
    51 	 * @param stdClass $args   An object of wp_nav_menu() arguments.
    51 	 * @param stdClass $args   An object of wp_nav_menu() arguments.
    52 	 */
    52 	 */
    53 	public function start_lvl( &$output, $depth = 0, $args = array() ) {
    53 	public function start_lvl( &$output, $depth = 0, $args = null ) {
    54 		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
    54 		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
    55 			$t = '';
    55 			$t = '';
    56 			$n = '';
    56 			$n = '';
    57 		} else {
    57 		} else {
    58 			$t = "\t";
    58 			$t = "\t";
    87 	 *
    87 	 *
    88 	 * @param string   $output Used to append additional content (passed by reference).
    88 	 * @param string   $output Used to append additional content (passed by reference).
    89 	 * @param int      $depth  Depth of menu item. Used for padding.
    89 	 * @param int      $depth  Depth of menu item. Used for padding.
    90 	 * @param stdClass $args   An object of wp_nav_menu() arguments.
    90 	 * @param stdClass $args   An object of wp_nav_menu() arguments.
    91 	 */
    91 	 */
    92 	public function end_lvl( &$output, $depth = 0, $args = array() ) {
    92 	public function end_lvl( &$output, $depth = 0, $args = null ) {
    93 		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
    93 		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
    94 			$t = '';
    94 			$t = '';
    95 			$n = '';
    95 			$n = '';
    96 		} else {
    96 		} else {
    97 			$t = "\t";
    97 			$t = "\t";
   113 	 * @param WP_Post  $item   Menu item data object.
   113 	 * @param WP_Post  $item   Menu item data object.
   114 	 * @param int      $depth  Depth of menu item. Used for padding.
   114 	 * @param int      $depth  Depth of menu item. Used for padding.
   115 	 * @param stdClass $args   An object of wp_nav_menu() arguments.
   115 	 * @param stdClass $args   An object of wp_nav_menu() arguments.
   116 	 * @param int      $id     Current item ID.
   116 	 * @param int      $id     Current item ID.
   117 	 */
   117 	 */
   118 	public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
   118 	public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
   119 		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
   119 		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
   120 			$t = '';
   120 			$t = '';
   121 			$n = '';
   121 			$n = '';
   122 		} else {
   122 		} else {
   123 			$t = "\t";
   123 			$t = "\t";
   201 		 */
   201 		 */
   202 		$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
   202 		$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
   203 
   203 
   204 		$attributes = '';
   204 		$attributes = '';
   205 		foreach ( $atts as $attr => $value ) {
   205 		foreach ( $atts as $attr => $value ) {
   206 			if ( ! empty( $value ) ) {
   206 			if ( is_scalar( $value ) && '' !== $value && false !== $value ) {
   207 				$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
   207 				$value       = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
   208 				$attributes .= ' ' . $attr . '="' . $value . '"';
   208 				$attributes .= ' ' . $attr . '="' . $value . '"';
   209 			}
   209 			}
   210 		}
   210 		}
   211 
   211 
   257 	 * @param string   $output Used to append additional content (passed by reference).
   257 	 * @param string   $output Used to append additional content (passed by reference).
   258 	 * @param WP_Post  $item   Page data object. Not used.
   258 	 * @param WP_Post  $item   Page data object. Not used.
   259 	 * @param int      $depth  Depth of page. Not Used.
   259 	 * @param int      $depth  Depth of page. Not Used.
   260 	 * @param stdClass $args   An object of wp_nav_menu() arguments.
   260 	 * @param stdClass $args   An object of wp_nav_menu() arguments.
   261 	 */
   261 	 */
   262 	public function end_el( &$output, $item, $depth = 0, $args = array() ) {
   262 	public function end_el( &$output, $item, $depth = 0, $args = null ) {
   263 		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
   263 		if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
   264 			$t = '';
   264 			$t = '';
   265 			$n = '';
   265 			$n = '';
   266 		} else {
   266 		} else {
   267 			$t = "\t";
   267 			$t = "\t";
   268 			$n = "\n";
   268 			$n = "\n";
   269 		}
   269 		}
   270 		$output .= "</li>{$n}";
   270 		$output .= "</li>{$n}";
   271 	}
   271 	}
   272 
   272 
   273 } // Walker_Nav_Menu
   273 }