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 / upload-a-file.MD
Created January 2, 2019 14:35 — forked from ahmadawais/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

<div>
<label for="sort-by">Sort by</label>
<select id="sort-by">
<option value="manual">Featured</option>
<option value="price-ascending">Price: Low to High</option>
<option value="price-descending">Price: High to Low</option>
<option value="title-ascending">A-Z</option>
<option value="title-descending">Z-A</option>
<option value="created-ascending">Oldest to Newest</option>
<option value="created-descending">Newest to Oldest</option>
@lmartins
lmartins / related-products.liquid
Created November 16, 2017 11:29 — forked from carolineschnapp/related-products.liquid
Related Products — to add to product.liquid
@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");
@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
<?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 / 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 / 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 );