Skip to content

Instantly share code, notes, and snippets.

View thenbrent's full-sized avatar

Brent Shepherd thenbrent

View GitHub Profile
@thenbrent
thenbrent / wcs-debug-mode-engaged.php
Created April 14, 2014 17:30
Code to switch WooCommerce Subscriptions to Debug Mode on a site. Insert between PHP tags (`<?php ?>`)
if ( ! defined( 'WCS_DEBUG' ) ) {
define( 'WCS_DEBUG', true );
}
@thenbrent
thenbrent / test-strtotime.php
Last active June 1, 2017 17:16
Testing strtotime() input/output for a variety of strings
******* strtotime() test run on Friday (2014-03-21 22:28:50-UTC) **********
---- testing day of week ----
Wednesday = 2014-03-26 <-- the next Wednesday (not the last)
Wednesday next week = 2014-04-02 <-- interpretted as "the first Wednesday after one week from today" rather than "the next Wednesday"
Friday = 2014-03-21 <-- today!
Friday next week = 2014-03-28 <-- one week
---- testing day of month ----
First day of March = 1970-01-01 <-- requires specific integer day (i.e. date( 't' ) )
@thenbrent
thenbrent / wcs-do-not-update-role.php
Created February 7, 2014 19:31
A simple plugin to stop WooCommerce Subscriptions from changing users' roles.
<?php
/**
* Plugin Name: Stop WooCommerce Subscriptions Changing a User's Role
* Plugin URI:
* Description:
* Author: Brent Shepherd
* Author URI:
* Version: 1.0
*/
@thenbrent
thenbrent / wcs-remove-my-subscriptions-buttons.php
Last active October 19, 2023 06:22
Remove any given button from the My Subscriptions table on the My Account page. By default, only the "Change Payment Method" button is removed, but you can uncomment additional actions to remove those buttons also.
<?php
/**
* Plugin Name: Remove Subscription Action Buttons from My Account
* Plugin URI: https://gist.github.com/thenbrent/8851287/
* Description: Remove any given button from the <a href="http://docs.woothemes.com/document/subscriptions/customers-view/#section-2">My Subscriptions</a> table on the My Account page. By default, only the "Change Payment Method" button is removed, but you can uncomment additional actions to remove those buttons also.
* Author: Brent Shepherd
* Author URI:
* Version: 2.0
*/
@thenbrent
thenbrent / wcs-disallow-subscription-actions.php
Last active November 18, 2021 16:36
A simple plugin to disable certain core actions from being carried out on a subscription with the WooCommerce Subscriptions plugin. For example, prevent a subscription from being changed to a new payment method.
<?php
/**
* Plugin Name: WooCommerce Subscriptions Disallow Subscription Actions
* Plugin URI: https://docs.woothemes.com/document/subscriptions/faq/#section-63
* Description: Prevent core actions from being carried out on a subscription with the WooCommerce Subscriptions plugin.
* Author: Brent Shepherd
* Author URI:
* Version: 2.0
*/
<?php
/**
* Plugin Name: WCS 1.4 Upgrade Fix
* Plugin URI:
* Description: Custom plugin to fix a database that fell out of sync with Subscriptions 1.4's database structure.
* Author: Brent Shepherd
* Author URI:
* Version: 1.0
*/
@thenbrent
thenbrent / wc-task-scheduler-tester.php
Last active January 4, 2016 21:09
A simple plugin to create and test scheduled tasks with the WC Scheduler, see https://github.com/flightless/delayed-job for the scheduler in question.
<?php
/*
Plugin Name: WooCommerce Task Scheduler Tester
Plugin URI:
Description: A simple plugin to create and test scheduled tasks with the WC Scheduler
Author:
Author URI:
Version: 0.1
*/
@thenbrent
thenbrent / wcs-perpetual-download-access.php
Created January 28, 2014 18:49
Allow customers to download all files associated with a product to which they have purchased a subscription - even after their subscription has been cancelled or expired.
<?php
/**
* Plugin Name: WooCommerce Subscriptions Perpetual Download Access
* Description: Allow customers to download all files associated with a product to which they have purchased a subscription - even after their subscription has been cancelled or expired.
* Author:
* Author URI:
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@thenbrent
thenbrent / ppdg-customise-start-date.php
Created January 16, 2014 21:49
Customise the subscription start date sent to PayPal when purchasing a subscription via the WooCommerce PayPal Digital Goods extension (version 2.4.1 or newer).
<?php
/**
* Plugin Name: Custom PayPal Digital Goods Start Date
* Description: Customise the subscription start date sent to PayPal when purchasing a subscription via the WooCommerce PayPal Digital Goods extension (version 2.4.1 or newer).
* Author:
* Author URI:
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@thenbrent
thenbrent / wcs-is-not-large-site.php
Last active January 2, 2016 03:59
WooCommerce Subscriptions 1.4 disabled some features on larger sites (i.e. sites with more than 2,500 subscriptions). This plugin can be used to enable these features if you are confident your server has enough resources to allow them to work correctly.
<?php
/**
* Plugin Name: WooCommerce Subscriptions Enable Search
* Description: Enable the subscription search and sort by next payment date features on large sites. <a href="http://docs.woothemes.com/document/subscriptions/faq/#section-60">Learn More</a>.
* Author: Brent Shepherd
* Version: 1.0
* License: GPL v2
*/
add_filter( 'woocommerce_subscriptions_is_large_site', '__return_false' );