Skip to content

Instantly share code, notes, and snippets.

@JPry
Created February 25, 2013 18:05
Show Gist options
  • Save JPry/5031883 to your computer and use it in GitHub Desktop.
Save JPry/5031883 to your computer and use it in GitHub Desktop.
For WordPress users who don't speak English as their primary language, fix the text domain for the Limit Login Attempts plugin so that it can be translated properly.
<?php
/**
* Plugin Name: Fix MU Text Domain
* Description: <strong>For use on WPEngine</strong> Since WP Engine includes the plugin "Limit Login Attempts" in the /wp-content/mu-plugins folder instead of the normal /wp-content/plugins folder, the text domain (for translation) is broken. This plugin fixes the text domain issue.
* Version: 1.0
* Author: Jeremy Pry <[email protected]>
* Author URI: http://jeremypry.com
* License GPL3
*/
add_filter( 'load_textdomain_mofile', 'jpry_fix_mu_text_domain', 10, 2 );
/**
* This filters the default location of the .mo file for the Limit Login Attempts plugin on WP Engine
*
* @author Jeremy Pry <[email protected]>
* @param string $mofile The current location of the .mo file
* @param string $domain The plugin domain, used in determining whether or not to actually filter the results
* @return string New location of <var>$mofile</var>
*/
function jpry_fix_mu_text_domain( $mofile, $domain ) {
// Only filter for limit-login-attempts
if ( $domain == 'limit-login-attempts' ) {
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
$mofile = WPMU_PLUGIN_DIR . "/$domain/$domain-$locale.mo";
}
return $mofile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment