2017 © Pedro Peláez
 

library wai-aria-walker-nav-menu

WordPress menu walker which adds appropriate WIA-ARIA roles to dropdown menus.

image

proteusthemes/wai-aria-walker-nav-menu

WordPress menu walker which adds appropriate WIA-ARIA roles to dropdown menus.

  • Wednesday, May 18, 2016
  • by primozcigler
  • Repository
  • 10 Watchers
  • 24 Stars
  • 3,790 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 12 Forks
  • 0 Open issues
  • 6 Versions
  • 6 % Grown

The README.md

WAI-ARIA WordPress Walker

Nav menu walker for WP with correct WAI-ARIA roles for dropdown menus., (*1)

Install

Detailed explanation in a blogpost., (*2)

  1. You can install this class using Composer (preferred method) or manually copying this file to your theme / project., (*3)

  2. After that, include it in your theme, probably something like (assuming you installed it using Composer):, (*4)

    require_once 'vendor/proteusthemes/wai-aria-walker-nav-menu/aria-walker-nav-menu.php';
    

    You must enqueue wai-aria.js as well, because the aria-expanded attributes needs to be updated with JS., (*5)

  3. Finally, include the menus in your theme files as per example below:, (*6)

    <nav class="collapse  navbar-collapse" role="navigation" aria-label="<?php _e( 'Main Menu', 'your-textdomain' ); ?>">
    <?php
        if ( has_nav_menu( 'your-menu' ) ) {
            wp_nav_menu( array(
                'theme_location' => 'your-menu',
                'container'      => false,
                'menu_class'     => 'main-navigation',
                'walker'         => new Aria_Walker_Nav_Menu(),
                'items_wrap'     => '<ul id="%1$s" class="%2$s">%3$s</ul>',
            ) );
        }
    ?>
    </nav>
    

    Mind:, (*7)

  • 'walker' => new Aria_Walker_Nav_Menu(),
  • <nav> wrapping element and 'container' => false in the arguments
  • role="navigation"
  • aria-label="<?php _e( 'Main Menu', 'your-textdomain' ); ?>"
  • 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>',

Compatibility with WP

This repo aims to be 1:1 compatible with latest WP version, mainly with the class Walker_Nav_Menu in the file /<path-to-wp>/wp-includes/nav-menu-template.php., (*8)

Current version is compatible with WP core 4.5., (*9)

Contributing

No need to explain - fork me and create a pull request., (*10)

Created by @primozcigler and @Prelc.

The Versions

18/05 2016

dev-master

9999999-dev

WordPress menu walker which adds appropriate WIA-ARIA roles to dropdown menus.

  Sources   Download

GPLv2

by Primoz Cigler
by Marko Prelec

18/05 2016

v1.2.1

1.2.1.0

WordPress menu walker which adds appropriate WIA-ARIA roles to dropdown menus.

  Sources   Download

GPLv2

by Primoz Cigler
by Marko Prelec

14/10 2015

v1.2.0

1.2.0.0

WordPress menu walker which adds appropriate WIA-ARIA roles to dropdown menus.

  Sources   Download

GPLv2

by Primoz Cigler
by Marko Prelec

26/05 2015

v1.1.1

1.1.1.0

WordPress menu walker which adds appropriate WIA-ARIA roles to dropdown menus.

  Sources   Download

GPLv2

by Primoz Cigler
by Marko Prelec

26/05 2015

v1.1.0

1.1.0.0

WordPress menu walker which adds appropriate WIA-ARIA roles to dropdown menus.

  Sources   Download

GPLv2

by Primoz Cigler
by Marko Prelec

16/04 2015

v1.0.0

1.0.0.0

WordPress menu walker which adds appropriate WIA-ARIA roles to dropdown menus.

  Sources   Download

GPLv2

by Primoz Cigler
by Marko Prelec