Skip to content

Instantly share code, notes, and snippets.

View zanematthew's full-sized avatar

Zane Matthew zanematthew

View GitHub Profile
@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 / 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: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 / 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: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 / 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
#!/usr/bin/env bash
#apt-get install -y git-all
## Themes
REPOS[0]='[email protected]:zanematthew/sample.git'
REPOS[1]='[email protected]:zanematthew/sample-2.git'
for repo in ${REPOS[*]}
do
@zanematthew
zanematthew / welcome.php
Created December 12, 2014 17:27
Note this is a snippet from a class, you can replace the $this-> with your params or hardcode them. Its all ran during admin_init.
<?php
/**
* Sends user to the start page on first activation, as well as each time the
* plugin is upgraded to a new version
*
* @access public
* @since 1.1
* @return void
*/
@zanematthew
zanematthew / gist:f8440442df8524a9dff0
Created December 12, 2014 17:31
Storing plugin version number on activation and deleting it during plugin deactivation.
<?php
/**
* Manging of version numbers when plugin is activated
*/
function MYPLUGIN_install() {
// Add Upgraded From Option
$current_version = get_option( MYPLUGIN_NAMESPACE . '_version' );
if ( $current_version ) {
@zanematthew
zanematthew / plugin.php
Last active August 29, 2015 14:11
Plugin Action Links
<?php
/**
* Add our links to the plugin page, these show under the plugin in the table view.
*
* @param $links(array) The links coming in as an array
* @param $current_plugin_file(string) This is the "plugin basename", i.e., my-plugin/plugin.php
*/
function my_plugin_action_links( $links, $current_plugin_file ){
if ( $current_plugin_file == 'my-plugin/plugin.php' ){