Last active
July 22, 2017 06:52
-
-
Save guydumais/9a25917a905b68969044c6a046328aac to your computer and use it in GitHub Desktop.
WordPress ➧ Changer le code de langue WordPress dynamiquement
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
/** | |
* Changer le code de langue WordPress dynamiquement. | |
* | |
* @author Guy Dumais. | |
* @link https://guydumais.digital/changer-le-code-de-langue-wordpress-dynamiquement/ | |
*/ | |
// Filtrer les attributs de langue dans la balise html. | |
add_filter( 'language_attributes', $af = function( $output, $doctype ) { | |
if ( strpos($output, 'fr-FR') !== false ) { | |
$output = str_replace('fr-FR', 'fr-CA', $output); | |
} | |
return $output; | |
}, 10, 2 ); | |
unset( $af ); | |
// Filtrer les attributs de langue des balises og. | |
add_filter( 'locale', $af = function( $locale ) { | |
if( 'fr_FR' == $locale ) { | |
$locale = 'fr_CA'; | |
} | |
return $locale; | |
}, 10 ); | |
unset( $af ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment