From de699440ff94e9c0d8e8b5201ee93179c085bf60 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 01 Jan 2026 20:51:26 +0000
Subject: [PATCH] =Timeline fields in feedroutes.php
---
inc/rest/routes/FeedRoutes.php | 48 +++++++++++++++++++++++-------------------------
1 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/inc/rest/routes/FeedRoutes.php b/inc/rest/routes/FeedRoutes.php
index daadec6..d37feea 100644
--- a/inc/rest/routes/FeedRoutes.php
+++ b/inc/rest/routes/FeedRoutes.php
@@ -32,17 +32,17 @@
$this->cache_name = 'feed';
$this->cache_ttl = 86400;
parent::__construct();
+ $this->cache->clear();
}
public function init():void
{
+ $this->cache->clear();
$this->checker = Checker::getInstance();
if (jvbSiteUsesUmami()) {
$this->tracker = JVB()->connect('umami');
}
-
- $this->cache->clear();
$this->setupCacheConnections();
}
@@ -111,9 +111,9 @@
if (!$post || is_wp_error($post)) {
return [];
}
-
- return $cache->remember($postID,
- function() use ($postID, $type, $metaType, $post, $skip) {
+//
+// return $cache->remember($postID,
+// function() use ($postID, $type, $metaType, $post, $skip) {
$config = null;
switch ($metaType) {
case 'post':
@@ -150,10 +150,10 @@
return $field['type'] === 'taxonomy';
});
foreach ($temp as $key => $config) {
- if (array_key_exists($key, $out) && $out[$key] !== '') {
- $IDs = array_map('absint', explode(',', $out[$key]));
+ if (array_key_exists($key, $out['fields']) && $out['fields'][$key] !== '') {
+ $IDs = array_map('absint', explode(',', $out['fields'][$key]));
$data = [];
- $icon = JVB_TAXONOMY[$config['taxonomy']]['icon']??'triangle';
+ $icon = JVB_TAXONOMY[$config['taxonomy']]['icon']??jvbDefaultIcon();
foreach ($IDs as $ID) {
$term = get_term($ID, jvbCheckBase($config['taxonomy']));
if ($term && !is_wp_error($term)) {
@@ -179,9 +179,10 @@
$temp = array_filter($fields, function($field) {
return in_array($field['type'], [ 'upload', 'image', 'gallery']);
});
+
foreach ($temp as $key => $config) {
- if (array_key_exists($key, $out) && $out[$key] !== '') {
- $IDs = array_map('absint', explode(',',$out[$key]));
+ if (array_key_exists($key, $out['fields']) && $out['fields'][$key] !== '') {
+ $IDs = array_map('absint', explode(',',$out['fields'][$key]));
foreach ($IDs as $ID) {
$imgIDs[$ID] = jvbImageData($ID);
}
@@ -191,7 +192,7 @@
$out['id'] = $postID;
$out['content'] = $type;
- $out['icon'] = $config['icon']??'triangle';
+ $out['icon'] = $config['icon']??jvbDefaultIcon();
if ($this->tracker) {
$args = ($metaType === 'post') ? ['owner_id' => $post->post_author] : [];
@@ -214,12 +215,14 @@
$out['url'] = get_the_permalink($postID);
break;
}
- return $out;
- }
- );
-
+// return $out;
+// }
+// );
+ return $out;
}
+
+
protected function initTimelineFields(string $content):void
{
$content = jvbNoBase($content);
@@ -270,7 +273,7 @@
$images[$f['post_thumbnail']] = jvbImageData((int) $f['post_thumbnail']);
}
- $item['fields']['order'] = $subFields;
+ $item['fields']['timeline'] = $subFields;
$item['images'] = $item['images'] + $images;
return $item;
@@ -336,7 +339,6 @@
protected function buildRequestArgs(WP_REST_Request $request): array
{
$data = $request->get_params();
- error_log('Feed Request: ' . print_r($data, true));
$args = [
'post_type' => (array_key_exists($data['content'], $this->buildFeedTypesConfig())) ?
BASE . $data['content'] :
@@ -353,13 +355,15 @@
]
);
}
+ if (array_key_exists('taxonomy', $data) && is_string($data['taxonomy'])) {
+ $data['taxonomy'] = json_decode($data['taxonomy'], true);
+ }
$args = $this->applyContextFilters($args, $data);
$args = $this->applyTaxonomyFilters($args, $data);
$args = $this->applyOrderFilters($args, $data);
$args = $this->applyDateFilters($args, $data);
$args = $this->applyFavouritesFilter($args, $data);
- error_log('Final Args: '.print_r($args, true));
return $args;
}
@@ -420,7 +424,7 @@
if ($cache_check) {
return $cache_check; // Returns 304 Not Modified
}
- error_log('Feed Request Args: '.print_r($args, true));
+
$key = $this->cache->generateKey($args);
$cached = $this->cache->get($key);
if ($cached) {
@@ -435,9 +439,6 @@
// Fetch and format items
$items = $this->fetchFeedItems($args);
- error_log('Feed Got items: ' .print_r($items, true));
-
-
$ttl = (str_contains($args['orderby'], 'RAND')) ? 1800 : $this->cache_ttl;
$this->cache->set($key, $items, $ttl);
@@ -533,7 +534,6 @@
*/
protected function processHighlightedItem(array $items, array $data): array
{
- error_log('Data passed to processHighlightedItem:' . print_r($data, true));
if (empty($data['highlight'] ?? null)) {
return $items;
}
@@ -624,7 +624,6 @@
if (!array_key_exists('favourites', $filters)) {
return $args;
}
- error_log('Proceeding to check for favourites:');
global $wpdb;
// Get post types for the current filter
@@ -634,7 +633,6 @@
$favourites_table = $wpdb->prefix . BASE . 'favourites';
$placeholders = implode(',', array_fill(0, count($post_types), '%s'));
- error_log('CurrentUser ID: ' . print_r(get_current_user_id(), true));
$favourited_ids = $wpdb->get_col($wpdb->prepare(
"SELECT target_id FROM {$favourites_table}
WHERE user_id = %d AND type IN ($placeholders)",
--
Gitblit v1.10.0