Skip to content

Instantly share code, notes, and snippets.

@bradyvercher
bradyvercher / register-plugin-icons.php
Created October 4, 2017 22:30
Register icons to display on the Manage Plugins screen for plugins that aren't in the WordPress.org directory.
<?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
@davekiss
davekiss / gist:e2b5beb37b3a1a93a3dddcf43ce51ce9
Created September 18, 2018 18:33
Display notice in EDD if email already exists and not logged in
/**
* 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;
@brianhogg
brianhogg / gist:b87c216dde537ecaccdc5063858d0c3f
Last active October 30, 2018 21:16 — forked from davekiss/gist:e2b5beb37b3a1a93a3dddcf43ce51ce9
Display notice in EDD if email already exists and not logged in
<?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
*/
<?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 ) {
@spivurno
spivurno / gw-edd-could-not-copy-file-fix-for-windows-servers.php
Created February 2, 2017 16:18
Easy Digital Downloads: "Could not copy file" Fix For Windows Servers
<?php
/**
* Easy Digital Downloads provides packages URLs that look something like this:
*
* http://mysite.com/edd-sl/package_download/MTQ4NjA1NTA0NjphMDA5MTkzZjQ0NGRiNmVmMzczY2JhNTFiZWIxMWZiYzo0NzM3MzphM2Q5ZDA3NDQwMjZjZDFmOWVhYTBiNzBjMjVlZjI0YjpodHRwQC8vbXVzaWNmZXN0aXZhbC5zY2hvb2wubno
*
* This generates a temporary filename for the update process that look something like this:
*
* MTQ4NjA1NTA0NjphMDA5MTkzZjQ0NGRiNmVmMzczY2JhNTFiZWIxMWZiYzo0NzM3MzphM2Q5ZDA3NDQwMjZjZDFmOWVhYTBiNzBjMjVlZjI0YjpodHRwQC8vbXVzaWNmZXN0aXZhbC5zY2hvb2wubno.tmp
*
@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;
}
@davekiss
davekiss / gist:2639184ac066c53416b23c5a66f42d1e
Created February 2, 2019 17:44
EDD Weekly Domain Report via Email
/**
* 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')
);
@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
@jjeaton
jjeaton / .gitignore
Created August 5, 2015 01:54
WordPress root .gitignore. Ignore everything and then opt-in (exclude from the ignore) for your custom code.
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@claygriffiths
claygriffiths / resize_local_machine.sh
Last active November 6, 2020 03:45 — forked from joost/resize_boot2docker.sh
Resize Local by Flywheel VirtualBox image
# Steps we will take:
# 1. Change Local (Docker Machine) image type (this will take a bit)
# 2. Resize image
# 3. Resize partion
#
# Also see: https://docs.docker.com/articles/b2d_volume_resize/
# IMPORTANT: Make sure Local is not running!
VM_NAME="local-by-flywheel"
NEW_DISK_SIZE=50000