Skip to content

Instantly share code, notes, and snippets.

View zanematthew's full-sized avatar

Zane Matthew zanematthew

View GitHub Profile
@zanematthew
zanematthew / bootstrap.sh
Last active December 1, 2019 17:33
My shell script for creating a Vagrant 64bit development server
#!/usr/bin/env bash
echo "Running boostrap.sh..."
echo "+---------------------------------------------------+"
echo "| Update apt-get |"
echo "+---------------------------------------------------+"
apt-get update
@zanematthew
zanematthew / gist:5945722
Created July 8, 2013 01:56
non-working IE8 AJAX success. ajaxSubmit plugin: http://jquery.malsup.com/form/#getting-started
$('#jdugc_upload_form').on('submit', function(event) {
event.preventDefault();
$('.loading-icon').show();
$(this).ajaxSubmit({
target: 'myResultsDiv',
type: 'post',
dataType: 'json',
start: function(){
$('.loading-icon').show();
@zanematthew
zanematthew / post-receive.sh
Created January 22, 2013 19:03
This is a git post-receive hook that "deploys" code to your working tree using native git commands, edit as needed.
post-receive#!/bin/sh
###
# This file will deploy code from the repository into the
# specified web-root.
#
# File name: post-receive
#
# Instructions:
# 1. Uncomment and edit the lines below as needed
@zanematthew
zanematthew / gist:3518338
Created August 29, 2012 20:20
Ways to prevent "deep nesting"
<?php
foreach( $items as $item ){
if ( ! $item['name'] )
continue;
print $item['name'];
// more code
// and stuff going on here
@zanematthew
zanematthew / gist:3321350
Created August 11, 2012 05:17
Displaying emails and venue names
<?php
$venues = new Venues;
$venue_ids = $venues->IDs();
$count = count( $venue_ids );
$i = 1;
print '<pre>';
foreach( $venue_ids as $id ){
$email = $venues->contactEmail( $id );
if ( ! $email ){
@zanematthew
zanematthew / gist:3321345
Created August 11, 2012 05:16
Methods for our Venues Controller
<?php
/**
* Returns a object of ALL venues ids
*/
public function IDs(){
global $wpdb;
$query = "select ID from {$wpdb->prefix}posts where post_type = 'venues' and post_status = 'publish'";
$tmp = array();
@zanematthew
zanematthew / events.php
Created August 4, 2012 22:45
Sample Post Type
<?php
$event = new Events();
$event->post_type = array(
array(
'name' => 'Race Event',
'type' => 'events',
'has_one' => 'tracks', // add support 'has_many' => 'other_cpt'
'rewrite' => array(
'slug' => 'events'
@zanematthew
zanematthew / gist:3199265
Created July 29, 2012 14:38
WordPress Update Meta Key
<?php
/**
* Rename meta keys
* Usage: update_meta_key( 'old_key', 'new_key');
*/
function update_meta_key( $old_key=null, $new_key=null ){
global $wpdb;
$query = "UPDATE ".$wpdb->prefix."postmeta SET meta_key = '".$new_key."' WHERE meta_key = '".$old_key."'";
@zanematthew
zanematthew / gist:3199216
Created July 29, 2012 14:23
WordPress Custom Post Type Converter
<?php
/**
* Usage: post_type_converter( 'tracks', 'venues');
*/
function post_type_converter( $from=null, $to=null, $post_id=null ){
global $wpdb;
$query = "SELECT ID, post_type FROM $wpdb->posts WHERE post_type = '{$from}'";
@zanematthew
zanematthew / gist:3185613
Created July 27, 2012 01:18
Arsh Redirect
<?php
add_action( 'template_redirect', 'boo' );
function boo(){
// ge the global post type
global $post_type;
// this is the one we want to match against