Skip to content

Instantly share code, notes, and snippets.

View fabrizim's full-sized avatar

fabrizim

View GitHub Profile
@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_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()
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 / 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";
/**
* 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 / 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');
});
});
@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 / search.js
Created April 28, 2017 17:23
Search Form Handler
var $ = jQuery;
module.exports = {
init : function(){
$(document).on('submit', 'form.searchform', function(e){
if( window.angular ){
e.preventDefault();
var $form = $(e.currentTarget);
var data = $form.serialize();
var $injector = angular.element( $('html')[0] ).injector();
@fabrizim
fabrizim / .htaccess
Last active March 12, 2020 17:36
wp-content/uploads filler for staging environments
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp\-content\/uploads(.*)$ https://production-domain.com/wp-content/uploads$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^wp\-content\/blogs(.*)$ https://production-domain.com/wp-content/blogs$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
@fabrizim
fabrizim / vc_row.php
Last active May 8, 2018 15:36
Jupiter Theme 6.1.3 - ID Attribute Escaped Twice
<?php
$path = pathinfo( __FILE__ ) ['dirname'];
include( $path . '/config.php' );
wp_enqueue_script( 'wpb_composer_front_js' );
$fullwidth_start = $output = $fullwidth_end = '';