Last active
December 22, 2015 22:20
-
-
Save stephenbelyea/2335d862c4faab2f980a to your computer and use it in GitHub Desktop.
Google Language Translator Accessibility Fixes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Accessibility fixes for WordPress Google Language Translator plugin. | |
// Found on WP repo here: https://wordpress.org/plugins/google-language-translator/ | |
// Wait for jQuery to be ready... | |
// Grab and test for main wrap inserted before script runs. | |
var glt = document.getElementById('google_language_translator'); | |
if ( $(glt).length ) { | |
// Allow time for plugin to render. | |
setTimeout( function (){ | |
// Add label for select and blank alt text for logo images. | |
var $sel = $(glt).find('select'), | |
lbl = '<label for="goog-te-combo" class="sr-only">Select a language</label>'; | |
$(lbl).insertBefore($sel); | |
$sel.attr('id', 'goog-te-combo'); | |
$(glt).find('img').attr('alt', ''); | |
$('#goog-gt-tt').find('.logo img').attr('alt', ''); | |
}, 150); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment