Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe consider wp_add_inline_script for generate-a11y script #659

Open
diggeddy opened this issue Jan 6, 2025 · 0 comments
Open

Maybe consider wp_add_inline_script for generate-a11y script #659

diggeddy opened this issue Jan 6, 2025 · 0 comments
Labels
triage Awaiting review

Comments

@diggeddy
Copy link
Collaborator

diggeddy commented Jan 6, 2025

Users can't apply inline script attributes to generate-a11y using the core wp_inline_script_attributes as we print the code inline:

add_action( 'wp_footer', 'generate_do_a11y_scripts' );
/**
* Enqueue scripts in the footer.
*
* @since 3.1.0
*/
function generate_do_a11y_scripts() {
if ( apply_filters( 'generate_print_a11y_script', true ) ) {
// Add our small a11y script inline.
printf(
'<script id="generate-a11y">%s</script>',
'!function(){"use strict";if("querySelector"in document&&"addEventListener"in window){var e=document.body;e.addEventListener("mousedown",function(){e.classList.add("using-mouse")}),e.addEventListener("keydown",function(){e.classList.remove("using-mouse")})}}();'
);
}
}

Maybe we can ue wp_add_inline_script instead ?

@github-actions github-actions bot added the triage Awaiting review label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Awaiting review
Projects
None yet
Development

No branches or pull requests

1 participant