| | |
| | | <?php |
| | | namespace JVBase\blocks; |
| | | |
| | | use JVBase\managers\CacheManager; |
| | | use JVBase\forms\TaxonomySelector; |
| | | use JVBase\meta\MetaManager; |
| | | use JVBase\managers\Cache; |
| | | use WP_Block; |
| | | use WP_Query; |
| | | |
| | |
| | | |
| | | class GlossaryBlock |
| | | { |
| | | protected CacheManager $cache; |
| | | protected Cache $cache; |
| | | protected string $config; |
| | | protected string $type; |
| | | protected string $path = JVB_DIR . '/build/glossary'; |
| | |
| | | |
| | | public function __construct() |
| | | { |
| | | $this->cache = CacheManager::for('glossary_terms', WEEK_IN_SECONDS)->connectTo('post', 'terms'); |
| | | $this->cache = Cache::for('glossary_terms', WEEK_IN_SECONDS)->connect('post', true); |
| | | add_action('init', [ $this, 'registerBlock' ]); |
| | | } |
| | | |
| | |
| | | public function render(array $attributes, string $content, WP_Block $block) |
| | | { |
| | | $cache = $this->cache->get('all'); |
| | | $cache = false; |
| | | if ($cache) { |
| | | return $cache; |
| | | } |
| | |
| | | 'post_status' => 'publish', |
| | | 'orderby' => 'title', |
| | | 'order' => 'asc', |
| | | // 'fields' => 'ids' |
| | | ]); |
| | | $glossary = []; |
| | | if ($posts->have_posts()) { |
| | | foreach($posts->posts as $post) { |
| | | // $meta = new MetaManager($post, 'post'); |
| | | // $meta = Meta::forPost($post); |
| | | // $fields = $meta->getAll(); |
| | | // $glossary[$fields['post_slug']] = $fields; |
| | | $glossary[$post->post_name] = [ |