Skip to content

Instantly share code, notes, and snippets.

View Losgard's full-sized avatar

Patrik Losgard Losgard

View GitHub Profile
@Losgard
Losgard / functions-01.php
Created September 23, 2015 22:08 — forked from robincornett/functions-01.php
Responsive menus for HTML5 Genesis themes. with updating skip links. The skip links must follow the pattern established in Genesis core.
<?php
//do not include the opening tag!
// Required Scripts and Styles
add_action( 'wp_enqueue_scripts', 'leaven_load_scripts', 15 );
function leaven_load_scripts() {
// Responsive Navigation
wp_enqueue_style( 'fontawesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css', array(), '4.3.0' );
@Losgard
Losgard / style.css
Last active August 29, 2015 14:25 — forked from cjkoepke/style.css
Animation CSS for the Off Canvas Menu.
/*
Title: How to Add a Mobile-Friendly, Off Canvas Menu in Genesis
Author: Calvin Makes (@calvin_makes)
Link: http://www.calvinmakes.com/add-a-mobile-friendly-off-canvas-menu-in-genesis
*/
/* ## Animation Settings and Classes
--------------------------------------------- */
.off-canvas-active {
@Losgard
Losgard / style.css
Last active August 29, 2015 14:25 — forked from cjkoepke/style.css
Styling for a vertical navigation that is fixed and full-height.
/*
Title: How to Add a Mobile-Friendly, Off Canvas Menu in Genesis
Author: Calvin Makes (@calvin_makes)
Link: http://www.calvinmakes.com/add-a-mobile-friendly-off-canvas-menu-in-genesis
*/
/* ## Genesis Navigation Menu
--------------------------------------------- */
.genesis-nav-menu {
@Losgard
Losgard / functions.php
Last active August 29, 2015 14:25 — forked from cjkoepke/functions.php
Add JavaScript file to our body.
<?php
//* Do NOT include the opening PHP tag
/**
* Include the JavaScript
* @author Calvin Makes (@calvin_makes)
* @link http://www.calvinmakes.com/add-a-mobile-friendly-off-canvas-menu-in-genesis
*/
add_action( 'wp_enqueue_scripts', 'cm_load_menu' );
function cm_load_menu() {
@Losgard
Losgard / offcanvas-nav.js
Last active August 29, 2015 14:25 — forked from cjkoepke/offcanvas-nav.js
Add a listener to the designated triggers for the Off Canvas Menu, and run a function depending on the state.
jQuery( document ).ready(function( $ ) {
// Variables
var open = false, // Set the state of the menu on load (false = closed)
body = $('body'),
siteContainer = $('.site-container'),
toggleButtons = $('.menu-btn, .close-btn, .site-overlay'); // Trigger buttons
// Function to open the menu
function openMenu() {
@Losgard
Losgard / functions.php
Last active August 29, 2015 14:25 — forked from cjkoepke/functions.php
Add a blank overlay div to the DOM for clicking.
<?php
//* Do NOT include the opening PHP tag
/**
* Add the overlay div that will be used for clicking out of the active menu.
* @author Calvin Makes (@calvin_makes)
* @link http://www.calvinmakes.com/add-a-mobile-friendly-off-canvas-menu-in-genesis
*/
add_action( 'genesis_before', 'cm_site_overlay', 2 );
function cm_site_overlay() {
@Losgard
Losgard / functions.php
Last active August 29, 2015 14:25 — forked from cjkoepke/functions.php
Add a menu button to the Header, and a "Close Navigation" menu to the Primary Navigation
<?php
//* Do NOT include the opening PHP tag
/**
* Add the menu to the .site-header, but hooking right before the genesis_header_markup_close action.
* @author Calvin Makes (@calvin_makes)
* @link http://www.calvinmakes.com/add-a-mobile-friendly-off-canvas-menu-in-genesis
*/
add_action( 'genesis_header', 'cm_menu_button', 14 );
function cm_menu_button() {
@Losgard
Losgard / functions.php
Last active August 29, 2015 14:25 — forked from cjkoepke/functions.php
Reposition the Primary Navigation
<?php
//* Do NOT include the opening PHP tag
/**
* Reposition the Primary navigation at the top of the DOM.
* @author Calvin Makes
* @link http://www.calvinmakes.com/add-a-mobile-friendly-off-canvas-menu-in-genesis
*/
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_before', 'genesis_do_nav', 1 );
@Losgard
Losgard / structural-wraps.php
Last active August 29, 2015 14:25 — forked from studiopress/structural-wraps.php
Genesis structural wraps.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
'header',
'nav',
'subnav',
'site-inner',
'footer-widgets',
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Unregister primary sidebar
unregister_sidebar( 'sidebar' );