Skip to content

Instantly share code, notes, and snippets.

Created October 26, 2015 22:08
  • Star 18 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save soderlind/610a9b24dbf95a678c3e to your computer and use it in GitHub Desktop.
A faster load_textdomain for WordPress
Plugin Name: A faster load_textdomain
Version: 0.0.1
Description: While we're wating for
Author: Per Soderlind
Author URI:
Plugin URI:
License: GPL
Save the plugin in mu-plugins. You don't have to, but you should add an an object cache. See benchmarks at
Credit: nicofuma , I just created the plugin based on his patch (
function a_faster_load_textdomain($retval, $domain, $mofile) {
global $l10n;
if ( !is_readable( $mofile ) ) return false;
$data = get_transient(md5($mofile));
$mtime = filemtime($mofile);
$mo = new MO();
if (!$data || !isset($data['mtime']) || $mtime > $data['mtime']) {
if ( !$mo->import_from_file( $mofile ) ) return false;
$data = array(
'mtime' => $mtime,
'entries' => $mo->entries,
'headers' => $mo->headers
set_transient(md5($mofile), $data);
} else {
$mo->entries = $data['entries'];
$mo->headers = $data['headers'];
if ( isset( $l10n[$domain] ) ) {
$mo->merge_with( $l10n[$domain] );
$l10n[$domain] = &$mo;
return true;
Copy link

wpsumo commented Jun 30, 2021

@soderlind How will this play with WPML cache? Think they use JSON. How do you verify it is working as it should and stored in Redis object cache, do you SCAN?

Copy link

Is this plugin still functional?

Copy link

wpsumo commented Nov 25, 2021

Guess not.

Copy link

soderlind commented Jul 18, 2023

This plugin is deprecated, use instead

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