Skip to content

Instantly share code, notes, and snippets.

@danieliser
danieliser / rename-plugins-after-update.php
Last active November 28, 2022 18:40
This code works to update addon/extension plugin slugs during update from a premapped list. Code likely needs to be run in separate plugin/theme/mu-plugin/drop-in.
<?php
/**
* This code works to update addon/extension plugin slugs during update from a premapped list.
*
* Code likely needs to be run in separate plugin/theme/mu-plugin/drop-in.
*
* Tested Working On:
* - Single Site: Updates Page - Singe Plugin.
@polevaultweb
polevaultweb / edd_perpetual_discounts.php
Last active June 28, 2022 08:31
EDD - Allow discounts to be set to apply to all renewals
<?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
webzunft / canceled-subscriptions.sql
Last active October 4, 2022 13:15
SQL queries to analyse canceled subscriptions managed with EDD Recurring Payments
# 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
SELECT ID,
created,
REGEXP_SUBSTR( REGEXP_SUBSTR( notes, '.* Status changed from active to cancelled .*' ), '^[a-z]+ [0-9]+, [0-9]+' ) AS 'date',
@ciaranmcnulty
ciaranmcnulty / notes.md
Last active March 25, 2024 06:36
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
merlinmann / wisdom.md
Last active April 17, 2024 21:52
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.

<?php
/*
Plugin Name: RafflePress Invent Your Own
Plugin URI:
Description: Programmatically Add User and Complete Actions in RafflePress
Version:
Author:
Author URI:
License:
License URI:
@nerdcha
nerdcha / delete_tweets.sh
Last active April 2, 2020 02:33
Bash oneliner to delete tweets
#!/bin/bash
# Context: https://jamiehall.cc/2020/03/10/delete-all-your-tweets-with-one-line-of-bash/
# https://news.ycombinator.com/item?id=22689746
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
@ericmann
ericmann / Fortress.Options.php
Last active September 20, 2023 04:13
Encrypted 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
jchristopher / functions.php
Last active August 15, 2019 03:25
Prevent EDD Software Licensing Recurring renewal when associated subscription is failing
<?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'] ) ) {
return;
}
@Idealien
Idealien / .lando.yml
Last active October 4, 2021 21:04
Lando .yml with separate DB for phpunit testing
name: local
recipe: wordpress
config:
webroot: .
xdebug: true
services:
appserver:
type: php