Skip to content

Instantly share code, notes, and snippets.

@aubreypwd
Last active January 3, 2016 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aubreypwd/8513348 to your computer and use it in GitHub Desktop.
Save aubreypwd/8513348 to your computer and use it in GitHub Desktop.
Example of how to use filters on your returns.
<?php
// Differentiate whether we need to load from
// cache or get live results.
function gdurl_googapi_cache($s){
// First see if we have cached data (15 seconds?)
$gdurl_transient = get_transient( 'gdurl_googapi_cache' );
if( isset($gdurl_transient[$s]) ){
return apply_filters(
__FUNCTION__,
$gdurl_transient[$s]
);
}else{
return apply_filters(
__FUNCTION__,
gdurl_googapi_set_cache($s)
);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment