Skip to content

Instantly share code, notes, and snippets.

View jfitzsimmons2's full-sized avatar
🤖
Leveling

jfitzsimmons2

🤖
Leveling
View GitHub Profile
@jfitzsimmons2
jfitzsimmons2 / viewport.js
Last active August 29, 2015 14:05
Accurately returns the height and width of the viewport much more reliably than $(window).height
/*
* Accurately returns the height and width of the viewport
* much more reliably than simply $(window).height
*
* Source: http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript
*/
function viewport() {
var e = window, a = 'inner';
@jfitzsimmons2
jfitzsimmons2 / wp-config.php
Last active October 21, 2015 13:53
My boilerplate wp-config.php file for working locally with WordPress
<?php
if ( file_exists( dirname( __FILE__ ) . '/wp-local-config.php' ) ) {
include( dirname( __FILE__ ) . '/wp-local-config.php' );
define( 'WP_LOCAL_DEV', true ); // We'll talk about this later
} else {
define('DB_NAME', 'database_name_here');
define('DB_USER', 'username_here');
define('DB_PASSWORD', 'password_here');
define('DB_HOST', 'localhost');
@jfitzsimmons2
jfitzsimmons2 / gruntfile.js
Last active August 29, 2015 14:01
Example grunt setup
'use strict';
module.exports = function(grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
// watch for changes and trigger compass, jshint, uglify and livereload
watch: {
@jfitzsimmons2
jfitzsimmons2 / Wordpress Bootstrap 3 nav.php
Last active November 10, 2017 15:01
How to structure your WP <nav> tag using wp_nav_menu to use Bootstrap 3's navbar. Note this is specifically for the "fixed top" version of the navbar (http://getbootstrap.com/components/#navbar-fixed-top). Also only works for single-level navs. If there are sub-menus, additional tweaking is needed.
<nav id="site-navigation" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><?php bloginfo( 'name' ); ?></a>
@jfitzsimmons2
jfitzsimmons2 / CPT.php
Last active January 18, 2016 12:03
A Sublime Text snippet that expands into a function that will register a custom post type in WordPress. CPT + Tab will generate the code.$1 = lowercase forms of the CPT name$2 = uppercase forms of the CPT name
<snippet>
<content><![CDATA[
<?php
add_action( 'init', 'register_cpt_$1' );
function register_cpt_$1() {
$labels = array(
'name' => _x( '$2s', '$1' ),