Skip to content

Instantly share code, notes, and snippets.

View stuartduff's full-sized avatar

Stuart Duff stuartduff

View GitHub Profile
@thenbrent
thenbrent / custom-subscription-interval.php
Last active April 2, 2021 10:25
Add a new billing interval to WooCommerce Subscriptions to allow for longer intervals between subscription renewal payments. Specifically a new "8" interval to allow you to sell a subscription that renews every 8 days, weeks, months or years.
<?php
/**
* Plugin Name: WooCommerce Subscription Custom Interval
* Description: Add a custom 8 week subscription interval to WooCommerce Subscriptions
* Author: Brent Shepherd
* Version: 1.0
* License: GPL v2
*/
function eg_add_custom_subscription_interval( $subscription_intervals ) {
add_filter( 'woocommerce_dynamic_pricing_is_cumulative', 'wcdp_cumulative_pricing', 10, 2 );
function wcdp_cumulative_pricing( $cumulative, $module_id ) {
if ( $module_id == 'advanced_category' || $module_id == 'simple_membership' ) {
$cumulative = true;
}
return $cumulative;
}
add_filter('wc_dynamic_pricing_load_modules', 'custom_dynamic_pricing_module_order');
add_filter( 'woocommerce_dynamic_pricing_is_cumulative', 'wcdp_cumulative_pricing', 10, 2 );
function wcdp_cumulative_pricing( $cumulative, $module_id ) {
if ( $module_id == 'simple_category' || $module_id == 'simple_membership' ) {
$cumulative = false;
}
return $cumulative;
}
add_filter('woocommerce_dynamic_pricing_is_cumulative', 'on_woocommerce_dynamic_pricing_is_cumulative', 10, 3);
function on_woocommerce_dynamic_pricing_is_cumulative($cumulative, $discounter_name, $cart_item) {
if ($discounter_name == 'simple_category' || $discounter_name == 'simple_membership') {
$cumulative = false;
}
return $cumulative;
}
@jaybuys
jaybuys / woo-slider-content-filter.php
Last active August 25, 2017 00:41
Make WooSlider plugin show full HTML content instead of excerpts in slide layout. Place this code in your WordPress theme functions.php file.
<?php
add_filter( 'wooslider_slides_layout_html', 'wooslider_custom_content', 10, 3);
function wooslider_custom_content ( $content, $args, $post ) {
global $post;
$image = get_the_post_thumbnail( get_the_ID() );
if ( 'true' == $args['link_slide'] || 1 == $args['link_slide'] ) {
$wooslider_url = get_post_meta( get_the_ID(), '_wooslider_url', true );
@stuartduff
stuartduff / github-wppembed.php
Created July 28, 2012 15:04
Easily embed and share Github gists on your WordPress blog
**
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*/
wp_embed_register_handler( 'gist', '/https:\/\/gist\.github\.com\/(\d+)(\?file=.*)?/i', 'wp_embed_handler_gist' );