Skip to content

Instantly share code, notes, and snippets.

View lmartins's full-sized avatar

Luis Martins lmartins

  • Goodwin Media, Multiweb
  • Portugal
View GitHub Profile
@lmartins
lmartins / gist:5cb70eb0dc1834020fa7b54c10cffec2
Created April 3, 2016 10:08 — forked from kyleaparker/gist:560a3847860bace1d680
[Shopify] Show multiple images per variant
<script>
jQuery(document).ready(function($){
var images = [];
{% for image in product.images %}
images.push({url: "{{ image | product_img_url: 'medium' }}", alt: "{{ image.alt }}"});
{% endfor %}
var thumbnails = $(".thumbs");

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@lmartins
lmartins / sale-flash.php
Created January 11, 2016 21:07 — forked from vividvilla/sale-flash.php
Display Discount/Offer percentage in WooCommerce
<?php
/**
* Product loop sale flash
*
* @author Vivek R @ WPSTuffs.com
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@lmartins
lmartins / themarkup.html
Created December 28, 2013 17:03 — forked from blackfalcon/themarkup.html
Create UI badge using data attributes and CSS for content
<a href="#" rel="docs" data-notification="3">docs</a>
@lmartins
lmartins / gist:4007169
Created November 3, 2012 11:57 — forked from tomschlick/gist:3984898
Sublime Text 2 Keybindings to Resize Split Panes
[
{
"keys": ["super+shift+left"],
"command": "set_layout",
"args":
{
"cols": [0.0, 0.33, 1.0],
"rows": [0.0, 1.0],
"cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
}
<?php
// hide coupon field on cart page
function hide_coupon_field_on_cart( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
/**
* A function to reorder the default display of fields on the WooCommerce Bookings form
* Put this function in your theme's functions.php file
*/
function custom_order_booking_fields ( $fields ) {
$reorder = array();
$reorder[] = $fields['wc_bookings_field_duration'];
$reorder[] = $fields['wc_bookings_field_resource'];
$reorder[] = $fields['wc_bookings_field_persons'];
@lmartins
lmartins / category-1.php
Last active August 29, 2015 14:10 — forked from studiopress/category-1.php
Conditionally add classes to the body tag
<?php
//* Do NOT include the opening php tag
//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
if ( is_category( '1' ) )
$classes[] = 'custom-class';
return $classes;
add_action( 'genesis_after_post', 'reposition_jetpack_sharing_buttons' );
/**
* @author Brad Dalton - WP Sites
* @example http://wp.me/p1lTu0-95n
*/
function reposition_jetpack_sharing_buttons(){
remove_filter( 'the_excerpt', 'sharing_display', 19 );
remove_filter( 'the_content', 'sharing_display', 19 );
<?php
/**
* Get post image.
*/
function wds_get_post_image( $size = 'thumbnail' ) {
// Check for featured image
if ( has_post_thumbnail() ) {
the_post_thumbnail( $size );