Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. /**
  2. * Filter the HTML attributes applied to a menu item's anchor element.
  3. *
  4. * @since 3.6.0
  5. * @since 4.1.0 The `$depth` parameter was added.
  6. *
  7. * @param array $atts {
  8. * The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
  9. *
  10. * @type string $title Title attribute.
  11. * @type string $target Target attribute.
  12. * @type string $rel The rel attribute.
  13. * @type string $href The href attribute.
  14. * }
  15. * @param object $item The current menu item.
  16. * @param array $args An array of {@see wp_nav_menu()} arguments.
  17. * @param int $depth Depth of menu item. Used for padding.
  18. */
  19. $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
  20.  
  21. $attributes = '';
  22. foreach ( $atts as $attr => $value ) {
  23. if ( ! empty( $value ) ) {
  24. $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
  25. $attributes .= ' ' . $attr . '="' . $value . '"';
  26. }
  27. }
  28.  
  29. /** This filter is documented in wp-includes/post-template.php */
  30. $title = apply_filters( 'the_title', $item->title, $item->ID );
  31.  
  32. /**
  33. * Filter a menu item's title.
  34. *
  35. * @since 4.4.0
  36. *
  37. * @param string $title The menu item's title.
  38. * @param object $item The current menu item.
  39. * @param array $args An array of {@see wp_nav_menu()} arguments.
  40. * @param int $depth Depth of menu item. Used for padding.
  41. */
  42. $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
  43.  
  44. $item_output = $args->before;
  45. $item_output .= '<a'. $attributes .'>';
  46. $item_output .= $args->link_before . $title . $args->link_after;
  47. $item_output .= '</a>';
  48. $item_output .= $args->after;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement