Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / mb_html5_doctype.php
Last active December 21, 2015 07:18
Adding Conditional Classes to the HTML Tag in Genesis 2.0
/**
* HTML5 DOCTYPE
* removes the default Genesis doctype, adds new html5 doctype with IE8 detection
*/
function mb_html5_doctype() {
?>
<!DOCTYPE html>
<!--[if IE 8]> <html class="lt-ie9" <?php language_attributes( 'html' ); ?>> <![endif]-->
<!--[if gt IE 8]><!--> <html <?php language_attributes( 'html' ); ?>> <!--<![endif]-->
@mattbanks
mattbanks / php-expires-headers.php
Created August 15, 2013 13:29
PHP no caching expires headers
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>