Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@monecchi
monecchi / responsive-jquery-spectragram-helper.js
Created May 21, 2017 00:27
Helper js function for responsive jQuery Spectragram plugin
/**
* Helper function for responsive jQuery Spectragram
* @require - jquery-spectragram.js plugin - https://github.com/adrianengine/jquery-spectragram
*/
// Target the spectragram's wrapper as per the plugin's docs:
var insta = jQuery('#instagram_feed');
// Check for the wrapper's presence in the DOM
if (insta.length) {
!function(a){jQuery.fn.responsiveInstagram=function(b){var c,d,e,f=a(this),g=a(window).width();return e={width:610,extraHeight:80,breakpoint:620},b=a.extend(e,b),g<=b.breakpoint?f.css("width","100%"):f.css("width",b.width.toString(10)+"px"),c=f.width(),d=Math.round(c+b.extraHeight),f.css("height",d.toString(10)+"px"),this}}(jQuery);
@monecchi
monecchi / function-localize.php
Created June 19, 2017 15:17 — forked from neilgee/function-localize.php
wp_localize_script using Booleans & Integers
<?php
//wp_localize_script by default passes everything in as strings so for booleans and integers when being referenced in your javascript you need to do some trickery
//Example 1 - passing in booleans as strings
$options = get_option('ng_slicknavmenu');
// Add PHP plugin variables to the $params[] array to pass to jQuery
$data = array (
'ng_slicknav_menu' => $options['ng_slicknav_menu'],
'ng_slicknav_position' => $options['ng_slicknav_position'],
@monecchi
monecchi / chrome-color-scheme-alt.tmTheme
Created January 25, 2018 05:39
Modified Chrome Color Scheme for Sublime Text with better syntax for mixed PHP HTML JS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>author</key>
<string>Mattia Astorino</string>
@monecchi
monecchi / functions.php
Created February 23, 2018 20:00 — forked from claudiosanches/functions.php
WooCommerce - Variable product with custom price labels
function custom_variable_price_html( $price, $product ) {
$price = '';
if ( ! $product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) {
$price .= '<span class="from">' . __( 'A partir de' ) . ' </span>';
}
$price .= woocommerce_price( $product->get_price() );
if ( $product->max_variation_price && $product->max_variation_price !== $product->min_variation_price ) {
@monecchi
monecchi / functions.php
Created February 23, 2018 20:02 — forked from claudiosanches/functions.php
WooCommerce - Botão orçar
<?php
function cs_add_to_cart_text( $text ) {
return __( 'Orçar' );
}
// Loop.
add_filter( 'woocommerce_product_add_to_cart_text', 'cs_add_to_cart_text' );
// Single.
add_filter( 'woocommerce_product_single_add_to_cart_text', 'cs_add_to_cart_text' );
/**
* WooCommerce Quanity buttons add-back
*/
jQuery( function( $ ) {
var $testProp = $( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).find('qty');
if ($testProp && $testProp.prop('type') != 'date') {
// Quantity buttons
$( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '<input type="button" value="+" class="plus" />' ).prepend( '<input type="button" value="-" class="minus" />' );
// Target quantity inputs on product pages
@monecchi
monecchi / epsforwordpress.php
Created March 2, 2018 00:27 — forked from dovy/epsforwordpress.php
Add to your functions.php
<?php
function custom_upload_mimes ( $existing_mimes=array() ) {
// Add *.EPS files to Media upload
$existing_mimes['eps'] = 'application/postscript';
return $existing_mimes;
}
add_filter('upload_mimes', 'custom_upload_mimes');
jQuery(document).ready(function($) {
/**
* Media Uploader
*/
var media_uploader = null;
function open_media_uploader_video(img, field) {
media_uploader = wp.media({
title: 'Select or Upload Media',
button: {
text: 'Use this media'
@monecchi
monecchi / ubuntu-install-zeromq.sh
Created March 29, 2018 05:43 — forked from maxsummers/ubuntu-install-zeromq.sh
How to install ZeroMQ 4 on Ubuntu 16.10 from source
#!/usr/bin/env bash
# As in: http://stackoverflow.com/a/41289659/7331008
# Exiting on errors
set -e
# Set required version
VERSION="4.2.0"
@monecchi
monecchi / functions.php
Created April 30, 2018 14:30 — forked from tripflex/functions.php
How to set/use image URL from user's meta value as WordPress Avatar throughout entire site
<?php
add_filter( 'pre_get_avatar_data', 'smyles_set_avatar_based_on_user_meta', 10, 2 );
/**
* Use URL from User Meta for Avatar
*
* This will return a URL value set in the user's meta to use as an avatar, if it
* exists, and is a valid URL. Should work everywhere on the site unless you're
* using a custom avatar plugin that overrides or does not call core get_avatar_data()
*