Skip to content

Instantly share code, notes, and snippets.

View kingkool68's full-sized avatar
💻
Coding.

Russell Heimlich kingkool68

💻
Coding.
View GitHub Profile

Keybase proof

I hereby claim:

  • I am kingkool68 on github.
  • I am kingkool68 (https://keybase.io/kingkool68) on keybase.
  • I have a public key whose fingerprint is 23B6 C578 8286 FD7B 9E83 4C10 3B56 93AA 987B D9BF

To claim this, I am signing this object:

@kingkool68
kingkool68 / facebook-connect.php
Created August 22, 2014 14:42
Makes it easy for your site to use Facebook Connect, Google Connect, in a wholly modular way. Based on Simple Facebook Connect (http://ottopress.com/wordpress-plugins/simple-facebook-connect/) by Otto
<?php
/*
* Base
*
*/
// basic XFBML load into footer
function psc_fb_load_args() {
/*
global $sfc_comm_comments_form;
<?php
/**
* Plugin Name: Only Certain Logins Allowed
* Description: Only let certain usernames do anything...
* Version: 1.0
* Author: Russell Heimlich
* Author URI: https://twitter.com/kingkool68
*/
function only_certain_logins_allowed() {
@kingkool68
kingkool68 / gist:864a087b0b10cffde677
Last active August 29, 2015 14:16
Basic GET request from Uber's API
<?php
/* Short and sweet */
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
$url = 'https://api.uber.com/v1/estimates/price';
$args = array(
/*
'headers' => array(
'Authorization' => $some_token_goes_here
<?php
/*
Plugin Name: Simple Metabox Example
Description: Here's a barebones metabox example
Version: 1.0
Author: Russell Heimlich
Author URI: http://www.russellheimlich.com
*/
//Hook in to the load-post.php and load-post-new.php to determine if we want to show our metabox or not. If you only want to show your metabox on the screen once the post has been saved as a draft or published (aka not a brand new post) then remove the load-post-new.php action....
@kingkool68
kingkool68 / footnotes.php
Last active August 29, 2015 14:21
Simple WordPress Footnotes
<?php
function api_footnotes( $content ) {
$post_id = get_the_ID();
//Need to correct wpautop() which smart-quoteify's the " in the numoffset argument.
$content = preg_replace('/numoffset=&#8221;(\d+)&#8243;/i', 'numoffset="$1"', $content);
//Microsoft has some weird space characters that Mac/Unix systems don't have. What the next line does is replace the weird space characters with a real space character which makes the regex work...
$content = str_replace('[ref ', '[ref ', $content);
@kingkool68
kingkool68 / interactive-unauthorized-immigrants-2012.php
Created September 1, 2015 15:27
The code that powers http://www.pewhispanic.org/interactives/unauthorized-immigrants-2012/ a hybrid (frontend + backend) interactive data visualization.
<?php
function unauthorized_immigrants_enqueue_scripts() {
wp_enqueue_script( 'highmaps-us' );
if( !is_iframe() ) {
wp_enqueue_script( 'pew-sortable-tables' );
}
pew_interactives_enqueue_style( 'interactive-unauthorized-immigrants-2012' ); //Two interactives share the same CSS file.
}
add_action( 'pew_interactive_styles', 'unauthorized_immigrants_enqueue_scripts', 11 );
@kingkool68
kingkool68 / wordpress-environment-conditionals.php
Created October 12, 2015 18:23
WordPress helper conditionals to run code in certain environments.
<?php
/**
* Helper conditionals to run code in certain environments.
*/
if ( ! defined( 'RH_ENV' ) ) {
$hostname = $_SERVER['HTTP_HOST'];
if ( isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) && ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
$hostname = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
<?php
/*
Plugin Name: Pew Archive Filters
Description: Adds re-write rules and helper functions that make filtering archives by year and/or a taxonomy possible.
Version: 0.2
Author: Russell Heimlich
Author URI: http://www.russellheimlich.com
*/
function pew_archive_filter_rewrite_rules( $wp_rewrite ) {
@kingkool68
kingkool68 / Related WordPress Posts
Created January 8, 2016 17:23
This plugin features a smarty-pants set of functions to determine what content is related to what.