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 / bootstrap-looped-grid.js
Created September 6, 2013 13:57
Bootstrap looped item grid
$(document).ready(function(){
var width = $(window).width();
var height = $(window).height();
var divs = $('.item');
if (width >= 1200 ){
for(var i = 0; i < divs.length; i+=4) {
divs.slice(i, i+4).wrapAll('<div class="row"></div>');
}
} else if (width >= 992){
for(var i = 0; i < divs.length; i+=3) {
@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.
*
*/
<?php
function name_of_post_type_register() {
$labels = array(
'name' => _x( 'Post Type Names', 'post type general name' ),
'singular_name' => _x( 'Post Type Name', 'post type singular name' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Post Type Name' ),
'edit_item' => __( 'Edit Post Type Name' ),
'new_item' => __( 'New Post Type Name' ),
'view_item' => __( 'View Post Type Name' ),
<?php
function name_of_taxonomy_create() {
register_taxonomy(
'your_taxonomy_name',
array('post_types_here'),
array(
'label' => __( 'Your Taxonomy Label' ),
'rewrite' => array( 'slug' => 'your_taxonomy_name', 'with_front' => false ),
'hierarchical' => true,
'show_admin_column' => true
@sethrubenstein
sethrubenstein / image-crop-udpate.php
Created November 22, 2013 14:41
If you've ever run into the issue where going into the media library > editing an image > and the image that might be used in a custom field isn't updated on the post this will fix that.
/**
* This will update image sizes on save
*/
function add_image_options($data){
global $_wp_additional_image_sizes;
foreach($_wp_additional_image_sizes as $size => $properties){
update_option($size."_size_w", $properties['width']);
update_option($size."_size_h", $properties['height']);
update_option($size."_crop", $properties['crop']);
}
@sethrubenstein
sethrubenstein / remove_posts_menu.php
Created March 3, 2014 01:48
Remove 'posts' menu from WP admin
function remove_menus() {
global $menu;
$restricted = array( __('Posts'));
end($menu);
while(prev($menu))
{
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0]!= NULL?$value[0]:"", $restricted))
@sethrubenstein
sethrubenstein / fade-to-black-background.css
Created March 3, 2014 01:49
Fade to black background gradient
.element {
background-image: -webkit-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6));
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6));
background-image: -ms-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6));
background-image: -o-linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6));
background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.6));
}
@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 ) {