Skip to content

Instantly share code, notes, and snippets.

Alex King alexkingorg

Block or report user

Report or block alexkingorg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View wordpress-template.php
* The main template file.
* This is the most generic template file in a WordPress theme and one of the
* two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
* Learn more:
View wpdb-implode.php
$results = $wpdb->get_results(
SELECT ID, post_title, post_name, post_parent
FROM $wpdb->posts
WHERE post_parent IN (".implode(',', array_map('intval', $post_ids)).")
alexkingorg / wp-page-tags.php
Created Feb 6, 2014
Enable tags for pages (old code archive) for WordPress.
View wp-page-tags.php
Plugin Name: CF Page Tags
Plugin URI:
Description: Add the tags form to pages in WP.
Author: Crowd Favorite
Author URI:
Version: 1.0
alexkingorg / google-spreadsheet-colors.js
Created Feb 7, 2014
Google Spreadsheet coloring code
View google-spreadsheet-colors.js
function onEdit(e) {
function setColors() {
var activeSheet = SpreadsheetApp.getActiveSheet();
var numRows = activeSheet.getMaxRows();
var numCols = activeSheet.getMaxColumns();
var row, cell, value;
alexkingorg / wp-post-content-tweet.php
Created Feb 9, 2014
Replace post content with tweet URL using Twitter Tools data.
View wp-post-content-tweet.php
function aktt_replace_tweet_content($posts) {
foreach ($posts as $post) {
if ($post->post_type == AKTT::$post_type && !empty($post->tweet)) {
$post->post_content = esc_url(AKTT::status_url($post->tweet->username(), $post->tweet->id()));
add_action('the_posts', 'aktt_replace_tweet_content', 11);
alexkingorg / gist:11220299
Created Apr 23, 2014
RAMP Session Token Debugging
View gist:11220299
In classes/deploy.class.php find this code on or around line 426:
<p>'.__('The batch session token does not match.', 'cf-deploy').'</p>
Replace that with:
<p>'.sprintf(__('The batch session token does not match. Expected "%s", received "%s"', 'cf-deploy'), esc_html($session_token), esc_html($args['batch_session_token'])).'</p>
This will show you the expected and received tokens.
View gist:e8c5f5abad59f96eb837
// readable and easily re-orderable
$(document).on('submit', '#foo', myCallback1);
$(document).on('submit', '#bar', myCallback2);
$(document).on('click', '.baz', myCallback3);
// performant
$(document).on('submit', '#foo', myCallback1)
.on('submit', '#bar', myCallback2)
alexkingorg /
Last active Aug 29, 2015
Script to check the uptime of my ISP - I run this from a CRON job on a local box.
# try 3 times - sometimes getting an initial DNS failure that clears up
while [ $COUNTER -lt 3 ]; do
ping -c 1 &> /dev/null
if [ $? -ne 0 ]; then
echo "`date`: ping failed, isp is down!" >> /Users/aking/Dropbox/Temp/isp-ping-result.log
echo "`date`: ping failed, isp is down!" >> /Users/aking/Dropbox/Temp/isp-downtime.log
alexkingorg / standard-wp-admin-check.php
Created Jun 11, 2011
Check for standard WP admin page before attaching action.
View standard-wp-admin-check.php
Plugin Name: Standard WP Admin Page Check
Description: Example code.
Version: 1.0
Author: Alex King
Author URI:
alexkingorg / gist:1145803
Created Aug 15, 2011
ShareThis WordPress Plugin customization
View gist:1145803
// customizations to have ShareThis nicely integrated into FavePersonal.
// step 1, disable auto-addition to posts
// this adds the ShareThis button to the post sidebar for content posts only
if (function_exists('st_makeEntries')) {
add_action('favepersonal_content_sidebar_after', 'sharethis_button');
You can’t perform that action at this time.