Skip to content

Instantly share code, notes, and snippets.

(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
@fitzhaile
fitzhaile / svg-png-fallback.js
Created March 26, 2013 22:17
Modernizr PNG SVG Fallback
if(!Modernizr.svg){
$("img.svg").each(function(){
var src = this.src.replace('.svg', '.png');
this.src = src;
});
}
@fitzhaile
fitzhaile / script.rb
Created June 5, 2013 19:29
Base 64 encode Sass script
# Additional SASS Script functions
require 'sass'
require 'base64'
module Sass::Script::Functions
def base64encode(string)
assert_type string, :String
file = "."+string.value
data = File.open(file, "rb") {|io| io.read}
data = [data].flatten.pack("m").gsub("\n","")
@fitzhaile
fitzhaile / enable_tags.php
Last active December 20, 2015 00:19
WP: Enable Page tags
<?php
// Include the following in functions.php
//-------------------------------------------
// add tag support to pages
function tags_support_all() {
register_taxonomy_for_object_type('post_tag', 'page');
}
// ensure all tags are included in queries
@fitzhaile
fitzhaile / tiny-mce.php
Created November 15, 2013 16:39
Config for Tiny MCE in Wordpress.
<?php
/**
* Add custom styles to the styleselect dropdown
*
* @since required+ Foundation 0.5.0
*
* @param array $settings
* @return array
*/
@fitzhaile
fitzhaile / config.php
Created December 28, 2013 17:58
Fix media directory location to be outside of wordpress root.
<?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' ) );
}
@fitzhaile
fitzhaile / capistrano_wordpress_db_push_pull.rb
Created March 20, 2014 21:23
Push / Pull Wordpress Databases to / from remote and dev environments
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 / getSassyJSON.js
Created April 5, 2014 18:20
Get JSON from Sass output
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;
}
<?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 / wordpress-varnish3.vcl
Last active January 23, 2023 02:34
Varnish VCL for WP and W3 Total Cache
# 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";