Skip to content

Instantly share code, notes, and snippets.

View colegeissinger's full-sized avatar

Cole Geissinger colegeissinger

View GitHub Profile
@colegeissinger
colegeissinger / query.php
Last active August 29, 2015 13:56
Query post types based on taxonomy
<?php
// The query variable
$queried_term = get_query_var( 'Clients' );
// Return the terms for current post based off the query variable. Make you sanitize your queries!!
$terms = wp_get_post_terms( absint( get_the_ID() ), 'Clients', array( 'fields' => 'all' ) );
// Start the arguments for WP_Query(). We'll define an empty tax_query
// so we hav something to dump our terms into programatically.
$args = array(
@colegeissinger
colegeissinger / widgetized-example.php
Created April 27, 2014 23:14
This code is to be used in your theme. First block is to go in your functions.php then the last block is to be set where you want the widgetized area to be displayed.
/**
* Register our sidebars and widgetized areas.
* Add this block to your functions.php
*
*/
function arphabet_widgets_init() {
register_sidebar( array(
'name' => 'Home right sidebar',
'id' => 'home_right_1', // Take note of the ID! We'll need this to call the right widgetized area in our theme
@colegeissinger
colegeissinger / functions.php
Created June 9, 2014 23:02
Add an image to your WordPress RSS feed
// Add to functions.php and namespace your methods! :)
function cg_rss_post_thumbnail( $content ) {
global $post;
if ( has_post_thumbnail( absint( $post->ID ) ) ) {
$content = '<p>' . get_the_post_thumbnail( asbint( $post->ID ) ) . '</p>' . get_the_content();
}
return $content;
}
@colegeissinger
colegeissinger / gist:868e1bda385a9ca4fa0e
Created June 13, 2014 23:49
Standard text domain setup
class My_Awesome_Plugin {
public function __construct() {
add_action( 'init', array( $this, 'setup_textdomain' ) );
}
public static function setup_textdomain() {
$locale = apply_filters( 'plugin_locale', get_locale(), $this->domain );
load_textdomain( $this->domain, WP_LANG_DIR . '/plugin-name/plugin-name-' . $locale . '.mo' );
load_plugin_textdomain( $this->domain, false, $this->plugin_dir . '/languages/' );
}
}
@colegeissinger
colegeissinger / validate_int.php
Last active August 29, 2015 14:04
Validate a string of numbers, even if they are in a list separated by commas
$list_of_ids = '1,2,3,4,5,6';
if ( cg_validate_int( $list_of_ids ) ) {
echo 'Huzzah! We have valide integers!';
}
/**
* Allows us to pass either an array of or a single intger and validate that they are integers
*
* @param int|string $list_of_ids Pass either a single integer or a comma separated list
*
@colegeissinger
colegeissinger / jquery.flexslider.min.js
Created October 16, 2014 17:13
FlexSlider v2.2.2 custom minified fixing last post showing first
/*
* jQuery FlexSlider v2.2.2
* Copyright 2012 WooThemes
* Contributing Author: Tyler Smith
*/
(function(e){e.flexslider=function(t,n){var r=e(t);r.vars=e.extend({},e.flexslider.defaults,n);var i=r.vars.namespace,s=window.navigator&&window.navigator.msPointerEnabled&&window.MSGesture,o=("ontouchstart"in window||s||window.DocumentTouch&&document instanceof DocumentTouch)&&r.vars.touch,u="click touchend MSPointerUp keyup",a="",f,l=r.vars.direction==="vertical",c=r.vars.reverse,h=r.vars.itemWidth>0,p=r.vars.animation==="fade",d=r.vars.asNavFor!=="",v={},m=true;e.data(t,"flexslider",r);v={init:function(){r.animating=false;r.currentSlide=parseInt(r.vars.startAt?r.vars.startAt:0,10);if(isNaN(r.currentSlide))r.currentSlide=0;r.animatingTo=r.currentSlide;r.atEnd=r.currentSlide===0||r.currentSlide===r.last;r.containerSelector=r.vars.selector.substr(0,r.vars.selector.search(" "));r.slides=e(r.vars.selector,r);r.container=e(r.containerSelector,r);r.count=r.slides.length;r.syncExists=e(r.vars.sync).length>0;if(r.vars
@colegeissinger
colegeissinger / wp-config.php
Created October 29, 2014 19:07
WordPress Dev configurations
<?php
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* Add this above "That's all, stop editing! Happy blogging."
*/
@colegeissinger
colegeissinger / functions.php
Created September 5, 2015 00:05
Revert jQuery back a version so ACF works in WordPress 4.3
function cg_revert_jquery_version_admin() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
add_action( 'admin_enqueue_scripts', 'cg_revert_jquery_version_admin' );
@colegeissinger
colegeissinger / Fancy CSS3 Box Shadows with SCSS
Created February 7, 2013 09:03
Fancy CSS3 Box Shadows with SCSS. Requires SASS and Compass to be installed.
// Import some requiredness from compass
@import "compass/reset";
@import "compass/css3/box-shadow";
@import "compass/css3/transform";
// Define our mixin
@mixin fancy-box-shadow($color:rgba(0,0,0,.5), $left_shadow:-4deg, $right_shadow:4deg, $bottom:8px) {
position:relative;
background:#fff;
a:5:{i:0;O:8:"stdClass":5:{s:5:"title";s:50:"Install the standpipe and underground drain pipe.";s:5:"lines";a:2:{i:0;O:8:"stdClass":4:{s:4:"text";s:408:"My design uses a 2&quot; ABS standpipe that runs down from the washer and connects to a gently sloping horizontal pipe buried under a garden path. At the other end, the water splits and travels a bit farther in 2 directions, then flows out through perforated pots and bark chip mulch, and into the soil beneath some water-loving plants and trees. The area to be watered was 40' away and 10' below the washer.";s:8:"text_raw";s:403:"My design uses a 2" ABS standpipe that runs down from the washer and connects to a gently sloping horizontal pipe buried under a garden path. At the other end, the water splits and travels a bit farther in 2 directions, then flows out through perforated pots and bark chip mulch, and into the soil beneath some water-loving plants and trees. The area to be watered was 40' away and 10' below the washer.";s:6:"bullet";s:5:"black";s:5:"lev