Skip to content

Instantly share code, notes, and snippets.

@salcode
salcode / why-not-preprocess-comment-for-empty-comment.md
Created June 9, 2016 10:32
Why you can't use the `preprocess_comment` filter on an empty comment.
@salcode
salcode / only-display-post-info-on-posts.php
Created March 31, 2016 19:33
WordPress mu-plugin for Genesis to only display post info when the post type is "post". This applies to the single template, archive, and search results page.
<?php
/**
* Genesis: Only display post info when post type is "post"
*/
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
add_action( 'genesis_entry_header', 'fe_genesis_post_info', 12 );
function fe_genesis_post_info() {
if ( 'post' === get_post_type() ) {
genesis_post_info();
@salcode
salcode / wp-title-like-where.php
Created March 31, 2016 15:50
WordPress mu-plugin to add support for "title_like" in WP_Query to add a LIKE WHERE clause to a query.
<?php
/**
* Example usage to find all Titles with a comma:
* $example_query = new WP_Query(
* array(
* 'title_like' => ','
* )
* );
*/
<?php
/*********************************************
Contests CPT
**********************************************/
/* Contest CPT :: Initiate CPT
**********************************************/
function vs_register_contests_post_type() {
@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]
@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 / 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 / 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 / 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 / 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."