Skip to content

Instantly share code, notes, and snippets.

@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')
);
<?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 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
*/
@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;
@ianmjones
ianmjones / build-as3cf-aws2.sh
Last active April 18, 2024 16:05
A script for downloading the AWS PHP SDK v2, stripping down to S3 functionality and then applying a custom namespace.
#!/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 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
@Rarst
Rarst / headings.less
Created July 14, 2017 16:08
Less mixin to calculate vertical rhythm styling for headings [in Bootstrap]. Don’t ask me how this works because I don’t remember and this made my brain hurt enough.
.heading-line-height( @line-height ) when ( @line-height < 1 ) {
line-height: unit(@line-height * 2, em);
}
.heading-line-height( @line-height ) when ( @line-height >= 1 ) {
line-height: unit(@line-height, em);
}
.heading-rhythm ( @font-size-base, @font-size-increase ) {
@heading-font-size: @font-size-base * @font-size-increase;
@markjaquith
markjaquith / readme.md
Last active June 11, 2017 15:19
For WordPress, a method to re-index a multi-dimensional array by the (unique) value of a given array key

Okay, so, let's say you have some data like this:

$things = [
  0 => [ 'id' => 123, 'title' => '123 Title', 'content' => '123 Content' ],
  1 => [ 'id' => 456, 'title' => '456 Title', 'content' => '456 Content' ],
  2 => [ 'id' => 789, 'title' => '789 Title', 'content' => '789 Content' ],
];
@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
@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
*