Created
December 12, 2012 02:38
-
-
Save aprakasa/4264387 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 | |
/** | |
* Using caching for theme options | |
* @link http://speckyboy.com/2011/12/14/website-speed-part-3-caching-wordpress/ | |
* / | |
function my_get_cache_option($option_name = 'ThemeAdminOptions' ){ | |
// get wanted transient | |
$value = get_transient( $option_name ); | |
// check if it has any content | |
if(false === $value){ | |
// if no content in the transient get new copy of wanted option | |
$value = get_option( $option_name ); | |
// set new transient with a refresh of 1 day | |
set_transient( $option_name, $value, 60*60*24 ); | |
} | |
// return the transient $value or newly created $value | |
return $value; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment