Skip to content

Instantly share code, notes, and snippets.

@salcode
salcode / original-filename
Created July 21, 2015 14:17
Redirect with the meta Refresh tag. This file was useful to me when redirecting an Amazon S3 file where the bucket was not setup to act as a website.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Refresh" content="0; URL=http://www.example.com/target/">
<title>Redirect</title>
</head>
<body>
<a href="http://www.example.com/target/">http://www.example.com/target/</a>
@salcode
salcode / bsg-customizer-navbar-logo.php
Created August 6, 2015 20:46
Bootstrap Genesis - add the logo in the nav to the customizer. This file can be dropped into the wp-content/mu-plugins/ directory (note: you may need to create the mu-plugins folder within wp-content if it does not already exist)
<?php
// add customizer controls
add_action( 'customize_register', 'bsg_navbar_brand_logo_customize_register' );
function bsg_navbar_brand_logo_customize_register( $wp_customize ) {
$wp_customize->add_setting( 'brand_logo',
array(
'default' => '',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
@salcode
salcode / wp-overlay-dev.php
Last active June 27, 2016 18:05
WordPress code to overlay an image on the webpage I'm working on. This should only be used on a development site. This can be used as an mu-plugin
<?php
/*
* Plugin Name: Overlay Dev
* Description: Overlay an image on the website to assist with development. Please add overlay-dev.png to the same directory as this file. This works as an mu-plugin.
* Version: 1.0.0
* Author: Sal Ferrarello
* Author URI: http://salferrarello.com/
*
* This file can be copied from the gist with
* curl -O https://gist.githubusercontent.com/salcode/f286c301663edad4e4a3/raw/wp-overlay-dev.php
@salcode
salcode / remove-header-right-widget-area.php
Created August 26, 2015 19:55
Genesis remove Header Right Widget Area (a.k.a. sidebar)
<?php
unregister_sidebar( 'header-right' );
remove_action( 'genesis_header', 'genesis_do_header' );
@salcode
salcode / bash-script-git.sh
Created September 5, 2015 19:54
Notes for bash scripting git commands
# Current branch - Determine current git branch, store in $currentbranch, and exit if not on a branch
if ! currentbranch=$(git symbolic-ref --short -q HEAD)
then
echo We are not currently on a branch.
exit 1
fi
# Uncommited Changes - Exit script if there uncommited changes
if ! git diff-index --quiet HEAD --; then
echo "There are uncommited changes on this repository."
@salcode
salcode / WooCommerce-custom-vs-global-attribute-slugs.md
Last active November 25, 2015 16:41
Clarification on custom versus global attribute slugs in WooCommerce

This page in the documentation, Using custom attributes in menus and taxonomy archives indicates

Custom attribute slugs are prefixed with ‘pa_’, so an attribute called ‘size’ would be ‘pa_size’

image

However, the behavior I appear to be seeing is global (i.e. taxonomy) based attributes are prefixed with pa_ and custom (i.e. local) attributes are not, which I believe is the opposite of what the documentation says.

For clarification, I'm referring to a custom (i.e. local) attribute as one I add to a specific product using the Custom Product Attribute Add button.

@salcode
salcode / shortcode_fe_constant_test.php
Last active December 8, 2015 15:55
Shortcode to output the value of a constant. e.g. [fe_constant_test constant="DB_HOST"]
<?php
/**
* Shortcode [fe_constant_test], which takes one parameter called "constant"
* This shortcode then outputs the value of that constant.
* I find this helpful when testing the value of constants with a complex
* constant assignment (e.g. using .env)
*
* Example usage: [fe_constant_test constant="DB_HOST"]
* outputs the following on my local development environment
* Constant DB_HOST is defined as "localhost"
@salcode
salcode / wordpress-oembed-cache-sql-notes.txt
Last active March 18, 2021 15:35
WordPress oEmbed Cache SQL
# List all oembed cached values
SELECT * FROM wp_postmeta WHERE meta_key LIKE '_oembed_%';
# Delete all oembed cached values
DELETE FROM wp_postmeta WHERE meta_key LIKE '_oembed_%';
# Delete all oembed cached values for Vimeo
SELECT * FROM wp_postmeta WHERE meta_key LIKE '_oembed_%' AND meta_value LIKE '%_player.vimeo.com/video_%'
@salcode
salcode / markdown-on-save-4-4-fix.php
Last active December 31, 2015 20:21
Fix for Mark Jaquith's "Markdown on Save" WordPress plugin on WordPress 4.4
<?php
/**
* Plugin Name: Markdown on Save 4.4. Fix
* Plugin URI: https://gist.github.com/salcode/b6b298a77f1c35cfce1c
* Description: Temporary fix for https://github.com/markjaquith/markdown-on-save/issues/13, which appears in WordPress 4.4 when running Markdown on Save 1.2.1
* Version: 1.0.0
* Author: Sal Ferrarello
* Author URI: http://salferrarello.com/
* Text Domain: markdown-on-save-4-4-fix
*
@salcode
salcode / phpswap.log
Created February 11, 2016 15:54
VVV phpswap 7.0.2 failure log
phpswap 7.0.2
===> Fetching release list...
[==================================================================] 2.69/2.69KB 100%
7.0: 4 releases
5.6: 19 releases
5.5: 33 releases
5.4: 46 releases
5.3: 2 releases
===> Done
PHP version 7.0.2 not installed. Building from source/installing... [this may take a few mintues]