Skip to content

Instantly share code, notes, and snippets.

View rafflepress-invent-your-own.php
<?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 Apr 2, 2020
Bash oneliner to delete tweets
View delete_tweets.sh
#!/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
View Fortress.Options.php
<?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 Aug 15, 2019
Prevent EDD Software Licensing Recurring renewal when associated subscription is failing
View functions.php
<?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;
}
@davekiss
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')
);
View functions.php
<?php
// Quick and dirty *AUTOMATIC* upgrade-only discount for EDD (no discount code)
class SearchwpUpgradeDiscount {
private $upgrade_discount = 30; // 30% discount
private $applicable = false;
function __construct() {
add_filter( 'edd_get_cart_content_details_item_discount_amount', function( $discount, $item ) {
@brianhogg
brianhogg / gist:b87c216dde537ecaccdc5063858d0c3f
Last active Oct 30, 2018 — forked from davekiss/gist:e2b5beb37b3a1a93a3dddcf43ce51ce9
Display notice in EDD if email already exists and not logged in
View gist:b87c216dde537ecaccdc5063858d0c3f
<?php
/*
Plugin Name: EDD Prompt Login On Checkout
Plugin URI: http://brianhogg.com/
Description: Prompt login if email exists
Author: Dave Kiss
Version: 1.0.0
Author URI: http://brianhogg.com
License: GPL2
*/
@davekiss
davekiss / gist:e2b5beb37b3a1a93a3dddcf43ce51ce9
Created Sep 18, 2018
Display notice in EDD if email already exists and not logged in
View gist:e2b5beb37b3a1a93a3dddcf43ce51ce9
/**
* Redirect the user to the appropriate page upon login.
*/
add_filter( 'login_redirect', function( $url, $query, $user ) {
if ( is_wp_error( $user ) ) {
return $url;
}
if ( current_user_can('administrator') ) {
return $url;
@ianmjones
ianmjones / build-as3cf-aws2.sh
Last active Feb 27, 2021
A script for downloading the AWS PHP SDK v2, stripping down to S3 functionality and then applying a custom namespace.
View build-as3cf-aws2.sh
#!/usr/bin/env bash
set -e
if [ ! -d src/amazon-s3-and-cloudfront ]; then
echo 'This script must be run from the repository root.'
exit 1
fi
for PROG in composer find sed
@bradyvercher
bradyvercher / register-plugin-icons.php
Created Oct 4, 2017
Register icons to display on the Manage Plugins screen for plugins that aren't in the WordPress.org directory.
View register-plugin-icons.php
<?php
/**
* Register plugin icons.
*
* WordPress 4.9 introduced icons in the list table on the Manage Plugins
* screen. The icons are pulled from the W.org update API. If an icon isn't
* available, a generic plugin Dashicon is shown instead.
*
* @param array $value Plugin update data.
* @return array