wp-bootstrap-navwalker icon indicating copy to clipboard operation
wp-bootstrap-navwalker copied to clipboard

Make the bootstrap navwalker respect the title attribute from wp_nav_menu

Open robbiegod opened this issue 12 years ago • 5 comments

Hi there, I'm using your wp-bootstrap-navwalker and i came across an issue where I had a primary navigation setup where I put a hard break (<br>) inside the navigation label of the link. The problem I ran into was the <br> would also appear in the title attribute of the link.

I temporarly fixed this by making a minor adjustment to wp_bootstrap_navwalker.php.

Line 78: $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';

I then had to enter in a title attribute value for each menu item. That seems to work ok, but ideally I think everyone would appreciate if it would show the Navigation Label if the title attribute is empty. If the title attribute has a value, it should show that value in the title param of the href link.

Can you incorporate that logic into the your navwalker?

After reading some of the new stuff that you've added into the class like glyphicons, disabled buttons, dividers, etc I can see you are using the title attribute in a creative way.

Is it possible to move these things that are currently now set in the title attribute to the class attribute in wordpress? Classes are hidden by default for menus in wordpress, but can be turned on the wp_nav_menu screen.

robbiegod avatar Oct 21 '14 15:10 robbiegod

This is definitely the plan, I just have not had the time to flesh out the new version of the walker.

SideQuestDIY avatar Nov 05 '14 20:11 SideQuestDIY

Please also consider the possibility of markup existing in the title, as when a plugin changes a menu to be a social icon. I had to change line 79 to use strip_tags, because the tags were ending up in the title tooltip:

            $atts['title']  = ! empty( $item->title )   ? strip_tags($item->title)  : '';

watou avatar Feb 24 '15 07:02 watou

That solved my problem @watou . Thanks a lot. :+1:

mayeenulislam avatar May 03 '15 08:05 mayeenulislam

Not sure if anyone else has found a solution for this.. But I wrote this up and it seems to be working for me:

      if(empty($item->attr_title)) {
          $atts['title']  = ! empty( $item->title )   ? strip_tags($item->title) : '';
      } else {
          $atts['title'] = $item->attr_title;
      }

mitchelb avatar Jul 01 '16 18:07 mitchelb

This is an old issue thread and is resolved in an upcoming branch of the walker.

Closing this issue for now.

pattonwebz avatar Jun 18 '17 18:06 pattonwebz