Skip to content

Instantly share code, notes, and snippets.

@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.
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@mindctrl
mindctrl / gist:c7d27f504ed0eb281dc5
Created January 14, 2016 04:35 — forked from ericandrewlewis/gist:95239573dc97c0e86714
Setting up a WordPress site on AWS

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.

@mindctrl
mindctrl / wp_human_time_diff.php
Created May 7, 2016 13:53 — forked from BinaryMoon/wp_human_time_diff.php
Human Time Difference Function for WordPress
<?php
/**
* Display the post time in a human readable format
*
* @return string
*/
function carmack_human_time_diff() {
$post_time = get_the_time( 'U' );
$time_now = date( 'U' );
@mindctrl
mindctrl / plugin.php
Created September 10, 2016 17:21 — forked from logoscreative/plugin.php
Friendlier, Safer WordPress Admin Areas
<?php
/**
* "Friendlier, Safer WordPress Admin Areas"
* Presented by Cliff Seal at WordCamp Atlanta 2015 and Asheville 2016
* Slides: http://www.slideshare.net/cliffseal/wp-admin
*
* Plugin Name: A Better Admin Experience
* Plugin URI: http://evermoresites.com
* Description: Cleans up and sanitizes the WordPress admin area
* Version: 1.0