Skip to content

Instantly share code, notes, and snippets.

View colegeissinger's full-sized avatar

Cole Geissinger colegeissinger

View GitHub Profile
@colegeissinger
colegeissinger / input.js
Created September 5, 2015 00:48
Fixing ACF Pro so the dreded "isArrayLike empty obj error" is avoided
acf.add_filter('validation_complete', function( json, $form ){
// Return early if there are no errors.
// This will avoid the dreded "isArrayLike empty obj error"
// https://github.com/jquery/jquery/issues/2242
if ( 0 === json.errors ) {
return json;
}
// show field error messages
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / wp_query.php
Last active January 4, 2016 13:39
A working WP_Query() script with pagination and some data validation for http://wordpress.org/support/topic/custom-post-type-pagination-problem
<div id="content">
<?php
$args = array(
'post_type' => 'recipes',
'paged' => ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1 ),
);
// It's generally a good idea to give a unique name for your new query, so I'll name this $recipes
$recipes = new WP_Query( $args );
?>