Last active
January 15, 2017 15:51
-
-
Save maurobringolf/da7c443ae56e47b3b5b5c6012af43c1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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