Skip to content

Instantly share code, notes, and snippets.

View jmdodd's full-sized avatar

Jennifer M. Dodd jmdodd

View GitHub Profile
Verifying my Blockstack ID is secured with the address 1KecTY34FUtg2epggbdZ7H6BLZG5Wf2qFU https://explorer.blockstack.org/address/1KecTY34FUtg2epggbdZ7H6BLZG5Wf2qFU
@jmdodd
jmdodd / keybase.md
Created August 5, 2014 21:12
keybase.md

Keybase proof

I hereby claim:

  • I am jmdodd on github.
  • I am jmdodd (https://keybase.io/jmdodd) on keybase.
  • I have a public key whose fingerprint is 3700 3C68 F60E 8294 0A34 FBF3 D0AC 9489 3A6B A29A

To claim this, I am signing this object:

@jmdodd
jmdodd / gist:5006995
Last active December 14, 2015 01:29
Calendar for multiple post types; needs cleanup (circa 2010).
<?php
function ucc_get_calendar( $post_types = '', $initial = true, $echo = true ) {
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
// Set and verify post types to fetch
if ( empty( $post_types ) || !is_array( $post_types ) ) {
$args = array(
'public' => true,
'_builtin' => false,
@jmdodd
jmdodd / gist:4055427
Created November 11, 2012 16:28
Set Twitter language for WordPress oEmbeds
if ( !function_exists( 'ucc_oembed_twitter_lang' ) ) {
function ucc_oembed_twitter_lang( $provider, $url, $args ) {
if ( 'twitter.com' == parse_url( $url, PHP_URL_HOST ) ) {
if ( defined( 'WPLANG' ) )
$lang = strtolower( WPLANG );
if ( empty( $lang ) )
$lang = 'en';
$args['lang'] = $lang;
$provider = add_query_arg( 'lang', urlencode( $lang ), $provider );
@jmdodd
jmdodd / gist:2402288
Created April 16, 2012 23:26
Limit the BuddyPress datebox year range.
<?php
if ( ! function_exists( 'ucc_profile_field_datebox_year_range' ) ) {
function ucc_profile_field_datebox_year_range( $html, $type, $day, $month, $year, $field_id, $date ) {
if ( 'year' == $type ) {
$current_year = date( 'Y' );
$past_year = $current_year - 3;
$future_year = $current_year + 3;
$html = '';
$html .= '<option value=""' . selected( $year, '', false ) . '>----</option>';
@jmdodd
jmdodd / gist:2402155
Created April 16, 2012 22:50
Set user as spammer in BuddyPress when given the 'suspended' Role.
<?php
if ( ! function_exists( 'ucc_set_user_to_spammer' ) ) {
function ucc_set_user_to_spammer( $userid, $role ) {
global $wpdb;
$userid = abs( intval( $userid ) );
$wp_roles = new WP_Roles;
if ( $wp_roles->is_role( $role ) && ( $role == 'suspended' ) ) {
$wpdb->update( $wpdb->users, array( 'user_status' => 1 ), array( 'ID' => $userid ) );
@jmdodd
jmdodd / gist:1782766
Created February 9, 2012 20:13
Locate a template from a BuddyPress plugin template call.
<?php
// Example usage: ucc_bp_locate_template( 'template/index.php', true, true, __FILE__ ).
if ( ! function_exists( 'ucc_bp_locate_template' ) ) {
function ucc_bp_locate_template( $template_names, $load = false, $require_once = true, $file = '' ) {
$located = '';
foreach ( (array) $template_names as $template_name ) {
if ( ! $template_name )
continue;
@jmdodd
jmdodd / gist:1708947
Created January 31, 2012 05:05
Display tweets from Ozh' Tweet Archiver using oEmbed
<?php
// You will need to replace the in_category( 'twit' ) conditional with one that fits your own setup.
if ( ! function_exists( 'ucc_twitter_oembed_the_content' ) ) {
function ucc_twitter_oembed_the_content( $content ) {
global $post;
$screen_name = 'YOUR_SCREEN_NAME_HERE';
if ( in_category( 'twit' ) ) {
$tweet_url = "http://twitter.com/#!/{$screen_name}/status/" . get_post_meta( $post->ID, 'ozh_ta_id', true );
$content = "\n[embed]{$tweet_url}[/embed]\n";
@jmdodd
jmdodd / gist:1695504
Created January 28, 2012 19:25
Add custom post types to the Loop by adding an action to pre_get_posts (doing it wrong)
<?php
if ( ! function_exists( 'ucc_include_custom_post_types' ) ) {
function ucc_include_custom_post_types( $query ) {
// Don't break admin or preview pages. This is also a good place to exclude feed with ! is_feed() if desired.
if ( ! is_preview() && ! is_admin() && ! is_singular() ) {
$args = array(
'public' => true ,
'_builtin' => false
);
@jmdodd
jmdodd / gist:1695498
Created January 28, 2012 19:22
Add custom post types to the Loop (doing it wrong)
<?php
if ( ! function_exists( 'ucc_request_filter' ) ) {
function ucc_request_filter( $query ) {
// Preview does not like having post_type set; feed is my personal preference.
if ( empty( $query['preview'] ) && empty( $query['feed'] ) ) {
$my_post_type = $query['post_type'];
if ( empty( $my_post_type ) ) {
$query['post_type'] = 'any';
}