Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Two buttons in top bar #358

Closed
jcallery opened this issue Jun 2, 2015 · 2 comments
Closed

Two buttons in top bar #358

jcallery opened this issue Jun 2, 2015 · 2 comments

Comments

@jcallery
Copy link
Contributor

jcallery commented Jun 2, 2015

Hello,
I followed these instructions to add buttons in the top bar:

/**
 * Add support for buttons in the top-bar menu:
 * 1) In WordPress admin, go to Apperance -> Menus.
 * 2) Click 'Screen Options' from the top panel and enable 'CSS CLasses' and 'Link Relationship (XFN)'
 * 3) On your menu item, type 'has-form' in the CSS-classes field. Type 'button' in the XFN field
 * 4) Save Menu. Your menu item will now appear as a button in your top-menu
*/

The first button (second to last menu item) had rel="button" and class="button" applied properly, but the second button (last menu item) doesn't get class="button".

<li id="menu-item-323" class="has-form menu-item menu-item-type-custom menu-item-object-custom menu-item-323"><a rel="button" class="button" href="/login/">Login</a></li>
<li id="menu-item-324" class="has-form menu-item menu-item-type-custom menu-item-object-custom menu-item-324"><a rel="button" href="/free-demo/">Free Demo</a></li>
</ul>

If I change the order of the buttons in the menu, the second to last menu item always has the button class.

Do you know what could be causing this? Let me know if there's any additional information I can provide.

Thanks!

@jcallery
Copy link
Contributor Author

jcallery commented Jun 5, 2015

I found the issue - right in front of my face:

if ( ! function_exists( 'foundationpress_add_menuclass' ) ) {
    function foundationpress_add_menuclass($ulclass) {
        $find = array('/<a rel="button"/', '/<a title=".*?" rel="button"/');
        $replace = array('<a rel="button" class="button"', '<a rel="button" class="button"');

        return preg_replace( $find, $replace, $ulclass, 1 );
    }
    add_filter( 'wp_nav_menu','foundationpress_add_menuclass' );
}
return preg_replace( $find, $replace, $ulclass, 1 );

needed to be

return preg_replace( $find, $replace, $ulclass, 2 );

@olefredrik
Copy link
Owner

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants