Jake Vanderwerf
2026-08-30 a58a2e7ca4700d3e23341fde767060a4c2c704a3
inc/blocks/FeedBlock.php
@@ -6,8 +6,6 @@
use JVBase\registrar\Registrar;
use JVBase\base\Site;
use JVBase\forms\TaxonomySelector;
use JVBase\ui\CRUDSkeleton;
use WP_Block;
use WP_Query;
if (!defined('ABSPATH')) {
@@ -32,12 +30,6 @@
   public function __construct()
   {
//    // Initialize cache with connections
//    $this->cache = Cache::for('feed_block','post', WEEK_IN_SECONDS);
//    if (JVB_TESTING) {
//       $this->cache->flush();
//    }
      add_action('init', [$this, 'registerBlock']);
   }
@@ -800,97 +792,94 @@
      if (!$isTemplate && empty($value)) {
         return '';
      }
      switch ($fieldName) {
         case 'post_title':
            return sprintf(
               '<h3%s>%s</h3>',
               $data,
               $meta && !empty($value) ? $value : '',
            );
         case 'post_date':
         case 'post_modified':
            return sprintf(
               '<time%s%s>%s</time>',
               $data,
               $meta && !empty($value) ? date('c', strtotime($value)) : '',
               $meta && !empty($value) ? date('F j, Y', strtotime($value)) : '',
            );
      }
      return match ($fieldType) {
         'date' => sprintf(
      return match ($fieldName) {
         'post_title' => sprintf(
            '<h3%s>%s</h3>',
            $data,
            $meta && !empty($value) ? $value : '',
         ),
         'post_date', 'post_modified' => sprintf(
            '<time%s%s>%s</time>',
            $data,
            $meta && !empty($value) ? date('c', strtotime($value)) : '',
            $meta && !empty($value) ? date('F j, Y', strtotime($value)) : '',
         ),
         'datetime' => sprintf(
            '<time%s%s>%s</time>',
            $data,
            $meta && !empty($value) ? date('c', strtotime($value)) : '',
            $meta && !empty($value) ? date('F j, Y at h:iA', strtotime($value)) : '',
         ),
         'time' => sprintf(
            '<time%s%s>%s</time>',
            $data,
            $value,
            $value
         ),
         'upload' => empty($value) ? sprintf(
            '<img%s width="300px" height="300px" loading="lazy" decoding="async">',
            $data
         ) :
            str_replace('<img', '<img' . $data, jvbFormatImage($value)),
         'selector' => sprintf(
            '<ul%s class="terms %s">%s</ul>',
            $data,
            $config['taxonomy']??$config['post_type']??$config['role']??'',
            empty($value) ? sprintf('<li><a>%s</a></li>',
               $this->iconFor($config)
         default => match ($fieldType) {
            'date' => sprintf(
               '<time%s%s>%s</time>',
               $data,
               $meta && !empty($value) ? date('c', strtotime($value)) : '',
               $meta && !empty($value) ? date('F j, Y', strtotime($value)) : '',
            ),
            'datetime' => sprintf(
               '<time%s%s>%s</time>',
               $data,
               $meta && !empty($value) ? date('c', strtotime($value)) : '',
               $meta && !empty($value) ? date('F j, Y at h:iA', strtotime($value)) : '',
            ),
            'time' => sprintf(
               '<time%s%s>%s</time>',
               $data,
               $value,
               $value
            ),
            'upload' => empty($value) ? sprintf(
               '<img%s width="300px" height="300px" loading="lazy" decoding="async">',
               $data
            ) :
               implode('', array_filter(array_map(function ($ID) use ($config) {
                  $type = $config['subtype'];
                  $taxonomy = isset($config['taxonomy']) ? jvbCheckBase($config['taxonomy']) : '';
               str_replace('<img', '<img' . $data, jvbFormatImage($value)),
            'selector' => sprintf(
               '<ul%s class="terms %s">%s</ul>',
               $data,
               $config['taxonomy'] ?? $config['post_type'] ?? $config['role'] ?? '',
               empty($value) ? sprintf('<li><a>%s</a></li>',
                  $this->iconFor($config)
               ) :
                  implode('', array_filter(array_map(function ($ID) use ($config) {
                     $type = $config['subtype'];
                     $taxonomy = isset($config['taxonomy']) ? jvbCheckBase($config['taxonomy']) : '';
                  $item = match ($type) {
                     'taxonomy' => get_term($ID, $taxonomy),
                     'user' => get_userdata($ID),
                     'post' => get_post($ID),
                     default => false,
                  };
                     $item = match ($type) {
                        'taxonomy' => get_term($ID, $taxonomy),
                        'user' => get_userdata($ID),
                        'post' => get_post($ID),
                        default => false,
                     };
                  if (!$item || is_wp_error($item)) {
                     return '';
                  }
                     if (!$item || is_wp_error($item)) {
                        return '';
                     }
                  $icon = $this->iconFor($config);
                     $icon = $this->iconFor($config);
                  $name = match ($type) {
                     'taxonomy' => $item->name,
                     'user' => $item->display_name,
                     'post' => $item->post_title,
                     default => '',
                  };
                  $url = match ($type) {
                     'taxonomy' => get_term_link((int)$ID, $taxonomy),
                     'user' => get_the_permalink(get_user_meta($ID, BASE . 'userLink', true)),
                     'post' => get_the_permalink($ID),
                     default => ''
                  };
                  return sprintf(
                     '<li><a href="%s">%s%s</a></li>',
                     $url,
                     !empty($icon) ? jvbIcon($icon) : '',
                     $name
                  );
               }, explode(',', $value))))
         ),
         default => sprintf(
            '<p%s>%s</p>',
            $data,
            $value
         ),
                     $name = match ($type) {
                        'taxonomy' => $item->name,
                        'user' => $item->display_name,
                        'post' => $item->post_title,
                        default => '',
                     };
                     $url = match ($type) {
                        'taxonomy' => get_term_link((int)$ID, $taxonomy),
                        'user' => get_the_permalink(get_user_meta($ID, BASE . 'userLink', true)),
                        'post' => get_the_permalink($ID),
                        default => ''
                     };
                     return sprintf(
                        '<li><a href="%s">%s%s</a></li>',
                        $url,
                        !empty($icon) ? jvbIcon($icon) : '',
                        $name
                     );
                  }, explode(',', $value))))
            ),
            default => sprintf(
               '<p%s>%s</p>',
               $data,
               $value
            ),
         },
      };
   }
   protected function iconFor(array $fieldConfig):string
   {