| | |
| | | |
| | | error_log('Final Args: '.print_r($args, true)); |
| | | |
| | | // Determine content type(s) for cache checking |
| | | $content_types = []; |
| | | if (!empty($data['content'])) { |
| | | $content_types[] = $data['content']; |
| | | } |
| | | if (!empty($data['type'])) { |
| | | $types = is_array($data['type']) ? $data['type'] : [$data['type']]; |
| | | $content_types = array_merge($content_types, $types); |
| | | } |
| | | // Check HTTP cache headers first |
| | | $cache_check = $this->checkHeaders($request, $content_types ?: ['feed']); |
| | | if ($cache_check) { |
| | | return $cache_check; // Returns 304 Not Modified |
| | | } |
| | | |
| | | $key = $this->cache->generateKey($args); |
| | | $cached = $this->cache->get($key); |
| | |
| | | $args['highlight'] = $highlight; |
| | | } |
| | | $cached['items'] = $this->processHighlightedItem($cached['items'], $args); |
| | | return new WP_REST_Response($cached); |
| | | $response = new WP_REST_Response($cached); |
| | | return $this->addCacheHeaders($response); |
| | | } |
| | | // Fetch and format items |
| | | $items = $this->fetchFeedItems($args); |
| | |
| | | } |
| | | |
| | | $items['items'] = $this->processHighlightedItem($items['items'], $args); |
| | | return new WP_REST_Response($items); |
| | | $response = new WP_REST_Response($items); |
| | | return $this->addCacheHeaders($response); |
| | | } |
| | | |
| | | /** |