Skip to content

Instantly share code, notes, and snippets.

View jfitzsimmons2's full-sized avatar
🤖
Leveling

jfitzsimmons2

🤖
Leveling
View GitHub Profile
@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' ),
@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 / 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 / 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 / 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 / Preferences.sublime-settings
Last active August 29, 2015 14:10
Sublime Text Settings
{
"font_face": "Ubuntu Mono",
"font_options": "subpixel_antialias",
"font_size": 16,
"highlight_line":true,
"line_padding_bottom": 1,
"line_padding_top": 1,
"rulers":
[
80
@jfitzsimmons2
jfitzsimmons2 / oswego.make
Created March 14, 2015 18:34
Oswego Make File
; This file was auto-generated by drush make
core = 7.x
api = 2
; Core
projects[drupal][version] = "7.34"
; Modules
projects[views_bulk_operations][version] = "3.2"
@jfitzsimmons2
jfitzsimmons2 / cookie.js
Created April 4, 2015 14:21
Creating a cookie with javascript
/**
* Implements hook_theme_registry_alter().
*/
function MODULENAME_theme_registry_alter(&$theme_registry) {
// Defined path to the current module.
$module_path = drupal_get_path('module', 'MODULENAME') . '/templates';
// Find all .tpl.php files in this module's folder recursively.
$template_file_objects = drupal_find_theme_templates($theme_registry, '.tpl.php', $module_path);
// Iterate through all found template file objects.
foreach ($template_file_objects as $key => $template_file_object) {
<?php
/**
* Implements hook_theme_registry_alter().
*/
function MODULENAME_theme_registry_alter(&$theme_registry) {
// Defined path to the current module.
$module_path = drupal_get_path('module', 'MODULENAME');
$module_path .= '/templates';