Jake Vanderwerf
2026-02-17 a24a06002081ad71a78ffeff9072725ba39cf121
inc/managers/DirectoryManager.php
@@ -38,7 +38,6 @@
      }
      add_action('init', [$this, 'registerDirectories']);
      jvb_register_do_once('directories_registered', [$this, 'activate']);
        add_action('render_block', [$this, 'renderBlock'], 99999, 3);
    }
@@ -66,7 +65,7 @@
         'public'              => true,
         'menu_icon'    => jvbCSSIcon('list-dashes'),
         'publicly_queryable'    => true,
         'show_in_menu'          => false,
         'show_in_menu'          => true,
         'show_in_admin_bar'     => false,
         'has_archive'           => true,
         'hierarchical'       => true,
@@ -128,16 +127,17 @@
   }
    public function activate()
    public static function activate()
    {
      $this->registerDirectories();
      $tmp = new self();
      $tmp->registerDirectories();
        $created = [];
        $directories = [];
      foreach($this->directories as $directory => $type) {
         $config = $this->getConfigFromType($directory);
         $title = $this->directoryTitle($config);
      foreach($tmp->directories as $directory => $type) {
         $config = $tmp->getConfigFromType($directory);
         $title = $tmp->directoryTitle($config);
         $excerpt = implode(' ', $config['description']??[]);
         $ID = wp_insert_post([
            'post_type' => BASE.'directory',
@@ -227,6 +227,33 @@
        }
    }
   protected function buildDirectoryList():array
   {
      $saved = get_option(BASE.'directory_list', []);
      if (empty($saved)) {
         $all = new WP_Query([
            'post_type' => BASE.'directory',
            'post_status'  => 'publish',
            'posts_per_page'  => -1,
         ]);
         foreach($all->posts as $post) {
            $saved[$post->post_name] = [
               'slug'   => $post->post_name,
               'title'  => $post->post_title,
               'ID'  => $post->ID,
               'url' => get_the_permalink($post->ID),
               'page'   => $post->post_title,
               'description'  => $this->getConfigFromType($post->post_name)['description']??'',
               'type'   => get_post_meta($post->ID, self::$type,true),
               'extra'  => $this->getConfigFromType($post->post_name)['directory_extra']??[],
            ];
         }
         update_option(BASE.'directory_list', $saved);
         wp_reset_postdata();
      }
      return $saved;
   }
   public function getDirectoryPageIDs():array
   {
      if (empty($this->directoryPageIDs)) {
@@ -237,7 +264,7 @@
   public function getDirectoryList():array
   {
      if (empty($this->directoryList)) {
         $this->directoryList = get_option(BASE.'directory_list', []);
         $this->directoryList = $this->buildDirectoryList();
      }
      return $this->directoryList;
   }