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 / woo-single-product.php
Created January 7, 2015 20:31
Change the default number of related products
/**
* ----------------------------------------------------------------------------
* CHANGE THE NUMBER OF RELATED PRODUCTS
* ----------------------------------------------------------------------------
*/
add_filter( 'woocommerce_output_related_products_args', 'mw_related_products_args' );
function mw_related_products_args( $args ) {
$args['posts_per_page'] = 4; // 4 related products
@lmartins
lmartins / woocommerce.php
Created December 30, 2014 09:57
Replace WooCommerce default thumbnail placeholder
/*
* goes in theme functions.php or a custom plugin. Replace the image filename/path with your own :)
*/
add_action( 'init', 'custom_fix_thumbnail' );
function custom_fix_thumbnail() {
add_filter('woocommerce_placeholder_img', 'custom_woocommerce_placeholder_img');
function custom_woocommerce_placeholder_img( $src ) {
@lmartins
lmartins / woocommerce.php
Created December 26, 2014 15:19
Limit the product types available in the WooCommerce Dashboard
/**
* Limit the product types that can be added to the store
*/
add_filter( 'product_type_selector', 'mw_custom_product_type_change', 20 );
function mw_custom_product_type_change( $product_types ) {
$new_array = array(
'subscription' => $product_types['subscription'] ,
'variable-subscription' => $product_types['variable-subscription'] ,
);
// $product_types = $new_array + $product_types;
@lmartins
lmartins / gulpfile.js
Last active September 2, 2018 17:08 — forked from anonymous/gulpfile.js
Show sass compilation errors in the browser
var gulp = require("gulp");
var sass = require("gulp-sass");
var autoprefix = require("gulp-autoprefixer");
var filter = require('gulp-filter');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
/**
* Start BrowserSync
*/
@lmartins
lmartins / functions.php
Created December 17, 2014 19:23
Activate cropping for all thumbnail sizes
// Standard Size Thumbnail
if(false === get_option("thumbnail_crop")) {
add_option("thumbnail_crop", "1"); }
else {
update_option("thumbnail_crop", "1");
}
// Medium Size Thumbnail
if(false === get_option("medium_crop")) {
add_option("medium_crop", "1"); }
@lmartins
lmartins / main.scss
Created December 17, 2014 14:09
Color management with Sass
// Color Settings
$color: (
nav: (
text: #333,
text-hover: #FFF,
bg: #FFF,
bg-hover: #FEF160
),
site-footer: (
title: #FFF,
@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' ) {
// If featured image is present, use that
if ( has_post_thumbnail() ) {
return get_the_post_thumbnail( $size );