Skip to content

Instantly share code, notes, and snippets.

polevaultweb / edd_perpetual_discounts.php
Last active Jun 28, 2022
EDD - Allow discounts to be set to apply to all renewals
View edd_perpetual_discounts.php
// Add new Discount setting the to discount add and edit forms
add_action( 'edd_add_discount_form_before_use_once', array( $this, 'edd_perpetual_discounts_setting_add_form' ) );
add_action( 'edd_edit_discount_form_before_use_once', array( $this, 'edd_perpetual_discounts_setting_edit_form' ) );
// Handle saving the settings on form submission
add_filter( 'edd_update_discount', 'edd_perpetual_discounts_add_meta' );
add_filter( 'edd_insert_discount', 'edd_perpetual_discounts_add_meta' );
webzunft / canceled-subscriptions.sql
Last active Mar 10, 2022
SQL queries to analyse canceled subscriptions managed with EDD Recurring Payments
View canceled-subscriptions.sql
# Basic queries to analyse canceled subscriptions using EDD Recurring Payments pre EDD 3.0
# Use EXPLAIN if you have large stores since the "notes" column is not indexed and queries can take some time
# Some of these reports might be worth storing as Views and look at the graphs PHPMyAdmin can also create from them
# List subscription cancelation with creation and cancelation date, as well as the user who canceled
# good as a basis for further queries
REGEXP_SUBSTR( REGEXP_SUBSTR( notes, '.* Status changed from active to cancelled .*' ), '^[a-z]+ [0-9]+, [0-9]+' ) AS 'date',
ciaranmcnulty /
Last active Apr 26, 2022
Notes on using Docker on ARM Macs (November 2021)

Docker for Mac

On M1 machines, Docker for Mac is running a lightweight linux ARM VM, then running containers within that, so containers are essentially running natively. Don't be fooled by the fact the UI or binary CLI tools (e.g. docker) might require Rosetta.

Within that VM is an emulation layer called QEmu. This can be used by docker to run Intel containers. This does not use Rosetta at all, and has a roughly 5-6X performance penalty. (If you just upgraded your CPU this may result in a similar performance to your old machine!)

Pulling and running with Docker

Many images in public registries are multi-architecture. For instance at the time of writing on Docker Hub the php:8.0-cli image has the following digests:

merlinmann /
Last active Jun 2, 2022
Merlin's Wisdom Project (Draft)

Merlin's Wisdom Project

Or: “Everybody likes being given a glass of water.”

By Merlin Mann.

It's only advice for you because it had to be advice for me.

View rafflepress-invent-your-own.php
Plugin Name: RafflePress Invent Your Own
Plugin URI:
Description: Programmatically Add User and Complete Actions in RafflePress
Author URI:
License URI:
nerdcha /
Last active Apr 2, 2020
Bash oneliner to delete tweets
# Context:
twurl "/1.1/statuses/user_timeline.json?screen_name=YOUR_TWITTER_HANDLE&count=200&max_id=$(twurl '/1.1/statuses/user_timeline.json?screen_name=YOUR_TWITTER_HANDLE&count=200&include_rts=1' | jq -r '.[9]|.id_str')&include_rts=1" | jq -r '.[]|.id_str' | parallel -j 10 -a - twurl -X POST /1.1/statuses/destroy/{1}.json > /dev/null
View Fortress.Options.php
* Encryption operations for working with WordPress options to store data
* in the options table. Not all options will be encrypted. You will need
* to wire up selection of options to be protected separately.
* @package Fortress
namespace DisplaceTech\Fortress\Options;
jchristopher / functions.php
Last active Aug 15, 2019
Prevent EDD Software Licensing Recurring renewal when associated subscription is failing
View functions.php
// Prevent license renewal when associated subscription is failing
// (it will cause double charges and double subscriptions and waste a lot of your time)
add_action( 'edd_pre_add_to_cart', function( $download_id, $options ) {
// Only applicable if this is a renewal.
if ( empty( $options['is_renewal'] ) ) {
Idealien / .lando.yml
Last active Oct 4, 2021
Lando .yml with separate DB for phpunit testing
View .lando.yml
name: local
recipe: wordpress
webroot: .
xdebug: true
type: php
davekiss / gist:2639184ac066c53416b23c5a66f42d1e
Created Feb 2, 2019
EDD Weekly Domain Report via Email
View gist:2639184ac066c53416b23c5a66f42d1e
* Add a weekly email report that summarizes which domains that
* your products are being used on.
add_filter( 'cron_schedules', function( $schedules ) {
$schedules['weekly'] = array(
'interval' => 604800,
'display' => __('Once Weekly')