Skip to content

Instantly share code, notes, and snippets.

@zevilz
Created August 12, 2019 10:22
Show Gist options
  • Save zevilz/70598baa0fc23ac9f33783ab54595b75 to your computer and use it in GitHub Desktop.
Save zevilz/70598baa0fc23ac9f33783ab54595b75 to your computer and use it in GitHub Desktop.
Function for get cached carbon fields option or get it if it not isset in cache
<?php
/**
* Gets cached carbon fields option or get it if it not isset in cache
*
* @param string $option Option name
*
* @return mixed
*/
function carbon_get_theme_option_cached( $option ) {
$option_value = wp_cache_get( $option, 'crb_options' );
if ( false === $option_value ) {
$option_value = carbon_get_theme_option( $option );
wp_cache_set( $option, $option_value, 'crb_options' );
}
return $option_value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment