Skip to content

Instantly share code, notes, and snippets.

// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@stephenh1988
stephenh1988 / sh-wp-dropdown-taxonomies.php
Created June 9, 2012 20:40
A walker class to use that extends wp_dropdown_categories and allows it to use the term's slug as a value rather than ID
<?php
/*
* A walker class to use that extends wp_dropdown_categories and allows it to use the term's slug as a value rather than ID.
*
* See http://core.trac.wordpress.org/ticket/13258
*
* Usage, as normal:
* wp_dropdown_categories($args);
*
@bueltge
bueltge / attachment-taxononimies.php
Created December 6, 2012 11:38
WordPress Attachment Taxonomies with WP 3.5*
<?php
/**
* Plugin Name: Attachment Taxonomies
* Plugin URI: attachment_taxonomies
* Text Domain: addquicktag
* Domain Path: /languages
* Description:
* Version: 1.0.0
* Author: Frank Bültge
* Author URI: http://bueltge.de
@sosukeinu
sosukeinu / wp_auto_thumbnail_functions.php
Created January 29, 2013 16:07
WP function auto featured image
<?php
/*
* This function will get the first image in this order:
*
* 1) Featured image
* 2) First image attached to post
* 3) First image URL in the content of the post
* 4) YouTube screenshot
* 5) Default images for different categories [SET MANUALLY]
@lschatzkin
lschatzkin / custom-gallery-shortcode.php
Created February 28, 2013 17:15
custom gallery shortcode for WordPress
@carolineschnapp
carolineschnapp / gist:9122054
Last active October 25, 2024 16:31
Order form to use in a page or collection template.
{% comment %}
Source: https://gist.github.com/carolineschnapp/9122054
If you are not on a collection page, do define which collection to use in the order form.
Use the following assign statement, replace 'your-collection-handle-here' with your collection handle.
{% assign collection = collections.your-collection-handle-here %}
Use the assign statement outside of this comment block at the top of your template.
{% endcomment %}
{% paginate collection.products by 100 %}
@cjmox
cjmox / Related posts
Created February 20, 2014 21:33
WordPress: Related Posts based on category of current post
@tkirrane
tkirrane / companion-product
Last active July 22, 2020 14:03
Add a companion product to cart page
{% comment %}
To add a companion product to the cart automatically if a primary product is in cart:
1. Create a new link list under your Navigation tab.
2. In that link list, make the first link point to companion product.
3. Copy your link list handle where indicated at line 8:
{% endcomment %}
{% assign linklist = linklists['put-your-link-list-handle-here'] %}
{% comment %}
@Pleiades
Pleiades / gist:b9711273719a401d52f3
Created August 26, 2014 22:09
Sample WordPress Action and Filter Hooks
Code Samples for Hooks And Filters Class
<?php
/* Filter the title to add a page number if necessary.
------------------------------------------------------------------------------------ */
add_filter( 'wp_title', 'page_numbered_wp_title', 10, 2 );
function page_numbered_wp_title( $title, $sep ) {
@lucased
lucased / shopify-add-to-cart
Created October 30, 2014 11:03
Shopify - Add product to cart automatically
if (typeof Shopify === 'undefined') var Shopify = {};
Shopify.cart = {{ cart | json }};
Shopify.toAdd = 378589397;
var surchargeInCart = false;
var total = 2507; // total in cents.
for (var i=0; i<Shopify.cart.items.length; i++) {
if (Shopify.cart.items[i].id === Shopify.toAdd) {
surchargeInCart = true;
total -= Shopify.cart.items[i].line_price;