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 / gist:1545420
Created December 31, 2011 21:36
Add post format to FeedWordPress syndicated posts
<?php
if ( ! function_exists( 'ucc_post_format_feedwordpress_syndicated_post' ) ) {
function ucc_post_format_feedwordpress_syndicated_post ( $data ) {
$feed = $data['meta']['syndication_feed'];
// Adjust stripos contents as needed.
if ( stripos( 'delicious.com', $feed ) !== false ) {
$data['tax_input']['post_format'] = 'post-format-link';
} elseif ( stripos( 'tumblr.com', $feed ) !== false ) {
@jmdodd
jmdodd / gist:1458820
Created December 11, 2011 06:19
Set custom post type and taxonomy terms with Ozh' Tweet Archiver
<?php
if ( ! function_exists( 'ucc_ozh_ta_insert_tweets_post' ) ) {
function ucc_ozh_ta_insert_tweets_post( $data ) {
// Replace values of [tax_input][category] and [post_type] with appropriate values.
$data['tax_input']['category'] = '1,2';
$data['post_type'] = 'tweet';
return $data;
} }
add_filter( 'ozh_ta_insert_tweets_post' , 'ucc_ozh_ta_insert_tweets_post' );
@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:1695468
Created January 28, 2012 19:14
Add custom post types to the Loop
<?php
if ( ! function_exists( 'ucc_add_cpts_to_pre_get_posts' ) ) {
function ucc_add_cpts_to_pre_get_posts( $query ) {
if ( $query->is_main_query() && ! is_post_type_archive() && ! is_singular() && ! is_404() ) {
$my_post_type = get_query_var( 'post_type' );
if ( empty( $my_post_type ) ) {
$args = array(
'exclude_from_search' => false,
'public' => true,