From bf39f933f35c40e3a7712a5251d38a64202e1ebc Mon Sep 17 00:00:00 2001 From: Jb Date: Tue, 21 Apr 2020 13:43:44 +0200 Subject: [PATCH] Accessibility: add wp.a11y.speak to communicate action links AJAX changes to screen reader users --- functions.php | 3 ++- js/wp-autoupdates.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 2c714d5..aa5716b 100755 --- a/functions.php +++ b/functions.php @@ -117,7 +117,7 @@ function insert_into_template(positioning_text, added_text, insert_before) { wp_enqueue_script( 'wp-autoupdates', plugin_dir_url( __FILE__ ) . 'js/wp-autoupdates.js', - array( 'jquery', 'wp-ajax-response' ), + array( 'jquery', 'wp-ajax-response', 'wp-a11y' ), WP_AUTO_UPDATES_VERSION, true ); @@ -130,6 +130,7 @@ function insert_into_template(positioning_text, added_text, insert_before) { 'disable' => __( 'Disable auto-updates', 'wp-autoupdates' ), 'disabling' => __( 'Disabling auto-updates...', 'wp-autoupdates' ), 'auto_enabled' => __( 'Auto-updates enabled', 'wp-autoupdates' ), + 'auto_disabled' => __( 'Auto-updates disabled', 'wp-autoupdates' ), ) ); } diff --git a/js/wp-autoupdates.js b/js/wp-autoupdates.js index 19312ad..b968590 100644 --- a/js/wp-autoupdates.js +++ b/js/wp-autoupdates.js @@ -27,6 +27,7 @@ jQuery(function ($) { $( '.autoupdate_disabled span' ).html( response.data.disabled_count ); $parent.html( response.data.return_html ); $parent.find('.plugin-autoupdate-enable').focus(); + wp.a11y.speak( wp_autoupdates.auto_disabled, 'polite' ); }) .fail(function (response) { // todo - Better error handling. @@ -63,6 +64,7 @@ jQuery(function ($) { $( '.autoupdate_disabled span' ).html( response.data.disabled_count ); $parent.html( response.data.return_html ); $parent.find('.plugin-autoupdate-disable').focus(); + wp.a11y.speak( wp_autoupdates.auto_enabled, 'polite' ); }) .fail(function (response) { // todo - Better error handling. @@ -99,6 +101,7 @@ jQuery(function ($) { $( '.autoupdate_disabled span' ).html( response.data.disabled_count ); $parent.html( response.data.return_html ); $parent.find('.theme-autoupdate-enable').focus(); + wp.a11y.speak( wp_autoupdates.auto_disabled, 'polite' ); }) .fail(function (response) { // todo - Better error handling. @@ -135,6 +138,7 @@ jQuery(function ($) { $( '.autoupdate_disabled span' ).html( response.data.disabled_count ); $parent.html( response.data.return_html ); $parent.find('.theme-autoupdate-disable').focus(); + wp.a11y.speak( wp_autoupdates.auto_enabled, 'polite' ); }) .fail(function (response) { // todo - Better error handling. @@ -169,6 +173,7 @@ jQuery(function ($) { .done(function (response) { $parent.html( response.data.return_html ); $parent.find('.theme-autoupdate-enable').focus(); + wp.a11y.speak( wp_autoupdates.auto_disabled, 'polite' ); }) .fail(function (response) { // todo - Better error handling. @@ -203,6 +208,7 @@ jQuery(function ($) { .done(function (response) { $parent.html( response.data.return_html ); $parent.find('.theme-autoupdate-disable').focus(); + wp.a11y.speak( wp_autoupdates.auto_enabled, 'polite' ); }) .fail(function (response) { // todo - Better error handling.