Skip to content

Instantly share code, notes, and snippets.


Chris Van Patten chrisvanpatten

View GitHub Profile
chrisvanpatten /
Last active Jun 9, 2020
Super-simple way to grab a few Instagram images and cache them w/ WordPress

This is an easy way to integrate a basic Instagram feed into a WordPress site.


First, register with Instagram's developer program, then register a client. Set the client ID they provide you in line 4.

Second, get your Instagram user ID by running this in your terminal:

curl -X GET\?q\=USERNAME\&client_id\=CLIENT_ID
View panel.js
import { PluginPrePublishPanel } from '@wordpress/edit-post';
import { registerPlugin } from '@wordpress/plugins';
import Required from './required';
const Test = () => {
{ ( fills ) => fills.length > 0 ? fills : null ) }
chrisvanpatten / order_has_trial.php
Created Nov 18, 2015
Function to check if a WooCommerce order contains a free trial (via the Subscriptions extension)
View order_has_trial.php
* Loop through an order's items and see if there's a free trial set
* @param WC_Order $order
* @return bool|WP_Error
function custom_order_has_trial( $order ) {
if ( ! $order instanceof WC_Order )
View gist:7aa9fb17501bc154b71f8aa6ce15d089
{"skywordId":281474979915458,"type":"gallery","title":"Brendan Test 9\/17","author":"Author Byline Field","trackingTag":"true","publishAsDraft":false,"fields":[{"name":"seo_title","value":"Testing Revised Gallery - Feb 25th - Title Field","type":"META"},{"name":"toutImage","value":"84982","type":"IMAGE"},{"name":"toutImageCropOrientation","value":"Horizontal","type":"TAXONOMY"},{"name":"toutImageTitle","value":"Tout Image Title Field","type":"TEXT"},{"name":"toutImageCaption","value":"Tout Caption Field","type":"TEXT"},{"name":"toutImageAlt","value":"Tout Alternative Text Field","type":"TEXT"},{"name":"toutImageCredit","value":"Tout Credit Field","type":"TEXT"},{"name":"toutImageFocalPoint","value":"Tout Focal Point Field","type":"TEXT"},{"name":"toutImageRights","value":"restricted","type":"TAXONOMY"},{"name":"toutImageUsage","value":"Tout Image Rights Usage Field","type":"TEXT"},{"name":"socialTitle","value":"Social Title Field","type":"TEXT"},{"name":"socialDescription","value":"Social Description Field","
chrisvanpatten /
Created Mar 7, 2012
WordPress Admin Tabs


Believe it or not, WordPress doesn't have a fully-fleshed out common tab style for plugins or theme authors to use in metaboxes.

The style exists for categories, but it hasn't been fully adapted for the half-complete wp-tab setup. Trac ticket #17959 has a solution that not only fleshes the style but it also adds a global JavaScript file to give the wp-tab HTML some action. Until that ticket is accepted into core, this Gist adapts that code so it's available to use independently in your theme or plugin.


Just enqueue the CSS and JavaScript in the admin_enqueue_scripts script hook and drop the tab HTML in a metabox. It will automatically adapt to the normal and side column widths, much like category tabs.

View 47684.php
// Filter search endpoint responses.
add_filter( 'rest_post_dispatch', 'wp_47684_filter_response', 10, 3 );
* Resolves the behavior reported in WP Core Trac 47684.
* @see
# Usage:
# ./ dev marthastewart < sample.csv
while IFS=, read -r from to
wpcli @$1 onecms-srm add $from $to 301 --url=$2.$
View gist:da7e3c72e2a008ed8a1a4ddc2f0a8c4a
* Save term meta data.
* @param int $cat_id Category ID.
* @return void
public static function create_category_page_data( $cat_id ) {
// Setup the values for the category page.
$author_id = get_current_user_id();
$post_type = 'category-page';
View gist:9840d1b854fd9e2dc4d7d445ff2500a1
* This file is for loading all mu-plugins within subfolders
* where the PHP file name is exactly like the directory name + .php.
* Example: /mu-tools/mu-tools.php
$dirs = glob( dirname( __FILE__ ) . '/*' , GLOB_ONLYDIR );
View errors
You can’t perform that action at this time.