Skip to content

Instantly share code, notes, and snippets.

View brichards's full-sized avatar

Brian Richards brichards

View GitHub Profile
@brichards
brichards / functions.php
Created January 3, 2014 14:46
Make all WP oEmbedded videos responsive.
<?php
/**
* Wrap an embedded video with a container for simpler styling.
*
* @since 1.0.0
*
* @param string $output HTML Markup.
* @param string $url oEmbed URL.
@brichards
brichards / gist:7517250
Last active December 28, 2015 14:49 — forked from jaredatch/gist:7517176
=== Almost always running ===
Google Chrome (10 tabs average)
Vagrant (running VirtualBox)
SublimeText 2
iTerm2
Alfred
Dropbox
Skype
Tweetbot
Hipchat
<?php
/**
* Change "Featured Image" to "Achievement Image" throughout media modal.
*
* @since 1.3.0
*
* @param array $strings All strings passed to media modal.
* @param object $post Post object.
* @return array Potentially modified strings.
*/
<?php
/*
Pages
Short description
Since x.x.x
*/
/* Pages
* Short description
@brichards
brichards / custom_query.php
Last active December 24, 2015 01:09
Returns an array of queried results. Behaves as expected, with GROUP BY limiting my results to a single entry for each term_id, whereas no GROUP BY returns a separate entry for each term_id differing object_id. Desired outcome: single entry per term_id which contains all connected object_ids. Current output: single entry per term_id (success!). …
<?php
$terms = $wpdb->get_results(
"
SELECT term.term_id,
term.name,
term.slug,
taxonomy.term_taxonomy_id,
relationship.object_id
FROM $wpdb->terms as term
<?php
/**
* This is a docblock.
* With two lines of text.
*/
/*
* This is a multiline inline comment.
* With two lines of notes about something.
<?php
class HHW_WP_CLI_Commands extends WP_CLI_Command {
/**
* Update post meta for all posts that have sdac_post_thumbnail key.
* Move associated meta value to featured image.
*/
function fix_images() {
global $wpdb;
@brichards
brichards / media.php
Last active December 21, 2015 12:49
Hook documentation for the image_downsize filter
<?php
/**
* Override default image downsize rules with a custom resizing service
*
* Defaults to false (no third-party downsizing), but can pass an indexed
* array of image details to use in place of WP's default downsizing rules
* and short-circuit the remainder of the function.
*
* @since 2.5.0
@brichards
brichards / async-upload.php
Created August 22, 2013 01:24
Dynamically-named Filter, with @return statement
<?php
/**
* Return the ID of the uploaded attachment of a given type
*
* @since 2.5.0
*
* @param int $id The uploaded attachment ID
* @return int The uploaded attachment ID
*/
@brichards
brichards / functions.php
Created August 5, 2013 15:22
Remove Support for StartBox Slideshows
<?php
// Disable support for SB Slideshows
function remove_sb_slideshows() {
remove_theme_support( 'sb-slideshows' );
}
add_action( 'after_setup_theme', 'remove_sb_slideshows' );