| | |
| | | exit; |
| | | } |
| | | |
| | | use JVBase\Instance; |
| | | use JVBase\integrations\services\Umami; |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\base\Site; |
| | | use WP_Block; |
| | |
| | | |
| | | class DirectoryManager |
| | | { |
| | | use Instance; |
| | | protected array $directories; |
| | | protected array $directoryPageIDs; |
| | | protected array $directoryList; |
| | |
| | | protected static string $slug = BASE.'for_type_slug'; |
| | | protected Cache $cache; |
| | | |
| | | public function __construct($perPage = 100) |
| | | private function __construct($perPage = 100) |
| | | { |
| | | $this->directories = $this->getDirectories(); |
| | | if (empty($this->directories)) { |
| | |
| | | } |
| | | $this->perPage = $perPage; |
| | | $this->cache = Cache::for('directory', WEEK_IN_SECONDS); |
| | | $this->cache->connect('post', true) |
| | | ->connect('taxonomy', true) |
| | | ->connect('user', true); |
| | | |
| | | if (JVB_TESTING) { |
| | | $this->cache->flush(); |
| | | } |
| | | |
| | | |
| | | jvb_register_do_once('buildDirectories', [$this, 'activate']); |
| | | add_action('init', [$this, 'registerDirectories']); |
| | | add_filter('pre_render_block', [$this, 'renderBlock'], 20, 3); |
| | | add_action('save_post', [$this, 'flushPostCache']); |
| | | add_action('edit_terms', [$this, 'flushPostCache']); |
| | | } |
| | | |
| | | public function flushPostCache(int $postID):void |
| | | { |
| | | //TODO: We can probably use a bit more finesse here. |
| | | $this->cache->flush(); |
| | | } |
| | | |
| | | public function registerDirectories():void |
| | | { |
| | | |
| | |
| | | 'public' => true, |
| | | 'menu_icon' => jvbCSSIcon('list-dashes'), |
| | | 'publicly_queryable' => true, |
| | | 'show_in_menu' => true, |
| | | 'show_in_menu' => false, |
| | | 'show_in_admin_bar' => false, |
| | | 'has_archive' => true, |
| | | 'hierarchical' => true, |
| | |
| | | public function renderLettersList(array $list, string $type):string |
| | | { |
| | | |
| | | $umami = JVB()->connect('umami'); |
| | | $umami = Umami::getInstance(); |
| | | |
| | | $out = '<ul class="list-none">'; |
| | | foreach ($list as $letter => $items) { |