Skip to content

Instantly share code, notes, and snippets.

View Hube2's full-sized avatar

John A. Huebner II Hube2

View GitHub Profile
<?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
/*
* Plugin Name: Query Thief
* Description: Hijacking the main WordPress query and loop for fun and profit
* Version: 0.1
*/
// I namespace everything now that PHP 5.2.4 is the minimum requirement. :D
namespace JPB;
<?php
add_filter( 'posts_request', 'pre_db_hit' );
function pre_db_hit( $request )
{
global $diy_cache_current_request;
$diy_cache_current_request = $request;
// use request string to see if expired...