Skip to content

Instantly share code, notes, and snippets.

View brandondove's full-sized avatar

Brandon Dove brandondove

View GitHub Profile
<?php
/**
* Sets the value of a column called "clicks" in the AdSanity post list in the WordPress Dashboard.
*/
function example_adsanity_ads_posts_columns_clicks_value( $value = '' ) {
// Today's clicks
$clicks = get_post_meta(
get_the_ID(),
sprintf( '_clicks-%s', mktime( 0,0,0, date( 'n' ), date( 'j' ), date( 'Y' ) ) ),
<?php
/**
* Indicates that the "clicks" column is sortable for the AdSanity post list in the WordPress Dashboard.
*/
function example_adsanity_ads_sortable_posts_columns( $sortable_columns = array() ) {
$sortable_columns['clicks'] = 'clicks';
return $sortable_columns;
<?php
/**
* Adds a "thumbnail" column to the AdSanity post list in the WordPress Dashboard.
*/
function example_adsanity_ads_posts_columns( $columns = array() ) {
$columns['thumbnail'] = __( 'Thumbnail', 'example' );
return $columns;
@brandondove
brandondove / twitter-stream.patch
Created July 18, 2016 20:37
Twitter Stream Patch for PHP 5.5 compatibility
diff --git a/wp-content/plugins/twitter-stream/twitter-stream.php b/wp-content/plugins/twitter-stream/twitter-stream.php
index 7e7df60..29f5bb0 100644
--- a/wp-content/plugins/twitter-stream/twitter-stream.php
+++ b/wp-content/plugins/twitter-stream/twitter-stream.php
@@ -301,9 +301,9 @@ function twitter_stream($args = FALSE) {
//Now let's do some highlighting & auto linking.
//Find all the @replies and place them in a span so CSS can be used to highlight them.
- $output = preg_replace('~(\@[a-z0-9_]+)~ise', "'<span class=\"at-reply\"><a href=\"http://twitter.com/'.substr('$1', 1).'\" title=\"View '.substr('$1', 1).'\'s profile\">$1</a></span>'", $output);
+ $output = preg_replace_callback( '~(\@[a-z0-9_]+)~is', 'twitter_stream_reply_wrap', $output );
<?php
/* available mentors (we'll probably have to add a user meta field to identify users as a mentor) */
$mentor_args = array(
'meta_query' => array(
array(
'wc_mentor' => '1'
)
)
);
@brandondove
brandondove / 01-intro.md
Last active August 29, 2015 14:22
Bullet Points for Contributor Corner

Contributing to the WordPress Project

What's in it for you?

Top reasons to get involved from a recent talk by former core contributor, John O'Nolan.

  • Learning: Get taught how to code using best practices by core contributors for FREE.
  • Recognition: Your name will be associated with WordPress, the most popular content management system on the planet. Whether you're trying to get a new job, land bigger projects, or find clients willing to pay you more money, being able to say that your work is used by millions of people to manage content on 23% of the web is kind of awesome.
  • Competitive Advantage: Get to know what's going in to core before anyone else.
@brandondove
brandondove / translate.php
Last active August 29, 2015 14:13
WordPress Translation Function Code Samples
<?php
/*
Plugin Name: WordPress Translation Examples
Description: Sample code to show how to do translations
Plugin URI: https://gist.github.com/brandondove/a0f43ce016a9566f3912
Author: Pixel Jar
Author URI: http://www.pixeljar.com
Version: 1.0
License: GPL2
@charset "UTF-8";
@font-face {
font-family: "adsanity";
src:url("../fonts/adsanity.eot");
src:url("../fonts/adsanity.eot?#iefix") format("embedded-opentype"),
url("../fonts/adsanity.woff") format("woff"),
url("../fonts/adsanity.ttf") format("truetype"),
url("../fonts/adsanity.svg#adsanity") format("svg");
font-weight: normal;
/* scripts js file for jQuery for Designers */
jQuery(document).ready(function($){
$('#username').focus();
});
@brandondove
brandondove / gist:6226205
Last active December 21, 2015 01:18
Use a specific template part based on referring webpage
<?php
// Will default to base.php, then base-(referrer).php
get_template_part( 'base', wp_get_referer() );