Skip to content

Instantly share code, notes, and snippets.

@jdcauley
jdcauley / fields.php
Created December 5, 2016 15:32
Shared fields
function sponsor_fields(){
$sponsor_id = '';
if( isset( $_GET['post'] ) ){
$sponsor_id = get_post_meta( $_GET['post'], '_os_sponsor_id', true );
} else if( isset( $_GET['taxonomy'] ) ){
$sponsor_id = get_term_meta( $_GET['tag_ID'], '_os_sponsor_id', true );
} else {
return;
@jdcauley
jdcauley / array.js
Created September 28, 2016 18:56
what the crap
driverInputs.each(function(i){
var data = $(this).getParams();
app.data.drivers.push(data);
if(!app.saved['drivers']){
app.saved['drivers'] = [];
}
var newCopy = app.model.driver.slice(0);
console.log(newCopy);
@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){