Skip to content

Instantly share code, notes, and snippets.

View michaelvandenberg's full-sized avatar
🏠
Working from home

Michael van den Berg michaelvandenberg

🏠
Working from home
View GitHub Profile
/**
* Turn a multi-dimensional array in to a simple flat array.
*
* @link http://stackoverflow.com/a/14972714/4429450
*/
function array_flatten($array) {
$return = array();
foreach ($array as $key => $value) {
if (is_array($value)){ $return = array_merge($return, array_flatten($value));}
else {$return[$key] = $value;}
@michaelvandenberg
michaelvandenberg / genius_add_search_toggle.php
Created February 3, 2016 15:36
Add a search toggle after the regular menu items.
function genius_add_search_toggle ( $items, $args ) {
if ( $args->theme_location == 'social') {
$items .= '<li id="search-toggle" class="menu-item"><a href="#"><span class="screen-reader-text">Search Toggle</span></a></li>';
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'genius_add_search_toggle', 10, 2 );
@michaelvandenberg
michaelvandenberg / detect-scroll.js
Last active December 7, 2015 18:12
Detect scroll distance from top and/or bottom and scroll up and down.
/**
* Detect Scroll.
*
* Detect scroll distance from top and/or bottom and scroll up and down.
*/
( function( $ ) {
var lastScrollTop = 0, delta = 20;
$(window).scroll(function(){