From 3b83905603d44b1a08f8b2b36a605808ce686ad6 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 02 Jun 2026 00:46:48 +0000
Subject: [PATCH] =double checking schema outputs for legacytattooremoval

---
 inc/blocks/FeedBlock.php |   88 ++++++++++++++++++++++++++++++--------------
 1 files changed, 60 insertions(+), 28 deletions(-)

diff --git a/inc/blocks/FeedBlock.php b/inc/blocks/FeedBlock.php
index 3ed2f38..3693d93 100644
--- a/inc/blocks/FeedBlock.php
+++ b/inc/blocks/FeedBlock.php
@@ -7,6 +7,7 @@
 use JVBase\forms\TaxonomySelector;
 use JVBase\ui\CRUDSkeleton;
 use WP_Block;
+use WP_Query;
 
 if (!defined('ABSPATH')) {
 	exit;
@@ -20,6 +21,9 @@
 
 	protected array $content = [];
 	protected array $taxonomies = [];
+	protected ?string $context = null;
+	protected ?int $contextID = null;
+
 	protected bool $isGallery = false;
 
 	public function __construct()
@@ -53,13 +57,15 @@
 		$classes = '';
 
 		return sprintf(
-			'<section class="feed-block%s" data-content="%s"%s>
+			'<section class="feed-block%s" data-content="%s"%s%s%s>
 			%s%s%s%s%s
 			<footer>%s</footer>
 			</section>',
 			$classes,
 			$this->getContent(),
 			$this->isGallery ? ' data-gallery' : '',
+			is_null($this->context) ? '' : ' data-context="'.$this->context.'"',
+			is_null($this->contextID) ? '' : ' data-context-id="'.$this->contextID.'"',
 			$this->renderFiltersAndControls(),
 			$this->renderGrid(),
 			$this->renderTemplates(),
@@ -80,6 +86,9 @@
 				global $post;
 				$author = $post->post_author;
 				$role = jvbUserRole($author);
+
+				$this->context = jvbNoBase($role);
+				$this->contextID = $author;
 				$registrar = Registrar::getInstance($role);
 				if (!$registrar) {
 					return;
@@ -88,6 +97,8 @@
 				return;
 			} elseif (is_tax()) {
 				$obj = get_queried_object();
+				$this->context = jvbNoBase($obj->taxonomy);
+				$this->contextID = $obj->term_id;
 				$registrar = Registrar::getInstance($obj->taxonomy);
 				if (!$registrar) {
 					return;
@@ -133,7 +144,7 @@
 	protected function renderFiltersAndControls():string
 	{
 		return sprintf(
-			'<details class="all-filters col top left" data-ignore open>
+			'<details class="all-filters col top left" data-ignore>
 			<summary>Filters %s</summary>
 			%s%s%s%s%s
 			</details>
@@ -159,23 +170,11 @@
 		}
 		protected function renderContentLabels():string
 		{
-			$inside = '';
-			if (count($this->content) === 1) {
-				return '';
-			}
-			foreach ($this->content as $i => $type) {
-				$active = $i === 0 ? ' class="active"' : '';
-				$inside .= sprintf(
-					'<li id="filter-%s"%s>%s</li>',
-					$type,
-					$active,
-					Registrar::getInstance($type)->getPlural()??''
-				);
-			}
 			return sprintf(
-				'<ul class="filter-label">%s</ul>',
-				$inside
+				'<span class="label">Showing: <span class="current">%s</span></span>',
+				$this->content[0]??''
 			);
+
 		}
 		protected function renderContent():string
 		{
@@ -191,7 +190,7 @@
 			if (count($this->content) === 1) {
 				return empty($favourites)
 					? sprintf(
-						'<input type="hidden" name="content" value="%s">',
+						'<input type="hidden" data-filter="content" name="content" value="%s">',
 						implode(',', $this->content)
 					)
 					: sprintf(
@@ -205,23 +204,55 @@
 			}
 			$i = 0;
 			$content = implode('', array_map(function($type) use (&$i) {
-				$i++;
 				$registrar = Registrar::getInstance($type);
+
+				$args = [
+					'post_type'	=> $registrar->getBased(),
+					'posts_per_page'	=> 1,
+					'fields'	=> 'ids',
+				];
+				if (!is_null($this->context)) {
+
+					$context = Registrar::getInstance($this->context);
+					switch ($context->getType()) {
+						case 'term':
+							$args['tax_query'] = [];
+							$args['tax_query'][] = [
+								'taxonomy'	=> $context->getBased(),
+								'terms'		=> $this->contextID
+							];
+							break;
+						case 'user':
+							$args['author'] = $this->contextID;
+							break;
+					}
+				}
+				$check = new WP_Query($args);
+				$hasPosts = !empty($check->posts);
+
+				$disabled = !$hasPosts;
+				$checked = $i === 0 && $hasPosts;
+				if ($hasPosts) {
+					$i++;
+				}
 				return sprintf(
 					'<input type="radio"
 					id="filter-%s"
 					class="btn"
 					name="content"
 					data-filter="content"
-					value="%s"%s>
-					<label for="filter-%s" title="Show %s">%s<span class="screen-reader-text">%s</span></label>',
+					data-label="%s"
+					value="%s"%s%s>
+					<label for="filter-%s" title="Show %s">%s<span class="label">%s</span></label>',
 					$type,
+					$registrar->getSingular(),
 					$type,
-					$i === 0 ? ' checked' : '',
+					$checked ? ' checked' : '',
+					$disabled ? ' disabled' : '',
 					$type,
-					$registrar->getPlural(),
+					$registrar->getSingular(),
 					jvbIcon($registrar->getIcon()),
-					$registrar->getPlural()
+					$registrar->getSingular()
 				);
 			}, $this->content));
 
@@ -267,9 +298,9 @@
 			}, $this->taxonomies)));
 			return sprintf(
 				'<div class="taxonomies row left">
-				<div class="row top nowrap">
-				<span class="label">Filter By:</span>
-				<div class="row left">%s</div>
+				<div class="row top wrap">
+					<span class="label">Filter By:</span>
+					%s
 				</div>
 				<div class="selected-items-section">
 					<div class="selected-items row left"></div>
@@ -314,6 +345,7 @@
 				'icon'	=> 'shuffle',
 				'label'	=> 'Randomly'
 			];
+
 			$custom = implode(',', array_map(function($ord) {
 				return $ord['slug'];
 			}, $custom));
@@ -382,7 +414,7 @@
 			);
 
 			return sprintf(
-				'<div class="ordering row left nowrap">%s%s</div>',
+				'<div class="ordering row top left nowrap">%s%s</div>',
 				$orderby,
 				$order
 			);

--
Gitblit v1.10.0