Last active
November 21, 2016 03:31
-
-
Save yousan/ab2ea7b3a43ecbb0f2c8205f1ef15d40 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
// https://codex.wordpress.org/Transients_API | |
// kショートコードをsキャッシうュるコード | |
add_shortcode('someshortcode', function() { | |
echo 'hoge'; | |
}); | |
add_shortcode('someshortcode_cached', function() { | |
if ( $ret = get_transient('someshortcode') ) { | |
return $ret; | |
} else { | |
$ret = do_shortcode( 'someshortcode' ); | |
set_transient('someshortcode_cached', $ret, 60); // 60 seconds | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment