Skip to content

Instantly share code, notes, and snippets.

View chrismcintosh's full-sized avatar

Chris Mcintosh chrismcintosh

View GitHub Profile
@chrismcintosh
chrismcintosh / responsive-menu.js
Created July 15, 2016 15:16
Combine Primary and Secondary Menu's in Genesis in responsive view.
jQuery(function( $ ){
$("header .genesis-nav-menu, .nav-primary .genesis-nav-menu, .nav-secondary .genesis-nav-menu").addClass("responsive-menu").before('<div class="responsive-menu-icon"></div>');
$(".responsive-menu-icon").click(function(){
$(this).next("header .genesis-nav-menu, .nav-primary .genesis-nav-menu, .nav-secondary .genesis-nav-menu").slideToggle();
});
$(window).resize(function(){
if(window.innerWidth > 767) {
setupMenus();
$( window ).resize( function() {
setupMenus();
});
function setupMenus () {
if ( window.innerWidth <= 768 ) {
$( 'ul.menu-secondary > li' ).addClass('moved-item'); //tag moved items so we can move them back
//Call The Package Dependencies
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var plumber = require('gulp-plumber');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var beep = require('beepbeep');
@chrismcintosh
chrismcintosh / independant-off-canvas-size
Created December 6, 2016 17:15
If you would like to set each off-canvas area separately you can use the below code as a model for modify a single off-canvas area
/* Set foundation 6 off canvas size independant of global settings*/
$offcanvas-right-size: 300px;
.is-open-right {
-webkit-transform: translateX(-$offcanvas-right-size);
-ms-transform: translateX(-$offcanvas-right-size);
transform: translateX(-$offcanvas-right-size);
}
jQuery(document).ready(function ($) {
//On load run the function defined below
slickActionsScreenSize();
//Run the function on window resize
jQuery( window ).resize( function() {
slickActionsScreenSize();
});
@chrismcintosh
chrismcintosh / acf_populate_custom_tax.php
Last active April 30, 2017 15:59
Some boilerplate code for populating an ACF select box with custom taxonomies and then querying a custom post type using the result of that select box.
<?php
/*
Assumes a custom post type called 'staff'
Assumes that there is a custom taxonomy called 'department'.
Every department that has at least one staff member assigned to it will
populate a select field that is specified in Advanced Custom Fields.
Using that Select field we can then do a query on a custom post type
in this case staff and grab only the staff with our selected department.
<?php
// Define ACF component markup
function sby_display_flexible_content() {
// loop through the rows of data
while ( have_rows('flexible_content') ) : the_row();
// List Components for ACF Page Builder
if( get_row_layout() == 'department_intro' ) {
include get_stylesheet_directory() . '/lib/acf/flexible-components/department-intro.php';
} elseif( get_row_layout() == 'featured_actions' ) {
include get_stylesheet_directory() . '/lib/acf/flexible-components/featured-actions.php';
<?php
$image = get_sub_field('background_image');
if( !empty($image) ):
// thumbnail
$size = 'large';
$thumb = $image['sizes'][ $size ];
endif;
<?php
add_action('genesis_setup', 'residence_post_meta_setup');
function residence_post_meta_setup() {
/* Set the post type */
add_action( 'pre_get_posts', 'set_residence_post_meta' );
function set_residence_post_meta( $query ) {
$query->set( 'post_type', 'residence');
$query->set( 'posts_per_page', -1 );
}
@chrismcintosh
chrismcintosh / pmp_pro_echo_body_class.php
Last active December 28, 2017 20:45
If you need to target specific elements with css based on membership level in paid memberships pro here's a snippet.
<?php
/* Dont Include This Comment or the opening <?php tag */
/*************************************
*
* Add a body class correlating to the users
* memberhsip level in Paid Memberships Pro
* looks like - 'member-level-1'
*
**************************************/