Skip to content

Instantly share code, notes, and snippets.

@imath
Created September 20, 2016 08:58
Show Gist options
  • Save imath/46303100666f7243c30c67d8ac18ed6d to your computer and use it in GitHub Desktop.
Save imath/46303100666f7243c30c67d8ac18ed6d to your computer and use it in GitHub Desktop.
Put this in any random file inside wp-content/mu-plugins to fix all custom language packs for plugins. Make sure the corresponding custom language packs are in WP_LANG_DIR/pluginName/
<?php
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
function fix_all_custom_language_packs_load_textdomain_mofile( $mofile, $domain ) {
if ( WP_LANG_DIR . '/plugins' === dirname( $mofile ) ) {
$mo = basename( $mofile );
$alt = trailingslashit( WP_LANG_DIR ) . $domain . '/';
if ( file_exists( $alt . $mo ) ) {
return $alt . $mo;
}
}
return $mofile;
}
add_filter( 'load_textdomain_mofile', 'fix_all_custom_language_packs_load_textdomain_mofile', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment