Skip to content

Instantly share code, notes, and snippets.

@jdcauley
jdcauley / main.js
Created March 31, 2016 16:31
bootstrap affix for widgets
var StickyWidget = $('.sidebar .widget:last-child');
if(StickyWidget){
var trigger = StickyWidget.offset().top - $('#primary-masthead').height();
StickyWidget.affix({
offset: {
top: function(){
return trigger;
},
bottom: function () {
@jdcauley
jdcauley / functions.php
Created March 31, 2016 16:27
widget form supplement
add_action( 'in_widget_form', 'in_widget_form', 20, 3 );
add_filter( 'widget_update_callback', 'widget_update_callback', 20 , 4 );
add_filter( 'widget_display_callback', 'widget_display_callback', 20, 3 );
function in_widget_form( &$widget, &$return, $instance ){
// $instance['nav_widget_is_sticky'] = 1;
?>
<p>
<label>
@jdcauley
jdcauley / index.js
Last active February 22, 2016 21:06
Gist for use with Hook.io
module['exports'] = function simpleHttpRequest (hook) {
// npm modules available, see: http://hook.io/modules
var request = require('request');
var options = {
uri: 'https://www.ourstate.com/?callback=gravityformsstripe',
method: 'POST',
json: hook.params
};
request(options, function (err, response, body) {
@jdcauley
jdcauley / gated-modal.php
Created February 17, 2016 20:01
conditional for modal
if( (is_single() || is_archive() || is_home() || is_page('business-resources') ) &! ( (get_post_type() == 'application') || (get_post_type() == 'confirmation') || (get_post_type() == 'testimonial') || (get_post_type() == 'hero') || (get_post_type() == 'landing') ) )
function get_menu_posts(){
if($data = get_transient('menu_posts')){
return $data;
} else {
$menu_posts = new stdClass;
$categories = array(57,56,55,1734,20,21,23,1716,1717,39,1718);
foreach($categories as $category){
$cat_info = get_category($category);
$posts = get_posts(array(
'posts_per_page' => 4,
@jdcauley
jdcauley / functions.php
Created February 5, 2016 19:54
ordering term checkboxes
function get_api_terms($term_id){
$posts = get_posts(array(
'post_type' => 'offer',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'offer_category',
'field' => 'term_id',
'terms' => $term_id,
@jdcauley
jdcauley / gated-modal.php
Created February 1, 2016 19:34
options and menu
function gated_modal_add_admin_menu(){
add_options_page( 'Gated Modal', 'Gated Modal', 'manage_options', 'gated_modal', array($this, 'gated_modal_options_page') );
// add_submenu_page( 'edit.php', 'Gated Modal', 'Gated Modal', 'manage_options', 'gated_modal', array($this, 'gated_modal_options_page') );
add_submenu_page( 'content.php', 'Gated Modal', 'Gated Modal', 'manage_options', 'options-general.php?page=gated_modal', array( $this, 'gated_modal_options_page' ) );
}
jQuery(document).ready(function(e) {
function t(e) {
var t = document.getElementById(e);
if (t) {
for (var a = t.getElementsByTagName("li"), i = [], s = 0; s < a.length; s++) i.push({
country: a[s].textContent,
item: a[s]
});
i.sort(function(e, t) {
var a = e.country,
$post_types = get_post_types(array(
'public' => true,
), 'objects');
foreach($post_types as $key => $value){
$field_name = 'binary_stars_post_type_' . $key;
print_r($field_name);
add_settings_field(
$field_name,
__( 'Load Stars on ' . $value->labels->name, 'binary_stars' ),
function call_routes() {
add_action( 'rest_api_init', function () {
register_rest_route( 'census/v1', '/test/', array(
'methods' => 'GET',
'callback' => array($this, 'test_action')
) );
register_rest_route( 'census/v1', '/submit',