Skip to content

Instantly share code, notes, and snippets.

@mattjstrauss
mattjstrauss / HTML, CSS, JS: Mobile Menu
Last active August 29, 2015 14:19
HTML, CSS, JS: Mobile Menu
// HTML
<a href="#" class="menu-trigger">
<span class="visuallyhidden">Menu</span>
<span class="lines"></span>
</a>
// CSS
.menu-trigger {
@mattjstrauss
mattjstrauss / WP: Custom Tiny MCE
Last active August 29, 2015 14:11
Adds formats to Tiny MCE in the backend of Wordpress
/*--------------------------------------------------------------
Callback function to filter the MCE settings
--------------------------------------------------------------*/
function wpb_mce_buttons_2($buttons) {
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'wpb_mce_buttons_2');
function my_mce_before_init_insert_formats( $init_array ) {
@mattjstrauss
mattjstrauss / WP: ACF styles and scripts function
Last active August 29, 2015 14:11
How to apply ACF styles and scripts within the functions file
/*--------------------------------------------------------------
ACF styles and scripts
--------------------------------------------------------------*/
function my_acf_admin_head()
{
?>
<style type="text/css">
/* ..styles.. */
@mattjstrauss
mattjstrauss / WP: Admin trigger DOM
Last active August 29, 2015 14:09
DOM for the Wordpress admin trigger
<?php if ( is_user_logged_in() ) { ?>
<span id="adminTrigger">
<a href="#">Toggle</a>
</span>
<?php } ?>
@mattjstrauss
mattjstrauss / gist:d6177e98abb89b17f1a4
Created November 19, 2014 16:45
WP: Admin bar toggle JS
// WP Admin Bar
$wpNav = $('#wpadminbar');
$wpNav.addClass('hide');
$('#adminTrigger').on('click', function(){
$(this).toggleClass('down');
$wpNav.toggleClass('hide show');
});
@mattjstrauss
mattjstrauss / gist:32b0cfb1f35c545b99d4
Created November 19, 2014 16:45
WP: Admin hide and show CSS
// WP admin hide and show
#wpadminbar {
@include transition(all, .4s, ease);
}
#wpadminbar.hide, #post-nav.hide {
@include translate(0, -90px);
@include transition(all, .4s, ease);
}
#adminTrigger {
@mattjstrauss
mattjstrauss / gist:4147d3f50829f433a886
Created November 19, 2014 16:41
WP: Removes admin bar margin-top
/*--------------------------------------------------------------
Removes admin margin-top
--------------------------------------------------------------*/
add_action('get_header', 'my_filter_head');
function my_filter_head() {
remove_action('wp_head', '_admin_bar_bump_cb');
}
@mattjstrauss
mattjstrauss / gist:3041842de88694be9071
Created November 19, 2014 15:08
JS: Base plugins including Modernizr and Respond.js
/*! Respond.js v1.4.2: min/max-width media query polyfill
* Copyright 2014 Scott Jehl
* Licensed under MIT
* http://j.mp/respondjs */
!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='&shy;<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.s
@mattjstrauss
mattjstrauss / gist:42373a0ea1b5d1f0dfcc
Last active August 29, 2015 14:09
JS: Animation and Transition callback with Modernizr
// Animation callback
var animEndEventNames = {
'WebkitAnimation' : 'webkitAnimationEnd',// Saf 6, Android Browser
'MozAnimation' : 'animationend', // only for FF < 15
'animation' : 'animationend' // IE10, Opera, Chrome, FF 15+, Saf 7+
},
animEndEventName = animEndEventNames[ Modernizr.prefixed('animation') ];
// Transition callback
var transEndEventNames = {
@mattjstrauss
mattjstrauss / gist:715304be15e4fef1d246
Created November 19, 2014 15:00
JS: Hover function
// Hover functions
$('.class-name').on({
mouseenter: function () {
},
mouseleave: function () {
}