Skip to content

Instantly share code, notes, and snippets.

View chrisvanpatten's full-sized avatar

Chris Van Patten chrisvanpatten

View GitHub Profile
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
#titlebar {
min-height: 36px !important;
}
#nav-bar-customization-target {
padding: 2px 4px;
}
@chrisvanpatten
chrisvanpatten / functions.php
Created June 7, 2014 18:31
Automatically register sidebars for all pages on a WordPress site
<?php
/**
* Per-page areas
*/
$pages_args = array(
'post_type' => 'page',
'posts_per_page' => -1,
);
@chrisvanpatten
chrisvanpatten / cross-sells.php
Created June 7, 2014 18:37
Conditional content in WordPress with CFS
<?php
if ( $cfs->get('cross_sells') ) {
// Use the per-page options, if set
$cross_sells = $cfs->get( 'cross_sells' );
$cs_header = $cfs->get( 'cross_sell_header_text' );
} else {
// Use the global setting
$cross_sells = $cfs->get( 'cross_sells', rach5_options() );
$cs_header = $cfs->get( 'cross_sell_header_text', rach5_options() );
@chrisvanpatten
chrisvanpatten / get_mailchimp_dc.php
Created June 16, 2014 14:03
Get the $dc (datacenter) out of a MailChimp API key with PHP
<?php
/**
* get_mailchimp_dc
*
* @return string
*/
function get_mailchimp_dc( $api_key ) {
$dc = 'us1';
$dc = explode('-', $api_key, 2 );
@chrisvanpatten
chrisvanpatten / remove_meta_box.php
Created June 21, 2014 19:51
Remove a WordPress meta box permanently
<?php
/**
* vpm_remove_meta_box
*/
function vpm_remove_meta_box() {
remove_meta_box( 'postcustom', 'post', 'normal' );
}
add_action( 'add_meta_boxes', 'vpm_remove_meta_box' );
<?php
/**
* vpm_default_hidden_meta_boxes
*/
function vpm_default_hidden_meta_boxes( $hidden, $screen ) {
// Grab the current post type
$post_type = $screen->post_type;
// If we're on a 'post'...
@chrisvanpatten
chrisvanpatten / custom-tinymce-0.php
Last active October 18, 2016 16:03
Register custom style formats to TinyMCE in WordPress
<?php
/**
* custom_tinymce
*/
function vpm_custom_tinymce( $settings ) {
// Define our custom formats
$style_formats = array(
array(
dataLayer.push({
'event': 'gaTriggerEvent',
'gaEventCategory': 'form',
'gaEventAction': 'submit',
'gaEventLabel': 'lead-gen'
});
@chrisvanpatten
chrisvanpatten / vpmframe-wp.sh
Last active August 29, 2015 14:04
Automatically create a new wpframe project
#!/usr/bin/env bash
# Create a vpmframe-wp project
mkdir $1
cd $1
git init
touch vpmframe-wp
@chrisvanpatten
chrisvanpatten / readme.md
Last active September 18, 2020 14:16
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.

Setup

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 https://api.instagram.com/v1/users/search\?q\=USERNAME\&client_id\=CLIENT_ID