From 474109a5df0a06f5343ab184838fe2d80e3872a8 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 11 Jan 2026 19:23:20 +0000
Subject: [PATCH] =Fixed timeline CRUD.js issue where this.activeItem was set null when we still needed it

---
 inc/managers/SEO/SchemaOutputManager.php |   63 +++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/inc/managers/SEO/SchemaOutputManager.php b/inc/managers/SEO/SchemaOutputManager.php
index 051eeb7..140716b 100644
--- a/inc/managers/SEO/SchemaOutputManager.php
+++ b/inc/managers/SEO/SchemaOutputManager.php
@@ -50,6 +50,69 @@
 
 		// Output our schema
 		add_action('wp_head', [$this, 'outputSchema'], 1);
+		add_filter('the_seo_framework_sitemap_exclude_ids', [$this, 'excludeHiddenSingles'], 10, 1);
+	}
+
+	/**
+	 * Exclude posts from sitemap based on hide_single and is_timeline flags
+	 *
+	 * @param array $ids Array of post IDs to exclude
+	 * @return array Modified array with hidden posts added
+	 */
+	public function excludeHiddenSingles(array $ids): array
+	{
+		$hiddenTypes = [];
+		$timelineTypes = [];
+
+		// Find post types with hide_single or is_timeline flags
+		foreach (JVB_CONTENT as $slug => $config) {
+			$postType = BASE . $slug;
+
+			if (!empty($config['hide_single'])) {
+				$hiddenTypes[] = $postType;
+			}
+
+			if (!empty($config['is_timeline'])) {
+				$timelineTypes[] = $postType;
+			}
+		}
+
+		$hiddenIds = [];
+
+		// Get all posts from hide_single types
+		if (!empty($hiddenTypes)) {
+			$hiddenIds = $this->cache->remember(
+				'hidden_single_posts',
+				function() use ($hiddenTypes) {
+					return get_posts([
+						'post_type' => $hiddenTypes,
+						'posts_per_page' => -1,
+						'fields' => 'ids',
+						'post_status' => 'publish',
+					]);
+				}
+			);
+		}
+
+		// Get child posts from timeline types
+		if (!empty($timelineTypes)) {
+			$timelineChildIds = $this->cache->remember(
+				'timeline_child_posts',
+				function() use ($timelineTypes) {
+					return get_posts([
+						'post_type' => $timelineTypes,
+						'posts_per_page' => -1,
+						'fields' => 'ids',
+						'post_status' => 'publish',
+						'post_parent__not_in' => [0], // Only get posts with a parent
+					]);
+				}
+			);
+
+			$hiddenIds = array_merge($hiddenIds, $timelineChildIds);
+		}
+
+		return array_merge($ids, $hiddenIds);
 	}
 
 	/**

--
Gitblit v1.10.0