| | |
| | | <?php |
| | | namespace JVBase\blocks; |
| | | |
| | | use JVBase\managers\Cache; |
| | | use JVBase\managers\DirectoryManager; |
| | | use JVBase\registrar\Registrar; |
| | | use WP_Block; |
| | | use WP_Query; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | | } |
| | | class FAQBlock { |
| | | protected Cache $cache; |
| | | // protected Cache $cache; |
| | | protected string $postType; |
| | | protected string $section; |
| | | protected string $slug; |
| | | protected bool $isDirectory; |
| | | public function __construct() |
| | | { |
| | | $this->cache = Cache::for('faq_block', WEEK_IN_SECONDS)->connect('post', true)->connect('taxonomy', true); |
| | | // $this->cache = Cache::for('faq_block', 'post', WEEK_IN_SECONDS); |
| | | add_action('init', [ $this, 'registerBlock' ]); |
| | | add_action('enqueue_block_editor_assets', [$this, 'localizeData']); |
| | | } |
| | |
| | | /** |
| | | * Register the FAQ block |
| | | */ |
| | | public function registerBlock() { |
| | | public function registerBlock():void |
| | | { |
| | | // Register the block |
| | | register_block_type( |
| | | JVB_DIR . '/build/faq', |
| | |
| | | * @param WP_Block $block Block instance |
| | | * @return string Rendered block HTML |
| | | */ |
| | | public function render($attributes, $content, $block) |
| | | public function render(array $attributes, string $content, WP_Block $block):string |
| | | { |
| | | ob_start(); |
| | | ?> |
| | |
| | | } |
| | | $buttons = ''; |
| | | if ($this->isDirectory) { |
| | | $directory = JVB()->directories()->directories($this->slug); |
| | | $directory = DirectoryManager::getInstance()->directories($this->slug); |
| | | $url = $directory['url']??''; |
| | | if (!empty($url)) { |
| | | $buttons .= '<li><a href="'.$url.'">'.__('See Alphabetical List', 'jvb').'</a></li>'; |