Skip to content

Instantly share code, notes, and snippets.

View davekellam's full-sized avatar

Dave Kellam davekellam

View GitHub Profile
@davekellam
davekellam / gist:11313483
Created April 26, 2014 06:46
Stupid keybase requirement for proving my identity
### Keybase proof
I hereby claim:
* I am davekellam on github.
* I am davekellam (https://keybase.io/davekellam) on keybase.
* I have a public key whose fingerprint is A1D3 5AFC 79AD F7F7 AA8E E70A D7FE F2CA B372 1884
To claim this, I am signing this object:
-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v0.1.12
Comment: https://keybase.io/crypto
wcFMA/ota0i80rHmAQ/+K8BN0jPlrfT5b0SVWyzUpJrIgIAKe/qO/TZoUkrquh6K
Wl4eAxTSJnix5n/bL+7rfJjQ0WNLJt79DfiS1QAMzZWMtW0OZotXuVx2GohcrMPM
9ZTjXmIjsjTvLQCs03y5qCKA4dWP8nq7iBLubgBVauhPndu60HgDW4Gd+ogJqFou
tZc2ugvdnusiaGROHndrRry2qfRAKg7ueEXZl0pAVQNE5eYkboM1TFoBMvValv/9
8V/qA28fJBm8Rjjhe0qWG2eh5I2miC8wRZnGEoocsTobiwyd6HlcR5bx7N01Gt+a
er/wVHrNjqWjNnXY0Zac3zAvGdgzoeQ+RbKJLICiV9NZh8HB1uNeG6lSGnS+MhZ+
<?php
/*
Script for converting a Yahoo Pipe's homepage URL into something more sensible
Requires cURL to be enabled
*/
// CHANGE THESE VARIABLES
// In the link http://pipes.yahoo.com/pipes/pipe.run?_id=uCxBbzww3hGB9ClS6ycw5g&_render=php
// the pipe ID is uCxBbzww3hGB9ClS6ycw5g (everything after _id= and before &_render
$pipe_id = '';
@davekellam
davekellam / functions.php
Created October 16, 2015 19:49
Prevent versioning of WordPress CSS/JS
<?php
function remove_cssjs_ver( $src ) {
if( strpos( $src, '?ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 1000 );
add_filter( 'script_loader_src', 'remove_cssjs_ver', 1000 );
@davekellam
davekellam / dk.wordpress.debug.php
Last active December 20, 2015 17:29
WordPress Save Debugging
<?php
/**
* Save debug info to log
*
* @param int $post_id ID of the post to save
*/
function dk_debug_save_post( $post_id ) {
global $wpdb;
error_log( print_r( $wpdb->queries, true ) );
@davekellam
davekellam / jetpack.open.graph.php
Last active December 31, 2015 19:09
Modify Jetpack's Open Graph Output
<?php
/**
* Modify Jetpack's Open Graph Output
*/
function ef_og_tweaks( $tags ) {
if ( is_home() ) {
// Remove the blank image
unset( $tags['og:image'] );
$ef_og_home_img = 'YOUR_IMAGE_URL';
@davekellam
davekellam / generate_post_title_and_slug_from_content.php
Last active April 25, 2018 23:10
Generate a post title and slug based on the content
<?php
/**
* Generate a post title and slug from the content
*/
function dk_generate_title_and_slug( $data ) {
if( 'post' == $data['post_type'] && empty( $data['post_title'] ) ) {
// Quick way to strip media (could do something like use media type to inform title)
$title = wp_trim_excerpt( $data['post_content'] );
@davekellam
davekellam / wordpress_author_url.php
Last active October 2, 2019 12:00
Remove the WordPress front matter slug from the author url.
<?php
/**
* Modify Author links go to the right page
*/
function dk_author_link( $link, $author_id ) {
$link = str_replace( 'FRONT_URL_PATH/', '', $link );
return $link;
}
add_filter( 'author_link', 'dk_author_link', 10, 2 );
@davekellam
davekellam / wp-bulk-import.sh
Created October 8, 2013 22:23
Bash script for batch importing of WordPress XML files via WP-CLI
#!/bin/bash
FILES=/path/to/files/*
for file in $FILES
do
echo "Processing $file..."
wp import $file --authors=skip
done