function genesis_get_option( $key, $setting = null, $use_cache = true ) { // The default is set here, so it doesn't have to be repeated in the function arguments for genesis_option() too. $setting = $setting ?: GENESIS_SETTINGS_FIELD; // Allow child theme to short circuit this function. $pre = apply_filters( "genesis_pre_get_option_{$key}", null, $setting ); if ( null !== $pre ) { return $pre; } // Bypass cache if viewing site in Customizer. if ( genesis_is_customizer() ) { $use_cache = false; } // If we need to bypass the cache. if ( ! $use_cache ) { $options = get_option( $setting ); if ( ! is_array( $options ) || ! array_key_exists( $key, $options ) ) { return ''; } return is_array( $options[ $key ] ) ? $options[ $key ] : wp_kses_decode_entities( $options[ $key ] ); } // Setup caches. static $settings_cache = []; static $options_cache = []; // Check options cache. if ( isset( $options_cache[ $setting ][ $key ] ) ) { // Option has been cached. return $options_cache[ $setting ][ $key ]; } // Check settings cache. if ( isset( $settings_cache[ $setting ] ) ) { // Setting has been cached. $options = apply_filters( 'genesis_options', $settings_cache[ $setting ], $setting ); } else { // Set value and cache setting. $settings_cache[ $setting ] = apply_filters( 'genesis_options', get_option( $setting ), $setting ); $options = $settings_cache[ $setting ]; } // Check for non-existent option. if ( ! is_array( $options ) || ! array_key_exists( $key, (array) $options ) ) { // Cache non-existent option. $options_cache[ $setting ][ $key ] = ''; } else { // Option has not previously been cached, so cache now. $options_cache[ $setting ][ $key ] = is_array( $options[ $key ] ) ? $options[ $key ] : wp_kses_decode_entities( $options[ $key ] ); } return $options_cache[ $setting ][ $key ]; }