Skip to content

Instantly share code, notes, and snippets.

@WillBrubaker
WillBrubaker / force-site-layout.php
Last active January 1, 2016 12:39
Force a Site Layout - Genesis Framework
<?php
//do not include opening php tag
add_filter( 'genesis_site_layout', function() { return 'full-width-content'; } );
@WillBrubaker
WillBrubaker / genesis-grid-eq-height.js
Last active January 1, 2016 12:39
Equal Height Columns - specific to the genesis framework grid loop
jQuery(document).ready(function(){
var highestBox = 0;
$('.genesis-grid').each(function(){
if($(this).height() > highestBox)
highestBox = $(this).height();
});
$('.genesis-grid').height(highestBox);
});
@WillBrubaker
WillBrubaker / pre-commit
Created June 8, 2014 14:40
A pre-commit hook to minify css & js when committing to branch 'master'
#!/bin/sh
#
# A pre-commit hook to minify js & css files
# if committing to branch 'master'
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [ "$BRANCH" == 'master' ]
then
csspath='css/*.css'
jspath='js/*.js'
@WillBrubaker
WillBrubaker / auth-filter.php
Last active August 29, 2015 14:02
An authentication filter for your WordPress development environment
<?php
/**
* Filters 'authenticate'
* to keep user with id 1
* logged in without needing
* to enter l/p
*/
add_filter( 'authenticate', 'wwm_authenticate_filter', 10, 1 );
@WillBrubaker
WillBrubaker / pre-option.php
Last active March 27, 2023 23:12
An example of the use of the pre_option_ WordPress filter
<?php
add_action( 'pre_get_posts', 'wwm_pre_get_posts', 10, 0 );
function wwm_pre_get_posts() {
/**
* For this example, the plugin that would be altered is the 'featured video plus' plugin
* The task is to show the featured video on single pages, but not on archives
* apply the filter on singlular pages that aren't the admin interface.
*/
@WillBrubaker
WillBrubaker / custom-redirect.php
Last active August 29, 2015 14:03
An example of how to redirect after survey submission for the Awesome Surveys WordPress plugin. Requires Awesome Surveys version > 1.1.1
<?php
/*
Plugin Name: Custom Redirect for Awesome Surveys
Plugin URI: http://www.willthewebmechanic.com/awesome-surveys
Description: Redirects to a specified link after survey submission
Version: 1.0
Author: Will Brubaker
Author URI: http://www.willthewebmechanic.com
License: GPLv3.0
*/
@WillBrubaker
WillBrubaker / products_sold_snippet.php
Created August 6, 2014 15:33
A snippet of code demonstrating how to create a shortcode that will output a number of items sold - This is specific to woocommerce
<?php
/* Do not copy the opening <?php tag above */
//Add the shortcode tag with its callback function:
add_shortcode( 'display_tickets_sold', 'wwm_display_tickets_sold' );
/**
* Given a valid product id, Outputs a number of 'units sold'
* Usage [display_tickets_sold product_id="####"] where #### is a valid product id.
@WillBrubaker
WillBrubaker / messages_nl.js
Created August 21, 2014 12:44
Language file for the jquery validation plugin - edited to work with noconflict mode
/*
* Translated default messages for the jQuery validation plugin.
* Locale: NL (Dutch; Nederlands, Vlaams)
*/
jQuery.extend(jQuery.validator.messages, {
required: "Dit is een verplicht veld.",
remote: "Controleer dit veld.",
email: "Vul hier een geldig e-mailadres in.",
url: "Vul hier een geldige URL in.",
date: "Vul hier een geldige datum in.",
@WillBrubaker
WillBrubaker / snippet.php
Created August 21, 2014 12:46
Code snippet to load custom messages for jQuery validation plugin within the Awesome Surveys WordPress plugin
<?php
/*
Plugin Name: Code With WP Custom Snippets
Plugin URI: http://codewithwp.com/
Description: This plugin holds custom code snippets that interact with both themes and plugins related to this website.
Author: Thomas Griffin
Author URI: http://thomasgriffinmedia.com/
Version: 1.0.0
License: GNU General Public License v2.0 or later
License URI: http://www.opensource.org/licenses/gpl-license.php
@WillBrubaker
WillBrubaker / remove-woocommerce-submenu-items
Last active November 22, 2022 13:34
Remove WooCommerce submenu items for Shop Managers
<?php
/*
Don't copy the opening php tag
*/
/*
Removes submenu items from WooCommerce menu for 'Shop Managers'
available submenu slugs are:
wc-addons - the Add-ons submenu
wc-status - the System Status submenu