Skip to content

Instantly share code, notes, and snippets.

@afragen
afragen / gist-oembed.php
Last active Aug 5, 2022
WordPress plugin to embed gists or gist files.
View gist-oembed.php
<?php
/**
* Gist oEmbed.
*
* @package Fragen\Gist_OEmbed
*
* Plugin Name: Gist oEmbed
* Plugin URI: https://gist.github.com/afragen/36ab01da116aadd27a3f4d85cce90390
* Description: oEmbed Gist or files within Gists.
* Version: 0.6.2
@polevaultweb
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
<?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 Oct 4, 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
SELECT ID,
created,
REGEXP_SUBSTR( REGEXP_SUBSTR( notes, '.* Status changed from active to cancelled .*' ), '^[a-z]+ [0-9]+, [0-9]+' ) AS 'date',
@aymericbeaumet
aymericbeaumet / delete-likes-from-twitter.md
Last active Nov 29, 2022
[Recipe] Delete all your likes/favorites from Twitter
View delete-likes-from-twitter.md

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
    d.click()
 }
@danielbachhuber
danielbachhuber / postmark-split-wp-mail.php
Created Jul 30, 2019
Splits wp_mail() with more than 40 bcc into multiple batches
View postmark-split-wp-mail.php
<?php
/**
* Splits a wp_mail() call with more than 40 bcc
* headers into multiple batches.
*
* Postmark only accepts 50 bcc, so this ensures the API call doesn't fail.
*
* @param array $args Original arguments passed to wp_mail().
* @return
*/
View enable-disable-plugins-when-doing-local-dev.php
<?php
/*
Plugin Name: Enable/Disable plugins when doing local dev
Plugin URL: https://gist.github.com/pbiron/52bb63042cf220256ece89bc07fb57b0
Description: If the WP_LOCAL_DEV constant is true, enables/disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Paul V. Biron/Sparrow Hawk Computing
Author URI: https://sparrowhawkcomputing.com
*/
@ollietreend
ollietreend / acf-php-to-json.php
Last active Nov 8, 2022
Convert Advanced Custom Fields Pro configuration from PHP to JSON.
View acf-php-to-json.php
<?php
/**
* Plugin Name: Convert ACF PHP to JSON
* Description: Convert Advanced Custom Fields Pro configuration from PHP to JSON.
*/
namespace ConvertAcfPhpToJson;
/**
* Add submenu item under 'Custom Fields'
@jchristopher
jchristopher / my.sql
Last active Oct 24, 2017
Get EDD Customer email and license key for Customers with ! 'active' Recurring subscriptions
View my.sql
# THIS IS NOT TESTED ENOUGH !!!!!!!!!!!!!!!!!! EXPECT INACCURACIES !!!!!!!!!!!!!!!!!!
# THIS IS CRAZY CRAZY SLOW
# ADJUST THE LIMIT ON LINE 20 ACCORDINGLY (READ: IF YOU DARE)
SELECT *
FROM (
SELECT
SUBSTRING_INDEX(SUBSTRING_INDEX(edd_customers.name, ' ', 1), ' ', -1) as firstname,
edd_customers.email AS email,
pm2.meta_value as license_key
FROM wp_edd_customers AS edd_customers
View post-receive
#!/bin/bash
#
## store the arguments given to the script
read oldrev newrev refname
## Where to store the log information about the updates
LOGFILE=./post-receive.log
# The deployed directory (the running site)
DEPLOYDIR=/directory/to/deploy/to
GITDIR=/directory/above/hooks/repo_name.git
@KeeperPat
KeeperPat / private.xml
Created Dec 30, 2016
Karabiner Configuration to Remap Surface Ergonomic Keyboard Alt and Windows Keys for Mac
View private.xml
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>Microsoft</vendorname>
<vendorid>0x045e</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>SurfaceErgonomic</productname>
<productid>0x0817</productid>