Skip to content

Instantly share code, notes, and snippets.

@jdcauley
jdcauley / trk.js
Last active September 21, 2016 17:26
Trk
(function($, Cookies, undefined){
var dateObj = new Date(),
month = dateObj.getUTCMonth() + 1,
day = dateObj.getUTCDate(),
year = dateObj.getUTCFullYear(),
currentDate = year + "" + month + "" + day,
currentSession = {},
trimData = {},
visits = localStorage.getItem("foVisit");
<?php
/*
Plugin Name: MINC
*/
require_once('lib/CMB2/init.php');
class MINC_Fields {
@jdcauley
jdcauley / app.js
Created June 8, 2016 18:13
cardinal-ajax
var request = $.ajax({
url: cardinal.apiURL + cardinal.namespace + '/campaign/',
cache: false,
crossDomain: true,
method: "GET",
dataType: "json"
});
request.done(function( response ) {
cardinal.data = response;
unpack_form($post_id){
$data = get_field('membership_registration_form', $post_id);
print_r('<pre>');
print_r($data);
print_r('<pre>');
}
function is_even($number) {
$isEven = false;
if (is_numeric ($number)) {
if ( $number % 2 == 0) $isEven = true;
}
return $isEven;
}
@jdcauley
jdcauley / functions.php
Created May 10, 2016 19:01
functions.php
function admin_scripts($hook) {
if ( 'post.php' != $hook ) {
return;
}
wp_enqueue_style('os/admin_style', get_template_directory_uri() . '/assets/admin/main.css', false, null);
wp_enqueue_script( 'os/admin_script', get_template_directory_uri() . '/assets/admin/main.js');
}
add_action( 'admin_enqueue_scripts', 'admin_scripts');
@jdcauley
jdcauley / assets.php
Last active May 4, 2016 15:47
assets
<?php
namespace Roots\Sage\Assets;
/**
* Scripts and stylesheets
*
* Enqueue stylesheets in the following order:
* 1. /theme/dist/styles/main.css
*
@jdcauley
jdcauley / main.js
Created April 28, 2016 17:36
turn Selectboxes into bootstrap btn dropdown
(function ($, undefined) {
$.fn.gfSelect = function () {
var Selects = this;
Selects.each(function(i){
var GFSelect = $(this),
btnHtml = '<div class="btn-group">';
btnHtml += '<button type="button" class="btn btn-default btn-gf-select dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Select One <span class="caret"></span></button>';
btnHtml += '<ul class="dropdown-menu">';
$(this).find('option').each(function(j){
@jdcauley
jdcauley / matchbox.jquery.js
Last active April 26, 2016 20:26
MatchBox.js
(function ($, undefined) {
$.fn.matchBox = function () {
var Boxes = this,
tallest = 0,
height;
Boxes.each(function(i){
height = $(this).height();
if(height > tallest){
tallest = height;
}
add_filter( 'post_type_link', function($post_link, $id = 0){
$post = get_post($id);
if ( is_object( $post ) ){
$terms = wp_get_object_terms( $post->ID, 'offer_category' );
if( $terms ){
return str_replace( '%offer_category%' , $terms[0]->slug , $post_link );
}
}
return $post_link;