Skip to content

Instantly share code, notes, and snippets.

View thadallender's full-sized avatar

Thad Allender thadallender

View GitHub Profile
@thadallender
thadallender / tw_contact_form
Last active August 29, 2015 14:06
Theme.Works Shortcode - Contact Form
[tw_contact_form]
@thadallender
thadallender / sell-media-filter-thumbnail-size.php
Created July 9, 2014 20:30
Filter Sell Media Thumbnail Size
<?php
/**
* Filters the size of thumbnail in Sell Media
*/
function sell_media_filter_thumbnail_size(){
return 'large';
}
add_filter( 'sell_media_thumbnail', 'sell_media_filter_thumbnail_size' );
@thadallender
thadallender / jquery-filter-items
Created June 10, 2014 19:49
jQuery filter a list of items using data attributes and classes on the item
jQuery(document).ready(function($){
$('.filter').on('click', function(){
var cat = $(this).data('filter');
$('.item').each(function(){
if($(this).hasClass(cat)){
$(this).show().removeClass('hide').addClass('show');
} else {
$(this).hide().removeClass('show').addClass('hide');
}
});
@thadallender
thadallender / sell-media-filter-post-status.php
Created May 21, 2014 17:02
Filter Sell Media add bulk and add package post status
/**
* Filter the post status of newly created Sell Media items
* Applies only to Add Bulk and Add Package features
* Useful if you don't want contributors to publish new items
* Without first being approved
*/
function my_sell_media_post_status(){
if ( current_user_can( 'manage_options' ) ) {
return 'publish';
} else {
@thadallender
thadallender / Volume discounts for Sell Media
Last active August 29, 2015 14:00
Volume discounts for Sell Media. Please note: Sell Media verifies the total cost of items from the database right before sending the order to the payment gateway. Comment out lines 200-232 in sell-media/sell-media.js to disable server-side price verification.
sellMediaCart.total = function(){
var total = 0;
sellMediaCart.each(function (item) {
total += item.total();
});
// take 10 off it qty is greater than or equal to 5
if ( sellMediaCart.quantity() >= 5 ){
total -= 10;
@thadallender
thadallender / Exclude Sell Media from native WP search results
Created April 17, 2014 16:55
Exclude Sell Media from native WP search results
function my_search_filter( $query ) {
if ( !$query->is_admin && $query->is_search ) {
$query->set( 'post_type', array('post', 'page' ) );
}
return $query;
}
add_filter( 'pre_get_posts', 'my_search_filter' );
@thadallender
thadallender / Customize Localized Sell Media Text
Created April 16, 2014 19:37
Customize Localized Sell Media Text
function my_set_add_to_cart_button() {
global $wp_scripts;
$data = $wp_scripts->get_data( 'sell_media', 'data' );
if( !is_array( $data ) ) {
$data = json_decode( str_replace( 'var sell_media = ', '', substr( $data, 0, -1 ) ), true );
}
$data['added_to_cart'] = 'New Add Cart Button Text';
$wp_scripts->add_data( 'sell_media', 'data', '' );
@thadallender
thadallender / gist:10427368
Created April 10, 2014 21:59
Modification to sell_media_load_template
/**
* Loads a template from a specified path
*
* @package Ajax
* @uses load_template()
* @since 0.1
*/
function sell_media_load_template() {
if ( file_exists( get_template_directory() . '/cart.php' ) ) {
@thadallender
thadallender / example-filter-sell-media
Created April 9, 2014 22:39
Example use of a filter in the Sell Media WordPress plugin
function my_sell_media_download_size_text(){
return 'Parameters';
}
add_filter( 'sell_media_download_size_text', 'my_sell_media_download_size_text' );
@thadallender
thadallender / sell-media-example-after-successful-payment
Created April 9, 2014 22:25
Example use of the sell_media_after_successful_payment action hook in the Sell Media WordPress plugin
function my_sell_media_after_successful_payment( $payment_id ){
wp_mail( '[email protected]', 'New Sale!', 'A new payment was successfully recorded and I figured you might want to know.' );
}
add_action( 'sell_media_after_successful_payment', 'my_sell_media_after_successful_payment' );