Last active
July 26, 2024 08:53
-
-
Save wpmudev-sls/699604e8ed2a4ddcdcd97a67d1b598e1 to your computer and use it in GitHub Desktop.
[Forminator Pro] - Wave accessibility fix for phone field
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
<?php | |
/** | |
* Plugin Name: [Forminator Pro] Phone field WAVE accessibility fix | |
* Description: Phone field WAVE accessibility fix. | |
* Author: Prashant @ WPMUDEV | |
* Task: SLS-6342 | |
* Author URI: https://premium.wpmudev.org | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
add_action( 'wp_footer', 'wpmudev_phone_field_accessibility', 9999 ); | |
function wpmudev_phone_field_accessibility() { | |
global $post; | |
if ( is_a( $post, 'WP_Post' ) && ! has_shortcode( $post->post_content, 'forminator_form' ) ) { | |
return; | |
} | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
setTimeout(function() { | |
$('.forminator-custom-form').trigger('after.load.forminator'); | |
},500); | |
$(document).on('after.load.forminator', function(e, form_id) { | |
$('#' + e.target.id).find('.iti__search-input').each(function(){ | |
$(this).attr('id', 'formi_search_phone'); | |
$(this).attr('aria-labelledby', 'formi_search_label'); | |
$('<label id="formi_search_label" for="formi_search_phone" style="display:none;">Search Country</label>').insertBefore($(this)); | |
}); | |
}); | |
}); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment