Skip to content

Instantly share code, notes, and snippets.

View sethrubenstein's full-sized avatar

Seth Rubenstein sethrubenstein

View GitHub Profile
<?php
/**
* WordPress Chosen Taxonomy Metabox
* Author: Helen Hou-Sandi
*
* Use Chosen for a replacement taxonomy metabox in WordPress
* Useful for taxonomies that aren't changed much on the fly and are
* non-hierarchical in nature, as Chosen is for flat selection only.
* You can always use the taxonomy admin screen to add/edit taxonomy terms.
* Categories need slightly different treatment from the rest in order to
@sethrubenstein
sethrubenstein / acf-auto-export.php
Last active May 19, 2016 03:31 — forked from raideus/acf-auto-export.php
Changed get_template_directory to get_stylesheet_directory to facilitate child themes
<?php
/**
* Automated PHP export for Advanced Custom Fields
*
* Export is initiated whenever an admin publishes a new field group
* or saves changes to an existing field group.
*
* Place this code in your theme's functions.php file.
*
*/
@sethrubenstein
sethrubenstein / gist:9487091
Created March 11, 2014 14:37 — forked from corsonr/gist:6725310
Redirect product add to cart to checkout
add_filter ('add_to_cart_redirect', 'woo_redirect_to_checkout');
function woo_redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
<?php
add_filter( 'woocommerce_checkout_fields' , 'woo_remove_billing_checkout_fields' );
/**
* Remove unwanted checkout fields
*
* @return $fields array
*/
function woo_remove_billing_checkout_fields( $fields ) {
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed
/***
* Gravity Forms: Validate to ensure date fields are not the same or todays date
*
* This will validate the fields on form submission and return a validation error on the fields in question.
* In this case it validates an Arrival and Departure date against each other and today's date.
*
* Code goes in your theme's functions.php file.
***/
add_filter('gform_field_validation','validate_dates',10,4);
/**
* Override WP oEmbed
* @version 1.0
*/
add_filter( 'embed_oembed_html', 'mycred_override_video_shortcode', 999, 4 );
function mycred_override_video_shortcode( $original, $url, $attr, $post_ID ) {
// If myCRED is not enabled
if ( ! function_exists( 'mycred_render_shortcode_video' ) ) return $original;
// Get cache
@sethrubenstein
sethrubenstein / excerpt-length.php
Last active August 29, 2015 14:17 — forked from danielpataki/excerpt-length.php
Some nice WP filters and functions to make posts better.
add_filter( 'excerpt_length', 'my_excerpt_length' );
function my_excerpt_length( $length ) {
return 110;
}
location ~* \.(jpe?g|gif|png)$ {
try_files $uri @photon;
}
location @photon {
rewrite ^(.*)-([0-9]+)x([0-9]+)\.(jpe?g|gif|png)$ http://i0.wp.com/$host$1.$4?resize=$2,$3;
rewrite . http://i0.wp.com/$host$request_uri;
}
@sethrubenstein
sethrubenstein / mailchimp-103115.html
Created November 2, 2015 20:56
Pew Mailchimp Template
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--[if !mso]><!-->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<link rel="stylesheet" type="text/css" href="styles.css">