Skip to content

Instantly share code, notes, and snippets.

View BruceMcKinnon's full-sized avatar

BruceMcKinnon

View GitHub Profile
@BruceMcKinnon
BruceMcKinnon / gist:d74210f4b2dc5089c50218e223d81cb7
Created December 13, 2017 23:56
FoundationPress Hamburger Nav on all screen sizes
Here is a simple receipt to enable the hamburger menu on all screen sizes of a FoundationPress-based Wordpress theme.
Step 1: Add a huge breakpoint to _settings.scss
$breakpoints: (
small: 0,
medium: 640px,
large: 1024px,
xlarge: 1200px,
xxlarge: 1440px,
@BruceMcKinnon
BruceMcKinnon / gist:57838d7b9dbbb6f110173f65801d28c1
Created December 27, 2017 21:23
Smooth Anchor Nav Scrolling
// Smooth anchor nav scrolling
// Handle links with @href started with '#' only
$(document).on('click', 'a[href^="#"]', function(e) {
// target element id
var id = $(this).attr('href');
// target element
var $id = $(id);
if ($id.length === 0) {
@BruceMcKinnon
BruceMcKinnon / functions.php
Last active March 20, 2018 00:22
Gravity Form Australian Phone Number Filtering
add_filter( 'gform_phone_formats', 'au_phone_format' );
function au_phone_format( $phone_formats ) {
$phone_formats['au'] = array(
'label' => 'Australia',
'mask' => false,
'regex' => '/^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$/',
'instruction' => false,
);
return $phone_formats;
@BruceMcKinnon
BruceMcKinnon / functions.php
Created March 20, 2018 22:03
Foundation Desktop Nav Open Right
if ( ! function_exists( 'foundationpress_top_bar_r' ) ) {
function foundationpress_top_bar_r() {
wp_nav_menu( array(
'container' => false,
'menu_class' => 'dropdown menu',
'items_wrap' => '<ul id="%1$s" class="%2$s desktop-menu" data-dropdown-menu data-alignment="left">%3$s</ul>',
'theme_location' => 'top-bar-r',
'depth' => 3,
'fallback_cb' => false,
'walker' => new Foundationpress_Top_Bar_Walker(),
@BruceMcKinnon
BruceMcKinnon / gform-sections-accordion.js
Last active January 7, 2025 11:18
Collapsible Gravity Form Sections
/*
This JS creates collapsible Gravity Form sections breaks
IMPORTANT:
1 - Within the Gravity form, you must add the class collapsible to each section break.
2 - All fields within those section breaks must have the class collapsible_field
3 - You must include both the CSS and the JS
@mixin flex-container {
display: flex;
align-items: center;
justify-content: center;
}
@mixin flex-item-top {
align-items: flex-start;
align-self: flex-start;
}
.grid-x > .xlarge-8 {
@include breakpoint(xlarge) {
width: 66.66667%;
}
}
.xlarge-offset-1 {
@include breakpoint(xlarge) {
margin-left: 8.33333%;
}
@BruceMcKinnon
BruceMcKinnon / gist:5fcd3139d8444c55b3c880a5ea05435e
Created November 14, 2018 22:13
Foundation Larger Table Breakpoints
//
//
// Custom breakpoint for larger tablets
//
//
$breakpoints: (
small: 0,
medium: 640px,
tablet: 860px,
@BruceMcKinnon
BruceMcKinnon / functions.php
Last active September 9, 2022 03:54
Gravity Forms Australian phone number validation mask
add_filter( 'gform_phone_formats', 'au_phone_format' );
function au_phone_format( $phone_formats ) {
$phone_formats['au'] = array(
'label' => 'Australia',
'mask' => '99 9999 9999',
'regex' => '/^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{2}(\ |-){0,1}[0-9]{1}(\ |-){0,1}[0-9]{3}$/',
'instruction' => 'Australian phone numbers.',
);
return $phone_formats;
@BruceMcKinnon
BruceMcKinnon / functions.php
Created January 8, 2019 23:48
Woocommerce Repleace Read More with Out of Stock
//
// WooCommerce - replace read more buttons for out of stock items
//
if (!function_exists('woocommerce_template_loop_add_to_cart')) {
function woocommerce_template_loop_add_to_cart() {
global $product;
if ( !$product->is_in_stock() ) {
echo '<a href="'.get_permalink().'" rel="nofollow" class="outofstock button">Out of Stock</a>';
} else {
woocommerce_get_template('loop/add-to-cart.php');