Skip to content

Instantly share code, notes, and snippets.

@mattbanks
mattbanks / Gruntfile.js
Last active December 22, 2015 13:19
Grunt Setup with LESS
'use strict';
module.exports = function(grunt) {
// load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);
grunt.initConfig({
// watch for changes and trigger compass, jshint, uglify and livereload
watch: {
@mattbanks
mattbanks / Gruntfile.js
Created September 9, 2013 16:05
Grunt LiveReload issue - package.json and Gruntfile.js
'use strict';
module.exports = function(grunt) {
// load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);
grunt.initConfig({
// watch for changes and trigger compass, jshint, uglify and livereload
watch: {
@mattbanks
mattbanks / Vagrantfile
Created October 9, 2013 18:56
Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
config.vm.network :private_network, ip: "192.168.204.72"
config.ssh.forward_agent = true
config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 1024]
@mattbanks
mattbanks / gulpfile.js
Created February 4, 2014 20:18
Setup for using gulp in developing and deploying WordPress themes
// Load plugins
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')({ camelize: true }),
lr = require('tiny-lr'),
server = lr();
// Styles
gulp.task('styles', function() {
return gulp.src('assets/styles/source/*.scss')
.pipe(plugins.rubySass({ style: 'expanded', compass: true }))
@mattbanks
mattbanks / wp-setup.sh
Created March 14, 2014 18:01
Scaffold a new WordPress development site in Alfred, utilizing WP-CLI. Use this script to run as a Terminal Script. Customize for your theme needs, plugin needs, etc.
# Create directory for new site
cd ~/Sites
mkdir {query}
cd {query}
# Download latest version of WordPress
wp core download
# Setup wp-config file with WP_DEBUG enabled
wp core config --dbname={query} --dbuser=root --dbpass=root --dbprefix={query}wp_ --extra-php <<PHP
@mattbanks
mattbanks / taxonomy-query-loop.php
Created April 2, 2014 16:51
Loop through each taxonomy term, run a new WP_Query in each term
<?php
// Get terms
// http://codex.wordpress.org/Function_Reference/get_terms
// use $args array in second parameter if needed
$my_categories = get_terms( 'TERM_NAME_HERE' );
$my_categories_count = count( $my_categories );
if ( $my_categories_count > 0 && is_array( $my_categories ) ) {
echo '<div class="wrap">';
@mattbanks
mattbanks / functions.php
Last active August 29, 2015 13:59
Pre-WordPress 3.9 showing kitchen sink in WYSIWYG editor
<?php
add_filter( 'tiny_mce_before_init', 'mb_unhide_kitchensink' );
function mb_unhide_kitchensink( $args ) {
$args['wordpress_adv_hidden'] = false;
return $args;
}
@mattbanks
mattbanks / index.php
Created August 5, 2014 16:43
Awful loop usage in WordPress theme index.php
<?php global $wp_query;
query_posts(
array_merge(
$wp_query->query,
array(
'orderby' => 'post_date',
'order' => 'desc'
)
)
);
@mattbanks
mattbanks / gist:55c990b1d5b517ccf043
Created June 3, 2015 15:10
TextExpander 5 snippet for a new WP_Query wrapped in a transient
// Get any existing copy of our transient data
if ( false === ( $%filltext:name=Query Name:default=myquery% = get_transient( '%filltext:name=Query Name:default=myquery%' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$%filltext:name=Query Name:default=myquery%_args = array(
'post_type' => '%filltext:name=Post Type:default=post%',
'order' => '%fillpopup:name=Order:default=ASC:DESC%',
'orderby' => '%fillpopup:name=Orderby:default=date:ID:rand:title:author:menu_order%',
'post_status' => 'publish',
'posts_per_page' => %filltext:name=Posts Per Page:default=-1%
@mattbanks
mattbanks / 0_reuse_code.js
Created September 29, 2015 19:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console