Skip to content

Instantly share code, notes, and snippets.

Fitz Haile fitzhaile

Block or report user

Report or block fitzhaile

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fitzhaile
fitzhaile / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@fitzhaile
fitzhaile / woocommerce_variable_fields.php
Last active Aug 29, 2015 — forked from corsonr/gist:9152652
WooCommerce Custom Fields for Variations
View woocommerce_variable_fields.php
<?php
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'my_variable_fields', 10, 2 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'my_variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'my_save_variable_fields', 10, 1 );
/**
@fitzhaile
fitzhaile / bem-nav.php
Last active Apr 17, 2017
Alternative BEM-based lib/nav.php for Roots Theme
View bem-nav.php
<?php
/**
* Cleaner, BEM-based walker for wp_nav_menu()
*
* (Attempts to adhere more to http://cssguidelin.es.)
*
* NOTE: This apprroach requires substitute arguments to be passed to wp_nav_menu().
*
* 'nav_class' - Class attached to the <nav> element that contains the menu.
* It is used to generate classes for the ul, li and anchor elements. For example,
@fitzhaile
fitzhaile / custom_excerpt.php
Last active Mar 24, 2016
Custom excerpt options for Wordpress.
View custom_excerpt.php
<?php
/**
* A replacement for the default wp_trim_excerpt().
*
* Generates an excerpt from the_content, if needed.
*
* It is similar (identical) to the default to allow filters other than our own to work,
* with the exception that it uses our default my_trim_words() function.
*
@fitzhaile
fitzhaile / is_blog.php
Created Aug 28, 2014
An is_blog() conditional function for Wordpress.
View is_blog.php
<?php
/**
* An is_blog() conditional function for Wordpress.
*
* Determines if the current page is blog(y), including:
*
* - Posts page
* - Archive (category, tag, author)
* - Single post
@fitzhaile
fitzhaile / wordpress-varnish3.vcl
Last active Aug 1, 2017
Varnish VCL for WP and W3 Total Cache
View wordpress-varnish3.vcl
# This is a basic VCL configuration file for varnish. See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition. Set this to point to your content
# server.
#
#
# BACKEND
backend default {
.host = "127.0.0.1";
View delete_revisions.php
<?php
// Delete all revisions from all posts in either a network or a single blog.
// Quick hack by @mrazzari, 2014.
// For context see this thread started by Kitchin at the forums:
// http://wordpress.org/support/topic/deleting-post-revisions-do-not-use-the-abc-join-code-you-see-everywhere
// HOWTO
// This snippet is meant to be called as a standalone script.
// Like http://example.com/tmp/multisite_delete_revisions.php
@fitzhaile
fitzhaile / getSassyJSON.js
Created Apr 5, 2014
Get JSON from Sass output
View getSassyJSON.js
function getSassyJSON() {
var style = null;
var json = null;
// Get the json string from CSS
if ( window.getComputedStyle && window.getComputedStyle(document.body, '::before') ) {
style = window.getComputedStyle(document.body, '::before');
style = style.content;
}
@fitzhaile
fitzhaile / capistrano_wordpress_db_push_pull.rb
Created Mar 20, 2014
Push / Pull Wordpress Databases to / from remote and dev environments
View capistrano_wordpress_db_push_pull.rb
namespace :db do
desc "Pull (dump) the remote database and replace the local database with it"
task :pull do
on roles(:app) do
within release_path do
with path: "#{fetch(:path)}:$PATH" do
execute :mysqldump, "-u #{fetch(:wpdb)[fetch(:stage)][:user]} -p\"#{fetch(:wpdb)[fetch(:stage)][:password]}\" -h #{fetch(:wpdb)[fetch(:stage)][:host]} #{fetch(:wpdb)[fetch(:stage)][:name]} > #{fetch(:tmp_dir)}/database.sql"
download! "#{fetch(:tmp_dir)}/database.sql", "database.sql"
execute :rm, "#{fetch(:tmp_dir)}/database.sql"
end
@fitzhaile
fitzhaile / config.php
Created Dec 28, 2013
Fix media directory location to be outside of wordpress root.
View config.php
<?php
/**
* Fix media directory location to be outside of wordpress root
*/
if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) {
update_option( 'upload_path', untrailingslashit( str_replace( 'wp', 'media', ABSPATH ) ) );
update_option( 'upload_url_path', home_url( 'media' ) );
}
You can’t perform that action at this time.