Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
/**
* Language Attribute Variant Fix
*
* @package language-attributes-variant-fix
* @author Bernhard Kau
* @license GPLv3
*
* @wordpress-plugin
* Plugin Name: Language Attribute Variant Fix
* Plugin URI: https://kau-boys.de
* Description: Removes the language variant from the laguage attribute used on the HTML root element
* Version: 0.1
* Author: Bernhard Kau
* Author URI: https://kau-boys.de
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
*/
/**
* Strips the language variant
*
* @param string $language_attributes The original language attributes value.
*
* @return string
*/
function language_attributes_variant_fix( $language_attributes ) {
return preg_replace( '/lang="([\w]+-[\w]+)-[\w]+"/', 'lang="$1"', $language_attributes );
}
add_filter( 'language_attributes', 'language_attributes_variant_fix' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment