Skip to content

Instantly share code, notes, and snippets.

View micc83's full-sized avatar

Alessandro Benoit micc83

View GitHub Profile
jQuery(document).ready( function($) {
function send_popup( title, text, popup_class, delay ) {
// Initialize parameters
title = title !== '' ? '<span class="title">' + title + '</span>' : '';
text = text !== '' ? text : '';
popup_class = popup_class !== '' ? popup_class : 'update';
delay = typeof delay === 'number' ? delay : 20000;
@micc83
micc83 / gist:9665159
Created March 20, 2014 14:37
Wordpress return 404
<?php
function return_page_404() {
global $wp_query;
$wp_query->set_404();
status_header(404);
}
@micc83
micc83 / iframe-height.js
Created June 23, 2014 17:01
Set iframe height based on content
jQuery('iframe.inpagedemo').load(function () {
var iframe = jQuery(this);
jQuery(window).resize(function() {
iframe.height(iframe[0].contentWindow.document.body.scrollHeight + 40);
});
jQuery(window).trigger('resize');
});
@micc83
micc83 / default.vcl
Created July 4, 2014 07:39
WordPress custom Varnish configuration
backend default {
.host = "127.0.0.1";
.port = "8080";
}
acl purge {
"localhost";
"127.0.0.1";
}
@micc83
micc83 / tutorial-chat-app.html
Created July 16, 2014 08:04
Tutorial: Creare una chat in tempo reale con Firebase e login facebook
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MyApp</title>
<style>
@micc83
micc83 / skip-to-check-out.php
Last active April 11, 2024 00:13
Skip cart and redirect to direct checkout on WooCommerce
<?php
/**
* Skip cart and redirect to direct checkout
*
* @package WooCommerce
* @version 1.0.0
* @author Alessandro Benoit
*/
// Skip the cart and redirect to check out url when clicking on Add to cart
@micc83
micc83 / Restfulizer.js
Created September 25, 2014 14:55
Ruby like delete links on laravel
/**
* Restfulizer
*
* Restfulize any hiperlink that contains a data-method attribute by
* creating a mini form with the specified method and adding a trigger
* within the link.
* Requires jQuery!
*
* Ex:
* <a href="post/1" data-method="delete">destroy</a>
@micc83
micc83 / wp_sync_roles.php
Last active August 29, 2015 14:07
Sync roles between different WordPress Blog inside the same schema on first login
<?php
/**
* Sync roles between different WordPress Blog
*
* Tables must be inside the same schema and you have to define
* custom user tables on wp-config.php in the SLAVE blog as follow:
+ define('CUSTOM_USER_TABLE', 'myprefix_users');
+ define('CUSTOM_USER_META_TABLE', 'myprefix_usermeta');
* Sync is run only at the first login on the alternative blog, any following
* role change must be manually sync.
@micc83
micc83 / fb.css
Created October 9, 2014 08:44
Facebook fix for truncated share box clicking on like button
/* Facebook fix */
.fb-like span{overflow:visible !important; width:450px !important; margin-right:-375px;z-index: 999;}
@micc83
micc83 / add_query_args.js
Created October 28, 2014 20:05
Add query args to url
/**
* Add query args
*/
function add_query_args(uri, params) {
var separator = uri.indexOf('?') !== -1 ? '&' : '?';
for (var key in params) {
if(params.hasOwnProperty(key)){
uri += separator + key + '=' + params[key];
separator = '&';
}