Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Don't update this plugin
*
* This prevents you from being prompted to update if there's a public plugin
* with the same name.
*
* @author Phil Wylie
* @link http://link.from.pw/1cFfcFZ
* @param array $r Request arguments
@mindctrl
mindctrl / readme.php
Last active August 29, 2015 14:01 — forked from sudar/readme.php
Automatically update a download's version number and change log using a readme.txt file with the Easy Digital Downloads Software Licensing extension.
<?php
/*
Plugin Name: EDD Readme Parsing Enhancements
Description: Updates a Download's current version and change log fields when using the readme.txt parsing feature in Easy Digital Downloads.
*/
/**
* Filters the EDD readme.txt parser response and updates the
* download's current version and change log fields.
*/
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
<?php
function ttf_get_make_stats() {
// Make remote request to WP.org
$response = wp_remote_post(
'http://api.wordpress.org/themes/info/1.0/',
array(
'body' => array(
'action' => 'theme_information',
'request' => serialize( (object) array(
<?php
/**
* Integrate Imager.js with WordPress
*
* Imager.js is BBC's solution for serving responsive and retina images, without
* the double payload issues that affect other solutions. For more information:
*
* https://github.com/BBC-News/Imager.js/
*
* This collection of functions modifies the output of WordPress's
function random_lipsum($amount = 1, $what = 'paras') {
$start = rand(0,30);
return simplexml_load_file("http://www.lipsum.com/feed/xml?amount=$amount&what=$what&start=$start")->lipsum;
}
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
@mindctrl
mindctrl / gist:78f215742ff307085ac9
Created January 3, 2015 15:09
Easy Digital Downloads - sort category and tag archives by title
function jp_sort_download_archives( $query ) {
if ( is_tax( array( 'download_category', 'download_tag' ) ) && $query->is_main_query() ):
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
endif;
}
add_action( 'pre_get_posts', 'jp_sort_download_archives' );
@mindctrl
mindctrl / gist:a102806b03587762a422
Created February 10, 2015 19:55
Removes the forced homepage redirect on the [edd_login] shortcode when using Marketify.
<?php
/**
* Remove the Marketify edd_login redirect
*/
function jp_fix_marketify_edd_shortcode() {
remove_filter( 'shortcode_atts_edd_login', 'marketify_shortcode_atts_edd_login' );
}
add_action( 'init', 'jp_fix_marketify_edd_shortcode' );
<?php
/**
* Plugin Name: Easy Digital Downloads - Change Purchase Receipt Heading
* Description: Changes the Default Template purchase receipt heading from "Purchase Receipt" to "Download Confirmation".
*/
function jp_filter_email_heading( $headers, $payment_id, $payment_data ) {
EDD()->emails->__set( 'heading', 'Download Confirmation' );
return $headers;
}