Plugin Directory

Changeset 166247


Ignore:
Timestamp:
10/23/2009 10:11:53 AM (16 years ago)
Author:
johanee
Message:

Whitelist which get_locale calls to filter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cache-translation-object/trunk/cache-translation-object.php

    r166142 r166247  
    103103    global $l10n, $cache_translation_cached;
    104104
     105    if (!cachet_handle_this_call() || empty($locale))
     106        return $locale;
     107
    105108    if ($cache_translation_cached) {
    106109        /* We have already restored a cached translation object */
     
    181184
    182185
     186/* Only handle calls from the load_*_textdomain functions */
     187function cachet_handle_this_call() {
     188    $whitelist = Array('load_default_textdomain', 'load_plugin_textdomain', 'load_theme_textdomain');
     189
     190    if (!is_callable('debug_backtrace'))
     191        return true;
     192
     193    $bt = debug_backtrace();
     194    foreach ( (array) $bt as $call ) {
     195        if ( in_array($call['function'], $whitelist) )
     196            return true;
     197    }
     198
     199    return false;
     200}
     201
     202
    183203/*
    184204 * Store the complete translation object at shutdown (once).
Note: See TracChangeset for help on using the changeset viewer.