Skip to content

Instantly share code, notes, and snippets.

View brichards's full-sized avatar

Brian Richards brichards

View GitHub Profile
<?php
/**
* This is a docblock.
* With two lines of text.
*/
/*
* This is a multiline inline comment.
* With two lines of notes about something.
@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
/*
Pages
Short description
Since x.x.x
*/
/* Pages
* Short description
<?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.
*/
@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
@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.
#!/usr/bin/php
<?php
echo PHP_EOL;
echo 'Starting unit tests' . PHP_EOL;
exec( 'phpunit', $test_output, $returnCode );
if ( 0 !== $returnCode ) {
echo implode( PHP_EOL, $test_output );
echo PHP_EOL;
<?php
/**
* Output HTML markup for forum post list.
*
* @since 1.0.0
*
* @param integer $post_count Post count.
*/
function skbp_output_forum_posts_list( $post_count = 5 ) {
<?php
$url = esc_url( get_post_meta( $post->ID, '_project-url', true ) );
if ( ! empty( $url ) {
printf( '<p>%s</p>', $url );
}
?>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*\.(js|css|png|jpe?g|gif|ico)) http://example.com/$1 [NC,P,L]
</IfModule>