Skip to content

Instantly share code, notes, and snippets.

@pacotole
pacotole / flick_fix.css
Last active January 2, 2016 14:59
Evitar parpadeo en webkit con CSS transform
-webkit-transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
@pacotole
pacotole / csstoinline_EN.md
Last active August 16, 2022 14:32
Copy CSS rules to inline styles

Copy CSS rules to inline styles

It's very useful for email layout. You can add css styles in header <style> tag and after apply this script to get the HTML with inline styles.

// remove duplicates from array
// http://www.etnassoft.com/2011/06/24/array-unique-eliminar-valores-duplicados-de-un-array-en-javascript/
Array.prototype.unique = function(a){
  return function(){return this.filter(a)}
}(function(a,b,c){return c.indexOf(a,b+1)<0});
@pacotole
pacotole / clean_diacritics.js
Last active August 29, 2015 14:14
replace diacritics characters with regular chars
// replace diacritics characters with regular character
// if tolower is true return str in lower case
function clean_diacritics(str, tolower) {
var map = {
'ae' : /ä|æ|ǽ/g,
'oe' : /ö|œ/g,
'ue' : /ü/g,
'Ae' : /Ä/g,
'Ue' : /Ü/g,
'Oe' : /Ö/g,
@pacotole
pacotole / change_list.html
Last active February 2, 2016 10:33
Django Suit template for Django Constance
{% extends "admin/base_site.html" %}
{% load i18n admin_static admin_modify suit_tags admin_urls %}
{% load url from suit_compat %}
{% block extrahead %}{{ block.super }}
{% url 'admin:jsi18n' as jsi18nurl %}
<script type="text/javascript" src="{{ jsi18nurl|default:"../../../jsi18n/" }}"></script>
{{ media }}
@pacotole
pacotole / functions.php
Last active April 6, 2023 08:46
Fix conflict between Google Analytics Dashboard for WP (GADWP) and WooCommerce Google Analytics Integration
<?php
/**
* ============================================================================
* Analytics fixes between GADWP and WooCommerce Google Analytics Integration
* ============================================================================
*/
function fix_double_google_analytics () {
if ( ! is_admin() && class_exists( 'WC_Google_Analytics_JS' ) ) {
@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(); },
@pacotole
pacotole / environment-plugin-disabler.php
Last active February 12, 2020 11:58
WP environment plugin disabler
<?php
/**
* Plugin Name: Environment Plugin Disabler
* Description: Disables plugins based on environment settings.
* Version: 1.1.0
* Author: Creame
* Author URI: https://crea.me/
*
* Usage: define and DISABLED_PLUGINS constant with a serialized array
* of plugins to disable (e.g.):
@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 / contact-form-7.php
Last active July 21, 2021 07:45
Only enqueue Contact Form 7 scripts when there is a form in the page
/**
* Contact Form 7 only enqueue scripts when there is a form in the page
*/
// Disable contact-form-7 recaptcha enqueue action
remove_action( 'wp_enqueue_scripts', 'wpcf7_recaptcha_enqueue_scripts', 20 );
// Dequeue contact-form-7 scripts
function contact_form_7_dequeue_scripts() {
wp_dequeue_script( 'contact-form-7' );
@pacotole
pacotole / joinchat-filter-examples.php
Last active May 24, 2021 18:28
Joinchat Agents filter examples of available agents by product category
<?php
// Array filter items that field contains $value
function array_filter_field_contains( $array, $field, $values ) {
return array_filter(
$array,
function( $item ) use ( $field, $values ) {
foreach ( (array) $values as $value ) {
if ( false !== stripos( $item[ $field ], $value ) ) {
return true;