| | |
| | | } |
| | | |
| | | use JVBase\registry\PostTypeRegistrar; |
| | | use JVBase\managers\Cache; |
| | | use JVBase\utility\Features; |
| | | use WP_Block; |
| | | use WP_Query; |
| | |
| | | protected int $perPage; |
| | | protected static string $type = BASE.'for_type'; |
| | | protected static string $slug = BASE.'for_type_slug'; |
| | | protected CacheManager $cache; |
| | | protected Cache $cache; |
| | | |
| | | public function __construct($perPage = 100) |
| | | { |
| | |
| | | return; |
| | | } |
| | | $this->perPage = $perPage; |
| | | $this->cache = CacheManager::for('directory', WEEK_IN_SECONDS); |
| | | $this->cache = Cache::for('directory', WEEK_IN_SECONDS); |
| | | $this->cache->connect('post', true) |
| | | ->connect('taxonomy', true) |
| | | ->connect('user', true); |
| | | |
| | | if (JVB_TESTING) { |
| | | $this->cache->clear(); |
| | | $this->cache->flush(); |
| | | } |
| | | |
| | | foreach(['content','taxonomy','user'] as $key) { |
| | | if (array_key_exists($key, $this->directories)) { |
| | | $this->cache->connectTo($key); |
| | | } |
| | | } |
| | | |
| | | |
| | | add_action('init', [$this, 'registerDirectories']); |
| | | jvb_register_do_once('directories_registered', [$this, 'activate']); |
| | | add_action('render_block', [$this, 'renderBlock'], 99999, 3); |
| | |
| | | if ( $terms && ! is_wp_error( $terms ) ) { |
| | | $term = $terms[0]; |
| | | $extra[] = [ |
| | | 'name' => (get_term_meta( $term->term_id, BASE . 'singular', true ) !== '') ? get_term_meta( $term->term_id, BASE . 'singular', true ) : $term->name, |
| | | 'name' => (get_term_meta( $term->term_id, BASE . 'singular', true ) !== '') ? get_term_meta( $term->term_id, BASE . 'singular', true ) : html_entity_decode($term->name), |
| | | 'url' => get_term_link( $term->term_id, $item ), |
| | | 'id' => $term->term_id, |
| | | 'type' => $item, |
| | |
| | | |
| | | $list = $this->alphabetizeMe( |
| | | $list, |
| | | $term->name, |
| | | html_entity_decode($term->name), |
| | | get_term_link( $term->term_id, jvbCheckBase( $slug ) ), |
| | | $term->term_id, |
| | | $extra |
| | |
| | | $children =$this->renderListChunk($taxonomy, $term->term_id); |
| | | $out .= '<li>'; |
| | | if ($children !== '') { |
| | | $out .= '<details class="term"><summary class="row btw"><a href="'.get_term_link($term->term_id, $term->taxonomy).'" title="See more '.$term->name.'">'.$term->name.'</a></summary>'; |
| | | $out .= '<details class="term"><summary class="row btw"><a href="'.get_term_link($term->term_id, $term->taxonomy).'" title="See more '.html_entity_decode($term->name).'">'.$term->name.'</a></summary>'; |
| | | $out .= $children; |
| | | $out .= '</details>'; |
| | | } else { |
| | | $out .= '<a href="'.get_term_link($term->term_id, $term->taxonomy).'" title="See more '.$term->name.'">'.$term->name.'</a>'; |
| | | $out .= '<a href="'.get_term_link($term->term_id, $term->taxonomy).'" title="See more '.$term->name.'">'.html_entity_decode($term->name).'</a>'; |
| | | } |
| | | $out .= '</li>'; |
| | | } |