Plugin Directory

Changeset 351932

Timestamp:
02/26/2011 05:21:22 PM (13 years ago)
Author:
macbre
Message:

l10ncache: make it work with plural forms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • l10n-cache/trunk/l10n-cache.php

    r350665 r351932  
    22/**
    33 * @package l10n cache
    4  * @version 0.2
     4 * @version 0.3
     5 * @see http://wordpress.org/extend/plugins/l10n-cache/
    56 *
    67 * $Id$
     
    1011Description: Improves site performance by providing caching for localisation objects (*.mo files)
    1112Author: Maciej Brencz
    12 Version: 0.2
     13Version: 0.
    1314Author URI: http://macbre.net
    1415*/
     
    1819 */
    1920class l10nCache {
     21
     22
    2023    private $cached = false;
    2124    private $cacheDir;
     
    3033     */
    3134    function __construct() {
    32         // don't run when in wp-admin panel
    33         // TODO: fix it :)
    34         if (defined('WP_ADMIN') && WP_ADMIN) {
    35             return;
    36         }
    37 
    3835        // set up path to cache directory
    3936        $this->cacheDir = WP_CONTENT_DIR . '/cache';
     
    4744        // add caching info to the footer
    4845        add_action('wp_footer', array(&$this, 'addFooter'));
     46
    4947    }
    5048
     
    5957
    6058        // caching location
    61         $hash = md5($mofile . $wp_version);
     59        $hash = md5($mofile . $wp_version);
    6260        $this->cacheFile = "{$this->cacheDir}/l10n-cache-{$this->domain}-{$hash}.cache";
    6361
     
    9593            $obj = isset($l10n[$this->domain]) ? $l10n[$this->domain] : false;
    9694
    97             // store it
    98             if (!empty($obj)) {
     95            if ($obj instanceof MO) {
     96                // perform object's cleanup
     97                unset($obj->_gettext_select_plural_form);
     98
     99                // store it
    99100                file_put_contents($this->cacheFile, serialize($obj));
    100101            }
Note: See TracChangeset for help on using the changeset viewer.