Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function str_replace_assoc(array $replace, $subject) {
- return str_ireplace(array_keys($replace), array_values($replace), $subject);
- };
- function title_wrap_vowels($items) {
- $vowelreplace = array(
- 'a' => '<span>a</span>',
- 'e' => '<span>e</span>',
- 'i' => '<span>i</span>',
- 'o' => '<span>o</span>',
- 'u' => '<span>u</span>',
- );
- return str_replace_assoc($vowelreplace, $items);
- };
- function title_wrap_vowels_menu($item_output, $item, $depth, $args) {
- global $wp_query;
- $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
- $class_names = $value = '';
- $classes = empty( $item->classes ) ? array() : (array) $item->classes;
- $classes[] = 'menu-item-' . $item->ID;
- $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
- $class_names = ' class="' . esc_attr( $class_names ) . '"';
- $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
- $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : '';
- $output .= $indent . '<li' . $id . $value . $class_names .'>';
- $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
- $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
- $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
- $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
- $item_output = $args->before;
- $item_output .= '<a'. $attributes .'>';
- @h@$item_output .= $args->link_before . title_wrap_vowels(apply_filters( 'the_title', $item->title, $item->ID )) . $args->link_after;
- $item_output .= '</a>';
- $item_output .= $args->after;
- return $item_output;
- }
- add_filter('walker_nav_menu_start_el','title_wrap_vowels_menu', 1, 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement