Skip to content

Instantly share code, notes, and snippets.

@maurobringolf
Last active January 15, 2017 15:51
Show Gist options
  • Save maurobringolf/da7c443ae56e47b3b5b5c6012af43c1f to your computer and use it in GitHub Desktop.
Save maurobringolf/da7c443ae56e47b3b5b5c6012af43c1f to your computer and use it in GitHub Desktop.
<?php
function get_remote_data( $slug ) {
$key = 'some-key-string';
if( !wp_cache_get( $key ) ) {
$response = wp_remote_get( $url );
//error handling
wp_cache_add( $key , $response );
return $response;
}
else {
return wp_cache_get( $key );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment