Skip to content

Instantly share code, notes, and snippets.

View zanematthew's full-sized avatar

Zane Matthew zanematthew

View GitHub Profile
@zanematthew
zanematthew / Template Redirect Switch
Created August 28, 2011 02:31
Redirecting a template in WordPress using a switch. This is used inside of a plugin when you want to allow default template for a Custom Post Type your template is generating.
case ( is_tax( $my_taxonomies ) ):
global $wp_query;
if ( in_array( $wp_query->query_vars['taxonomy'], $my_taxonomies ) ) {
foreach ( $my_taxonomies as $taxonomy ) {
load_template( MY_PLUGIN_DIR . 'theme/archive-' . $k['type'] . '.php' );
// load_template( MY_PLUGIN_DIR . 'theme/taxonomy-' . $my_taxonomies. '.php' );
}
}
exit;
@zanematthew
zanematthew / Remind me!
Created August 28, 2011 05:05
When entering a directory show the last entered notes that are in Git. This is used as a quick reminder for a forgetful programmer.
#!/bin/bash
if [ ${PWD##*/} == task-tracker ]; then
echo `git notes show`
fi
@zanematthew
zanematthew / gist:1187330
Created September 1, 2011 21:28
My Git Config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[color]
ui = auto
interactive = true
@zanematthew
zanematthew / gist:1218426
Created September 15, 2011 03:08
Template Redirect loopy
foreach( $this->post_type as $wtf ) {
$my_cpt = get_post_types( array( 'name' => $wtf['type']), 'objects' );
if ( is_tax( $wtf['taxonomies'] ) ) {
global $wp_query;
if ( in_array( $wp_query->query_vars['taxonomy'], $wtf['taxonomies'] ) ) {
if ( file_exists( MY_PLUGIN_DIR . 'theme/custom/' . $wtf['type'] . '-taxonomy.php' ) ) {
load_template( MY_PLUGIN_DIR . 'theme/custom/' . $wtf['type'] . '-taxonomy.php' );
} elseif ( file_exists( MY_PLUGIN_DIR . 'theme/default/taxonomy.php' ) ) {
load_template( MY_PLUGIN_DIR . 'theme/default/taxonomy.php' );
@zanematthew
zanematthew / gist:1248680
Created September 28, 2011 17:58
Basic Bash Profile
######
#
# NOTE, you must reload your profile for these changes to take effect
# [your name ~] source .bash_profile
# color codes: http://www.funtoo.org/en/articles/linux/tips/prompt/
#
######
######
#
$_GLOBALS['task'] = new CustomPostType();
$_GLOBALS['task']->post_type = array(
array(
'name' => 'Task',
'type' => 'task',
'supports' => array(
'title',
'editor',
'author',
'comments'
interface ICustomPostType {
public function registerPostType( $param=array() );
public function registerTaxonomy( $param=array() );
// @todo http://codex.wordpress.org/Function_Reference/locate_template
public function templateRedirect();
public function regsiterActivation();
// public function regsiterDeactivation();
// public function baseStyleSheet( $param=array() );
public function registerPostType( $args=NULL ) {
foreach ( $this->post_type as $post_type ) {
if ( !empty( $post_type['taxonomies'] ) )
$taxonomies = $post_type['taxonomies'];
.
.
.
.
@zanematthew
zanematthew / gist:1268641
Created October 6, 2011 20:51
Sample class
class CustomPostType extends CustomPostTypeBase {
/**
* Every thing that is "custom" to our CPT goes here.
*/
public function __construct() {
$this->dependencies['script'] = array(
'jquery',
'jquery-ui-core',
@zanematthew
zanematthew / gitconfig user and email
Created December 9, 2011 15:35
Syntax for adding your name and email to a gitconfig
[user]
name = Zane M. Kolnik
email = zanematthew@gmail.com