GithubHelp home page GithubHelp logo

isabella232 / wai-aria-walker_nav_menu Goto Github PK

View Code? Open in Web Editor NEW

This project forked from proteusthemes/wai-aria-walker_nav_menu

0.0 0.0 0.0 15 KB

Nav menu walker for WP with correct WAI-ARIA roles for dropdown menus.

License: GNU General Public License v2.0

JavaScript 9.89% PHP 90.11%

wai-aria-walker_nav_menu's Introduction

WAI-ARIA WordPress Walker

Nav menu walker for WP with correct WAI-ARIA roles for dropdown menus.

Install

Detailed explanation in a blogpost.

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

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

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.

  1. Finally, include the menus in your theme files as per example below:
<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:

  • '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.

Current version is compatible with WP core 4.5.

Contributing

No need to explain - fork me and create a pull request.

Created by @primozcigler and @Prelc.

wai-aria-walker_nav_menu's People

Contributors

primozcigler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.