Skip to content

Instantly share code, notes, and snippets.

View michael-cannon's full-sized avatar

Michael Cannon michael-cannon

View GitHub Profile
@michael-cannon
michael-cannon / constants.txt
Created August 28, 2012 08:42
For in2master, I wanted the ability to autoset config.absRefPrefix, specifically set it, or unset it without a lot of hassle. The following code does such.
config {
# cat=basic/links; type=string; label=Absolute Reference Prefix: Used to convert relative paths to absolute paths. Use absolute URL like "http://www.example.com" to set. If empty, config.baseURL is used. If 0, config.absRefPrefix is unset.
absRefPrefix =
}
@michael-cannon
michael-cannon / gist:4025107
Created November 6, 2012 14:43
Correctly import image caption as caption than description in WordPress
<?php
function add_attachment_caption( $meta, $attachment_id ) {
if ( ! empty( $meta['image_meta']['caption'] ) ) {
$data = array(
'ID' => $attachment_id,
// remove wrongly imported caption as description field
'post_content' => '',
'post_excerpt' => $meta['image_meta']['caption'],
);
@michael-cannon
michael-cannon / debug.php
Created December 13, 2012 03:35
A quick and dirty "what the fudge am i" helper for WordPress. I use this to help me determine what type of view is being presented when theming. In turn, this also helps me check that my display condition assumptions are correct.
<?php
/**
* WordPress debug helpers
*
* @author Michael Cannon <mc@aihr.us>
*/
function wtfami( $uk = null ) {
if ( ! is_null( $uk ) ) echo $uk . " is…\n<br />";
@michael-cannon
michael-cannon / filter.php
Last active December 9, 2015 21:58
Example of using the Testimonials Widget plugin for WordPress `testimonials_widget_testimonial_html` filter.
<?php
add_filter( 'testimonials_widget_testimonial_html', 'my_testimonials_widget_testimonial_html', 10, 6 );
// this function is a copy of Testimonials_Widget::get_testimonial_html and completely ignores what's in $content
function my_testimonials_widget_testimonial_html( $content, $testimonial, $atts, $is_list = true, $is_first = false, $widget_number = null ) {
$atts = wp_parse_args( $atts, Testimonials_Widget::get_defaults( true ) );
$atts = Testimonials_Widget_Settings::validate_settings( $atts );
// display attributes
.testimonialswidget_testimonials {
/* testimonials wrapper */
}
.testimonialswidget_testimonials .testimonialswidget_active {
/* active testimonials */
display: block;
}
.testimonialswidget_testimonials .testimonialswidget_display_none {
/*
Theme Name: Organic-NonProfit
Theme URL: http://www.organicthemes.com/
Description: Organic Themes offers professionally designed, highly customizable Wordpress themes.
Author: Organic Themes
Author URI: http://www.organicthemes.com
Version: 1.3.1
Tags: organic themes, wordpress customization
The CSS, XHTML and Design are released under the GPL:
@michael-cannon
michael-cannon / gist:5517959
Last active December 16, 2015 23:59
[testimonialswidget_list limit=1 random=true paging=false]
[testimonialswidget_list limit=1 random=true paging=false]
<div class="testimonials-widget-testimonials listing"><div class="post-15380 testimonials-widget type-testimonials-widget status-publish hentry testimonials-widget-testimonial single even"><span class="image"><img width="150" height="150" src="http://wp.localhost/wp-content/uploads/2013/01/winterbournedesign.jpeg" class="attachment-thumbnail wp-post-image" alt="winterbournedesign" /></span><blockquote><p><span class="open-quote"></span>Thanks for the fast reply Michael! Have a great weekend.<span class="close-quote"></span></p></blockquote><div class="credit"><span class="author"><a href="http://wordpress.org/support/profile/winterbournedesign" rel="nofollow">Winterbourne Design</a></span></div></div></div>
<div class="testimonials-widget-testimonials listing"><div class="post-15261 testimonials-widget type-testimonials-widget status-publish hentry testimonials-widget-testimonial single"><span class="image"><img width="150" height="150" src="http://w
@michael-cannon
michael-cannon / functions.php
Created May 12, 2013 08:14
Work around for Easy Digital Downloads Payment History report for showing account username than guest after using EDD Guest Registration to convert a guest account to real.
function dc_edd_get_payment_meta( $meta, $payment_id ) {
if ( -1 == $meta['user_id'] ) {
$user_id = get_post_meta( $payment_id, '_edd_payment_user_id', true );
$meta['user_id'] = $user_id;
$user_info = maybe_unserialize( $meta['user_info'] );
$user_info['id'] = $user_id;
$meta['user_info'] = serialize( $user_info );
}
@michael-cannon
michael-cannon / functions.php
Created May 13, 2013 21:07
Add recurring period to pricing
<?php
add_filter( 'edd_purchase_download_form', 'aihrus_edd_purchase_download_form', 10, 2 );
function aihrus_edd_purchase_download_form( $purchase_form, $args ) {
$id = $args['download_id'];
$price = edd_get_download_price( $id );
if ( 0 == $price ) {
$price = '&#036;' . $price;
$replace = 'Free';
$purchase_form = str_replace( $price, $replace, $purchase_form );
} elseif ( class_exists( 'EDD_Recurring' ) && EDD_Recurring()->is_recurring( $id ) ) {
@michael-cannon
michael-cannon / testimonials_widget_columns.php
Created June 21, 2013 19:30
Filter testimonials_widget_columns example
add_filter( 'testimonials_widget_columns', array( &$this, 'columns' ) );
public function columns( $columns ) {
$columns['testimonials-widget-read-more-link'] = __( 'Read More Link', 'testimonials-widget-premium' );
return $columns;
}