Skip to content

Instantly share code, notes, and snippets.

View eliorivero's full-sized avatar

Elio Rivero eliorivero

View GitHub Profile
@eliorivero
eliorivero / get-initials.js
Created February 5, 2020 21:22
Get word initials
/**
* Given a string of words separated by spaces, return the first letter of the first two words.
* Originally intended to get the initials of a "name lastName" string.
*
* @param {string} words A list of words. Only the first two are taken into account the rest are ignored.
*
* @returns {string}
*/
const getNameInitials = words => name.split(' ').slice(0, 2).reduce( (acc, cur) => acc + cur[0], '' );
@eliorivero
eliorivero / mueve-campos.php
Created December 29, 2016 02:09
Mueve los campos de nombre, sitio e email arriba de la caja de comentario.
<?php
/**
* Plugin Name: Mueve los campos
* Plugin URI: http://elio.blog/
* Description: Mueve los campos de nombre, sitio e email arriba de la caja de comentario.
* Author: @eliorivero
* Version: 0.0.7
* Author URI: http://elio.blog/
*/
@eliorivero
eliorivero / isinfscr.js
Created June 18, 2015 20:47
Detect Infinite Scroll load
$( document ).ajaxSend(function( e, request, settings ) {
// settings.url is something like http://queryloop.com/some-paginated-view/page/2/
var page = settings.url.replace( /^(.*?)(\/page\/\d+\/)/i, '$2' ),
regex = /^\/page\/\d+\//i,
match;
if ( ( match = regex.exec( page ) ) !== null ) {
if ( match.index === regex.lastIndex ) {
regex.lastIndex++;
}
(function($){
// Set a flag.
var didScroll = false;
// On scroll event, set the flag to true.
$(window).on('scroll', function() {
didScroll = true;
});
@eliorivero
eliorivero / ilc-shortbar.php
Created February 23, 2013 06:04
Class for WordPress that creates creates multiple sidebars that can be called using a related shortcode.
<?php
/**
* Plugin Name: ILC Shortbar
* Plugin URI: http://ilovecolors.com.ar/
* Description: Creates creates multiple sidebars that can be called using a related shortcode.
* Author: Elio Rivero
* Author URI: http://ilovecolors.com.ar
* Version: 1.0.0
*/
<?php
/**
* Show Woocommerce custom attributes
*/
global $product;
$custom_attributes = array();
foreach ( $product->get_attributes() as $slug => $attr ) {
@eliorivero
eliorivero / gist:4015177
Created November 5, 2012 03:37
Remove fixed width from embedded tweets in WordPress for responsiveness
/**
* Remove fixed width from embedded tweets. First step to make them responsive.
* @param string $html HTML that should be used to embed
* @param string $url The URL to the content that should be attempted to be embedded.
* @param array $args Optional arguments.
* @author Elio Rivero
* @link http://www.ilovecolors.com.ar/
*/
function themesrobot_oembed_result($html, $url, $args){
// Check if it's a tweet looking for 'twitter' in the url pasted in the post
@eliorivero
eliorivero / script.js
Created October 30, 2012 19:45
Drop down menus for iPad
function isTouch() {
try {
document.createEvent('TouchEvent');
return true;
} catch(e) {
return false;
}
}
jQuery(document).ready(function($) {