• Resolved mbartizmo

    (@mbartizmo)


    Hello. Firstly, thank you for the plug-in. It looks great.

    My site, https://www.englishcurrent.com, has two nav menus using Max Mega Menus. However, each menu calls the same ID, mega-toggle-block-1, which is a no no and results in the following w3c validation error:

    Error: Duplicate ID mega-toggle-block-1.
    From line 161, column 101; to line 161, column 223
    index=”0″><div class=’mega-toggle-block mega-menu-toggle-block mega-toggle-block-right mega-toggle-block-1′ id=’mega-toggle-block-1′></div>

    Warning: The first occurrence of ID mega-toggle-block-1 was here.
    From line 116, column 101; to line 116, column 223
    index=”0″><div class=’mega-toggle-block mega-menu-toggle-block mega-toggle-block-right mega-toggle-block-1′ id=’mega-toggle-block-1′></div>

    The site still works fine, but is there a simple way to fix this?
    Thanks.
    MB

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author megamenu

    (@megamenu)

    Hi MB,

    That’s an issue that I need to fix, I’m just concerned I’ll break people’s custom styling if they’ve used IDs to style the toggle blocks. Really I just need to bite the bullet and remove it and deal with the fallout, I can’t see any other way to get rid of them.

    In the mean time, here is some code which you can add to your themes functions.php file which will remove the IDs:

    function remove_ids_from_toggle_blocks($attributes, $block, $content, $nav_menu, $args, $theme_id) {
        if (isset($attributes['id'])) {
            unset($attributes['id']);
        }
        return $attributes;
    }
    add_filter('megamenu_toggle_block_attributes', 'remove_ids_from_toggle_blocks');

    Regards,
    Tom

    Thread Starter mbartizmo

    (@mbartizmo)

    Hello. I see the conundrum.

    Is that code meant to work as is, or do I have to enter my menu’s variables in place of $theme_id, etc?

    As is, I get these errors (twice):

    Warning: Missing argument 2 for remove_ids_from_toggle_blocks() in /home/ecftpuser/englishcurrent.com/wp-content/themes/twentytwelve-child/functions.php on line 202

    Warning: Missing argument 3 for remove_ids_from_toggle_blocks() in /home/ecftpuser/englishcurrent.com/wp-content/themes/twentytwelve-child/functions.php on line 202

    Warning: Missing argument 4 for remove_ids_from_toggle_blocks() in /home/ecftpuser/englishcurrent.com/wp-content/themes/twentytwelve-child/functions.php on line 202

    Warning: Missing argument 5 for remove_ids_from_toggle_blocks() in /home/ecftpuser/englishcurrent.com/wp-content/themes/twentytwelve-child/functions.php on line 202

    Warning: Missing argument 6 for remove_ids_from_toggle_blocks() in /home/ecftpuser/englishcurrent.com/wp-content/themes/twentytwelve-child/functions.php on line 202

    MB

    Plugin Author megamenu

    (@megamenu)

    Hi MB,

    Sorry, please try this instead:

    function remove_ids_from_toggle_blocks($attributes, $block, $content, $nav_menu, $args, $theme_id) {
        if (isset($attributes['id'])) {
            unset($attributes['id']);
        }
        return $attributes;
    }
    add_filter('megamenu_toggle_block_attributes', 'remove_ids_from_toggle_blocks', 10, 6);

    There’s nothing else you need to do, the code should work as is.

    Regards,
    Tom

    Thread Starter mbartizmo

    (@mbartizmo)

    Thanks. It works.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Duplicate ID mega-toggle-block-1 (using two menus)’ is closed to new replies.