Skip to content

Instantly share code, notes, and snippets.

View pacotole's full-sized avatar

Pacotole pacotole

View GitHub Profile
@pacotole
pacotole / mo-cache.php
Last active February 7, 2020 17:33 — forked from soderlind/a_faster_load_textdomain.php
WordPress store translations in external object cache for faster loading
<?php
/*
Plugin Name: .mo file cache
Version: 0.0.1
Description: Store translations in external object cache for faster loading.
Author: Pacotole
Author URI: https://crea.me
Plugin URI: https://gist.github.com/pacotole/85e422a27bb1635d98e1334cd2d5a634
License: GPL
@pacotole
pacotole / best-localStorage-polyfill-evar.js
Last active October 23, 2018 16:17 — forked from juliocesar/best-localStorage-polyfill-evar.js
localStorage polyfill with cookie storage
try {
localStorage.setItem('test', 1);
localStorage.removeItem('test');
} catch(e) {
window.localStorage = {
_data : JSON.parse(document.cookie.replace(/(?:(?:^|.*;\s*)localStorage\s*\=\s*([^;]*).*$)|^.*$/, "$1") || '{}'),
_save : function() { document.cookie = "localStorage=" + JSON.stringify(this._data) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"; },
setItem : function(id, val) { this._data[id] = String(val); this._save(); },
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : null; },
removeItem : function(id) { delete this._data[id]; this._save(); },