| | |
| | | <?php |
| | | |
| | | use JVBase\managers\CacheManager; |
| | | use JVBase\managers\Cache; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | */ |
| | | function jvbRenderHours(int $ID, JVBase\Meta\MetaManager $meta):string |
| | | { |
| | | $cache = CacheManager::for('hours-'.$ID, WEEK_IN_SECONDS)->connectTo('taxonomy'); |
| | | $key = 'hours_display'; |
| | | $cached = $cache->get($key); |
| | | $cache = Cache::for('hours_display', WEEK_IN_SECONDS)->connect('taxonomy')->connect('post')->connect('user'); |
| | | |
| | | $cached = $cache->get($ID); |
| | | |
| | | if ($cached !== false) { |
| | | return $cached; |
| | | } |
| | | |
| | | if (!$meta) { |
| | | if (term_exists((int)$ID)) { |
| | | if (term_exists($ID)) { |
| | | $type = 'term'; |
| | | } elseif (get_post_status((int)$ID)) { |
| | | } elseif (get_post_status($ID)) { |
| | | $type = 'post'; |
| | | } else { |
| | | $type = 'user'; |
| | |
| | | $out .= '<p class="hours-notes"><small>' . implode(' • ', $notes) . '</small></p>'; |
| | | } |
| | | |
| | | $cache->set($key, $out); |
| | | $cache->set($ID, $out); |
| | | return $out; |
| | | } |
| | | |