Allow Pinch-to-Zoom on Mobile
Removes maximum-scale and user-scalable=no from the page's viewport tag when a theme or plugin adds them, so visitors can zoom in on phones as WCAG requires.
Opens WPIDE on
Code
add_action( 'wp_head', function () {
?>
<script>
(function () {
function fix() {
document.querySelectorAll('meta[name="viewport"]').forEach(function (meta) {
var content = meta.getAttribute('content') || '';
var cleaned = content.split(',').map(function (part) { return part.trim(); }).filter(function (part) {
return part && !/^(maximum-scale|user-scalable)\s*=/i.test(part);
}).join(', ');
if (cleaned !== content) { meta.setAttribute('content', cleaned); }
});
}
fix();
document.addEventListener('DOMContentLoaded', fix);
})();
</script>
<?php
}, 99 );
Notes
Runs early in the page head and only touches the viewport meta tag.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.