Skip to content

Instantly share code, notes, and snippets.

View fabrizim's full-sized avatar

fabrizim

View GitHub Profile
@fabrizim
fabrizim / jquery.prebind.js
Created October 17, 2015 01:29 — forked from jonathanconway/jquery.prebind.js
preBind() - Add an event binding *before* any pre-existing bindings. (An early version, may not work in all scenarios)
$.fn.preBind = function(type, data, fn) {
var currentBindings = this.data('events')[type];
var currentBindingsLastIndex = currentBindings.length - 1;
var newBindings = [];
// bind the event
this.bind(type, data, fn);
// move the new event to the top of the array
newBindings.push(currentBindings[currentBindingsLastIndex]);
@fabrizim
fabrizim / gravity-ajax-fix.js
Created October 14, 2015 23:37
Gravity Forms: Prevent duplicate form submission on back button
jQuery(function($){
$(document).on('gform_post_render', function(e, form_id){
$('#gform_ajax_frame_'+form_id).attr('src', 'about:blank');
});
});
/**
* Retrieve the stored shopping cart and pass it to the callback.
*/
sync : function(){
return $.get('/modules/booking/content/functions.cfc?method=getCartJSONAjax&returnFormat=json');
},
@fabrizim
fabrizim / fix_mysql_passwords
Created October 17, 2014 02:53
Update passwords after MySQL upgrade
#! /usr/bin/env php
<?php
echo "MySQL root Password: ";
system('stty -echo');
$root_password = trim(fgets(STDIN));
system('stty echo');
// add a new line since the users CR didn't echo
echo "\n";
jQuery(function($){
if( $('body').hasClass('disable-scribd') ) return;
// check for a disable variable
var pairs = window.location.search.replace(/^\?/, '').split('&');
var disabled = false;
$.each(pairs, function(i, pair){
var keyval = pair.split('=');
if( keyval[0] == 'disable-scribd' ){
disabled = true;
return false;
@fabrizim
fabrizim / acf_fix_local_fields.php
Created October 16, 2014 00:00
Fix local fields for ajax queries
<?php
class acf_fix_local_fields
{
public function __construct()
{
add_action('acf/include_fields', array($this, 'fix_local_fields'), 20 );
}
public function fix_local_fields()
@fabrizim
fabrizim / iframe.js
Last active April 12, 2024 14:33
Javascript for updating iframe height with postMessage
(function(){
function post_height(){
var msg = JSON.stringify({event:'size', height: document.body.scrollHeight});
window.top.postMessage(msg, '*');
}
var onload = window.onload;
window.onload = function(){
if( onload && typeof onload =='function'){
@fabrizim
fabrizim / acf-customizer-patch.php
Last active January 17, 2024 02:30
Plugin to allow for Advanced Custom Fields to be used in widgets within the Customizer
<?php
/*
Plugin Name: ACF Customizer Patch
Plugin URI: https://gist.github.com/fabrizim/9c0f36365f20705f7f73
Description: A class to allow acf widget fields to be stored with normal widget settings and allow for use in customizer.
Author: Mark Fabrizio
Version: 1.0
Author URI: http://owlwatch.com/
*/
class acf_customizer_patch
@fabrizim
fabrizim / .htaccess
Last active December 27, 2015 18:49
RewriteRule ^(.+\.axd.*) ./proxy/index.php [NC,L]
RewriteRule ^((images|Documentation|DesktopModules|tabid/(364|622|623|624|625|626|627|628|650)|(P|p)ortals|Scripts|Developers|js|Home/Login|Gizmox/Store|Gizmox/Solutions|Gizmox/Landing)/.*) ./proxy/index.php [L]
@fabrizim
fabrizim / gist:6829389
Last active December 24, 2015 16:39
Use wp-less to process editor stylesheets.
<?php
add_filter('mce_css', 'theme_mce_less');
function theme_mce_less($css)
{
$handle = 'editor';
$less_plugin = WPLessPlugin::getInstance();
wp_enqueue_style($handle, get_stylesheet_directory_uri()."/assets/stylesheets/editor.less");
$less_plugin->processStylesheets();
global $wp_styles;