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: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]]
}

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 / 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>
# Swappable Mixins in CoffeeScript
# ================================
# Many thanks to Hashmal, who wrote this to start.
# https://gist.github.com/803816/aceed8fc57188c3a19ce2eccdb25acb64f2be94e
# Usage
# -----
# class Derp extends Mixin
@lmartins
lmartins / template-test.php
Last active April 11, 2019 00:59 — forked from billerickson/template-test.php
Genesis Custom Loop
<?php
/* Template Name: Test */
/**
* Genesis custom loop
*/
function be_custom_loop() {
global $post;
// arguments, adjust as needed
@lmartins
lmartins / gist:c84fc899832cf7b560b7
Last active August 29, 2015 14:07 — forked from corsonr/gist:3ac30cc334cf344dbb3b
Change related products thumbnail size
<?php
add_filter( 'wp_head' , 'related_products_style' );
function related_products_style() {
if( is_product() ) :
?>
<style>
.woocommerce .related ul.products li.product, .woocommerce .related ul li.product, .woocommerce .upsells.products ul.products li.product, .woocommerce .upsells.products ul li.product, .woocommerce-page .related ul.products li.product, .woocommerce-page .related ul li.product, .woocommerce-page .upsells.products ul.products li.product, .woocommerce-page .upsells.products ul li.product {
width: 24% !important;
@lmartins
lmartins / gist:8a0643b32efd4592125e
Created October 8, 2014 07:40 — forked from corsonr/gist:ba033db9978a536b2b05
Show products weight in the cart process
<?php
// Store cart weight in the database
add_action('woocommerce_checkout_update_order_meta', 'woo_add_cart_weight');
function woo_add_cart_weight( $order_id ) {
global $woocommerce;
$weight = $woocommerce->cart->cart_contents_weight;
update_post_meta( $order_id, '_cart_weight', $weight );
}
@lmartins
lmartins / gist:cc13a804a7bcea1bd1b0
Created October 8, 2014 07:41 — forked from corsonr/gist:e5e5c5fc944c278049de
WooCommerce Subscriptions: edit sign-up button text
<?php
function woocommerce_custom_subscription_product_single_add_to_cart_text( $text = '' , $post = '' ) {
global $product;
if ( $product->is_type( 'subscription' ) ) {
$text = get_option( WC_Subscriptions_Admin::$option_prefix . '_add_to_cart_button_text', __( 'Sign Up Now', 'woocommerce-subscriptions' ) );
} else {
$text = $product->add_to_cart_text(); // translated "Read More"
}
@lmartins
lmartins / gist:04f81dbad4246fd49d1e
Created October 8, 2014 07:43 — forked from corsonr/gist:9071214
WooCommerce - Store terms and conditions value within the database
<?php
/**
* Store terms and conditions value within the database
**/
add_action('woocommerce_checkout_update_order_meta', 'woo_save_terms_and_conditions_status');
function woo_save_terms_and_conditions_status( $order_id ) {
if ($_POST['terms']) update_post_meta( $order_id, '_terms', esc_attr($_POST['terms']));
}
@lmartins
lmartins / gist:cdafd234879acf5e2160
Created October 8, 2014 07:45 — forked from corsonr/gist:7370707
WooCommerce - display order coupons used in confirmation email and edit order page
add_action( 'woocommerce_email_after_order_table', 'add_payment_method_to_admin_new_order', 15, 2 );
/**
* Add used coupons to the order confirmation email
*
*/
function add_payment_method_to_admin_new_order( $order, $is_admin_email ) {
if ( $is_admin_email ) {