Skip to content

Instantly share code, notes, and snippets.

@Glinkfr
Created September 5, 2023 11:28
Show Gist options
  • Save Glinkfr/b120cdf4a715846342b616abe4fe7a19 to your computer and use it in GitHub Desktop.
Save Glinkfr/b120cdf4a715846342b616abe4fe7a19 to your computer and use it in GitHub Desktop.
Extra | meta viewport maximum-scale à 5 pour améliorer votre score d'Accessibilité dans PageSpeed Insights
<?php
// Merci à Garconis : https://gist.github.com/Garconis/34b6be24ee644c024663ef1d2e11e2bb
// Supprime extra_add_viewport_meta du wp_head
function remove_extra_actions() {
remove_action( 'wp_head', 'extra_add_viewport_meta' );
}
// Appel de 'remove_divi_actions' pendant l'initialisation de WP
add_action('init','remove_extra_actions');
// Ajout du nouveau pinch et zoom avec le maximum-scale à 5
function et_new_viewport_meta(){
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=1" />';
}
add_action( 'wp_head', 'et_new_viewport_meta', 15 );
@Bessonweb
Copy link

Hi and thank you for this script, but it seem not remove the Divi viewport meta tag.

It correctly add the new viewport tag after the first and Google pagespeed Insight is not happy.

viewport

Have you a fix please?

@Glinkfr
Copy link
Author

Glinkfr commented Nov 22, 2023

Hi Bessonweb,

this script is for EXTRA theme and not DIVI, you need to use this script :
https://gist.github.com/Glinkfr/fb77c5aeee77e117117d43b23c0bc965

@Bessonweb
Copy link

Oh thank you and sorry for the mistake :-)

@schoracle
Copy link

Thank you!!

The 'extra_add_viewport_meta' was the last bit of code in the script that I missed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment