Skip to content

Commit 46f8ecc

Browse files
committed
Merge branch 'master' of github.com:campuspress/divi-accessibility
* 'master' of github.com:campuspress/divi-accessibility: New/fix duplicate menu ids (#15)
2 parents 288e152 + e499a02 commit 46f8ecc

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

admin/class-divi-accessibility-admin.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public static function get_options_list() {
169169
'screen_reader_text' => 1,
170170
'skip_navigation_link' => 1,
171171
'aria_hidden_icons' => 1,
172+
'fix_duplicate_menu_ids' => 1,
172173
'tota11y' => 0,
173174
'developer_mode' => 0,
174175
);
@@ -332,7 +333,22 @@ public function register_settings() {
332333
'name' => 'aria_hidden_icons',
333334
'label_for' => $this->da11y . '_aria_hidden_icons',
334335
'label_text' => 'Hide all icons to screen readers so text is read normally.',
335-
'label_subtext' => 'Note: This may not work for all icons',
336+
'label_subtext' => 'This may not work for all icons',
337+
)
338+
);
339+
340+
// Fix duplicate menu ids.
341+
add_settings_field(
342+
$this->da11y . '_fix_duplicate_menu_ids',
343+
'Fix duplicate menu ids',
344+
array( $this, 'divi_accessibility_checkbox_cb' ),
345+
$this->da11y,
346+
$general_section,
347+
array(
348+
'name' => 'fix_duplicate_menu_ids',
349+
'label_for' => $this->da11y . '_fix_duplicate_menu_ids',
350+
'label_text' => 'Because Divi uses the same menu twice (Once for the primary menu and again for the mobile menu), the unique ID\'s are duplicated causing validation issues. This option prevents WordPress from adding a unique ID to the menu list items.',
351+
'label_subtext' => '',
336352
)
337353
);
338354

divi-accessibility.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
* that starts the plugin.
1010
*
1111
* @link https://campuspress.com
12-
* @since 1.0.0
12+
* @since 1.2.0
1313
* @package Divi_Accessibility
1414
*
1515
* @wordpress-plugin
1616
* Plugin Name: Divi Accessibility
1717
* Plugin URI: https://wordpress.org/plugins/accessible-divi/
1818
* Description: Improve Divi accessibility in accordance with WCAG 2.0 guidelines.
19-
* Version: 1.1.0
19+
* Version: 1.2.0
2020
* Author: CampusPress
2121
* Author URI: https://campuspress.com
2222
* License: GPL-2.0+
@@ -35,7 +35,7 @@
3535
define( 'DA11Y_FILE', plugin_basename( __FILE__ ) );
3636
}
3737

38-
// Used for referring to the plugin base path
38+
// Used for referring to the plugin base path.
3939
if ( ! defined( 'DA11Y_PATH' ) ) {
4040
define( 'DA11Y_PATH', plugin_dir_path( __FILE__ ) );
4141
}

includes/class-divi-accessibility.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ class Divi_Accessibility {
8686
* Load the dependencies, define the locale, and set the hooks for the admin area and
8787
* the public-facing side of the site.
8888
*
89-
* @since 1.1.0
89+
* @since 1.2.0
9090
*/
9191
public function __construct() {
9292

9393
$this->da11y = 'divi_accessibility';
9494
$this->da11y_options = 'divi_accessibility_options';
95-
$this->version = '1.1.0';
95+
$this->version = '1.2.0';
9696

9797
$this->load_dependencies();
9898
$this->load_settings();
@@ -175,6 +175,7 @@ private function define_public_hooks() {
175175
$this->loader->add_action( 'wp_footer', $plugin_public, 'developer_mode' );
176176
$this->loader->add_action( 'init', $plugin_public, 'remove_divi_viewport_meta' );
177177
$this->loader->add_action( 'wp_head', $plugin_public, 'accessible_viewport_meta' );
178+
$this->loader->add_filter( 'init', $plugin_public, 'remove_duplicate_menu_ids' );
178179

179180
}
180181

public/class-divi-accessibility-public.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,21 @@ public function can_load( $option ) {
165165

166166
}
167167

168+
/**
169+
* Prevent WordPress from adding a unique ID from menu list items.
170+
* Because Divi uses js to build the mobile navigation menu from the main navigation links,
171+
* unique ID's are cloned, causing issues with accessibility & validation.
172+
*
173+
* @since 1.2.0
174+
*/
175+
public function remove_duplicate_menu_ids() {
176+
177+
if ( $this->can_load( 'fix_duplicate_menu_ids' ) ) {
178+
add_filter( 'nav_menu_item_id', '__return_null', 1000 );
179+
}
180+
181+
}
182+
168183
/**
169184
* Log plugin info to console for admin users.
170185
*

readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ Plugin created by [CampusPress](https://campuspress.com). Plugin icon based off
5252

5353
== Changelog ==
5454

55+
= 1.2 =
56+
* Add option to remove id attribute from list items in navigation menus
57+
5558
= 1.1 =
5659
* Add option to hide decorative icons from screen readers
5760
* Add hidden submit button to search

0 commit comments

Comments
 (0)