title: Wordpress wp_nav_menu walker: dynamic before content
body: <p>I build a navigation within a wordpress blog. the items are displayed like this:</p>
  
  <p><a href="https://i.stack.imgur.com/MnXim.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MnXim.png" alt="enter image description here"></a></p>
  
  <p>The icon is applied by using the bootstrap classes <code>glyhicon-glyphiconname</code>. I add the classes dynamically. The php code for that:</p>
  
  <pre><code>function add_specific_menu_location_atts( $atts, $item, $args ) {
       // check if the item is in the primary menu
       if( $args-&gt;theme_location == 'directentries' ) {
         foreach($item as $key =&gt; $value) {
             if($key == 'title') {
               $catIcon = setCatIcon($value);
             }
         }
         // add the desired attributes:
         $atts['class'] = 'btn btn-primary btn-lg glyphicon glyphicon-'.$catIcon;
       }
       return $atts;
   }
   add_filter( 'nav_menu_link_attributes', 'add_specific_menu_location_atts', 10, 3 );
  
  $args = array(
          'theme_location' =&gt; 'directentries',
          'depth'      =&gt; 1,
          'container'  =&gt; false,
          'menu_class'     =&gt; 'nav',
          'link_before'  =&gt; '&lt;br&gt;', 
          //'link_before'  =&gt; 'span class"glyphicon"',
          'walker'     =&gt; ''
      );
      wp_nav_menu($args);
  </code></pre>
  
  <p>The problem here is, that the font of the link text is (of course) glyhicon, otherwise the icon would not apply to the link. So: The correct way would be to apply a <strong>span</strong> using the <strong>link-before</strong> parameter when initialising the menu. 
  But I need to apply my dynamic classname to the <strong>span</strong> then. 
  I think I could access the <strong>link_before</strong> param within my filter class using the $args parameter.. </p>
  
  <p>The current markup is this:
  <a href="https://i.stack.imgur.com/ZsG7p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZsG7p.png" alt="enter image description here"></a>
  And I need it to be linke this:
  <a href="https://i.stack.imgur.com/p5TS2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p5TS2.png" alt="enter image description here"></a>
  Does anyone have an idea how to apply a span and vary the classes?</p>
  
  <p>. </p>