| | |
| | | protected string $image; |
| | | protected string $header; |
| | | protected string $headerExtra; |
| | | protected bool $isOpen = false; |
| | | protected string $beforeSummary; |
| | | protected string $detailsTitle; |
| | | protected array $details; |
| | | |
| | |
| | | { |
| | | $this->cache = Cache::for('summary_block', WEEK_IN_SECONDS); |
| | | add_action('init', [ $this, 'registerBlock' ]); |
| | | add_action('wp_enqueue_scripts', [$this, 'enqueueScripts']); |
| | | if (JVB_TESTING) { |
| | | $this->cache->flush(); |
| | | } |
| | |
| | | ]); |
| | | } |
| | | |
| | | public function enqueueScripts():void |
| | | { |
| | | wp_enqueue_script('jvb-page-nav'); |
| | | } |
| | | |
| | | protected function getConfig():string |
| | | { |
| | | return (is_tax()) ? 'tax' : 'content'; |
| | |
| | | ); |
| | | $this->headerExtra = ($headerExtra === '') ? '' : '<div>'.$headerExtra.'</div>'; |
| | | |
| | | $this->beforeSummary = apply_filters( |
| | | 'jvbBeforeSummary', |
| | | '', |
| | | $this->getType() |
| | | ); |
| | | /** |
| | | * The HTML string that appears within the <summary> block |
| | | */ |
| | |
| | | $this->getType() |
| | | ); |
| | | |
| | | $this->isOpen = apply_filters( |
| | | 'jvbSummaryIsOpen', |
| | | false, |
| | | $this->getType() |
| | | ); |
| | | |
| | | /** |
| | | * The content of the <details> block. |
| | | * This should return either an empty array for no information (so no details block) |
| | |
| | | <?php endif; ?> |
| | | </header> |
| | | <?php |
| | | if (!empty($this->beforeSummary)) { |
| | | echo $this->beforeSummary; |
| | | } |
| | | } |
| | | |
| | | protected function renderDetails():void |
| | |
| | | if (empty($details)) { |
| | | return; |
| | | } |
| | | $open = $this->isOpen ? ' open' : ''; |
| | | ?> |
| | | <details class="info"> |
| | | <details class="info"<?=$open?>> |
| | | <summary class="row btw"><?= $this->detailsTitle ?></summary> |
| | | <?php |
| | | foreach ($this->details as $key => $details) { |
| | |
| | | if (empty($this->details)) { |
| | | return; |
| | | } |
| | | echo jvbOnThisPage(array_keys($this->details)); |
| | | $IDs = apply_filters('jvbSummaryOnThisPage', array_keys($this->details), $this->getType()); |
| | | echo jvbOnThisPage($IDs); |
| | | } |
| | | |
| | | protected function getType():string |