Skip to content

Instantly share code, notes, and snippets.

@davekellam
davekellam / generate_post_title_and_slug_from_content.php
Last active Apr 25, 2018
Generate a post title and slug based on the content
View generate_post_title_and_slug_from_content.php
<?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 / functions.php
Created Oct 16, 2015
Prevent versioning of WordPress CSS/JS
View functions.php
<?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 );
View gist:11313663
-----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+
@davekellam
davekellam / gist:11313483
Created Apr 26, 2014
Stupid keybase requirement for proving my identity
View gist:11313483
### 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:
@davekellam
davekellam / jetpack.open.graph.php
Last active Dec 31, 2015
Modify Jetpack's Open Graph Output
View jetpack.open.graph.php
<?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 / wp-bulk-import.sh
Created Oct 8, 2013
Bash script for batch importing of WordPress XML files via WP-CLI
View wp-bulk-import.sh
#!/bin/bash
FILES=/path/to/files/*
for file in $FILES
do
echo "Processing $file..."
wp import $file --authors=skip
done
@davekellam
davekellam / dk.wordpress.debug.php
Last active Dec 20, 2015
WordPress Save Debugging
View dk.wordpress.debug.php
<?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 / wordpress_author_url.php
Last active Oct 2, 2019
Remove the WordPress front matter slug from the author url.
View wordpress_author_url.php
<?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 );
View YahooPipes_PostProcessor.php
<?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 = '';
You can’t perform that action at this time.