| | |
| | | <?php |
| | | namespace JVBase\rest\routes; |
| | | |
| | | use JVBase\base\Site; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\rest\Rest; |
| | | use JVBase\integrations\Umami; |
| | | use JVBase\rest\Route; |
| | | use JVBase\base\Site; |
| | | use WP_Query; |
| | | use Umami; |
| | | use WP_Post; |
| | | use WP_Term; |
| | | use WP_Query; |
| | | use WP_REST_Request; |
| | | use WP_REST_Response; |
| | | use WP_Term; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; // Exit if accessed directly |
| | |
| | | 'context' => 'string', |
| | | 'contextId' => 'string', |
| | | 'favourites' => 'boolean', |
| | | 'user' => 'integer', |
| | | 'highlight' => 'string', |
| | | ]) |
| | | ->auth('public') |
| | |
| | | 'context' => 'string', |
| | | 'contextId' => 'string', |
| | | 'favourites' => 'boolean', |
| | | 'user' => 'integer', |
| | | 'highlight' => 'string', |
| | | ]) |
| | | ->auth('public') |
| | |
| | | : explode(',', $args['post_type']); |
| | | |
| | | // Check if filtering global feed content |
| | | if (in_array(jvbNoBase($context['type']), Registrar::getFeatured('is_content', 'term'))) { |
| | | if (in_array(jvbNoBase($context['type']), Registrar::withFeature('is_content', 'term'))) { |
| | | // Global: show posts from any content type with this taxonomy |
| | | $for_content = Registrar::getInstance($context['type'])->registrar->for ?? []; |
| | | |
| | |
| | | $post_types = array_map(fn($type) => jvbCheckBase($type), $for_content); |
| | | |
| | | // Filter to only show_feed content types |
| | | $show_feed_types = Registrar::getFeatured('show_feed', 'post'); |
| | | $show_feed_types = Registrar::withFeature('show_feed', 'post'); |
| | | $args['post_type'] = array_intersect( |
| | | $post_types, |
| | | array_map(fn($type) => jvbCheckBase($type), $show_feed_types) |
| | |
| | | */ |
| | | protected function applyFavouritesFilter(array $args, array $data): array |
| | | { |
| | | if (empty($data['favourites']) || empty($data['user'])) { |
| | | if (empty($data['favourites'])) { |
| | | return $args; |
| | | } |
| | | |
| | | $user_id = (int)$data['user']; |
| | | $user_id = get_current_user_id(); |
| | | if (!$user_id) { |
| | | //Shouldn't happen, but whatever |
| | | return $args; |
| | | } |
| | | $content = jvbNoBase($args['post_type']); |
| | | |
| | | // Get user's favourites for this content type |
| | |
| | | $config = []; |
| | | |
| | | // Get content types with show_feed |
| | | $contentTypes = Registrar::getFeatured('show_feed', 'post'); |
| | | $contentTypes = Registrar::withFeature('show_feed', 'post'); |
| | | foreach ($contentTypes as $slug) { |
| | | $this->cache->tag('content:'.$slug); |
| | | $registrar = Registrar::getInstance($slug); |
| | |
| | | } |
| | | |
| | | // Get taxonomies with show_feed (content taxonomies) |
| | | $taxonomies = Registrar::getFeatured('show_feed', 'term'); |
| | | $taxonomies = Registrar::withFeature('show_feed', 'term'); |
| | | foreach ($taxonomies as $slug) { |
| | | $registrar = Registrar::getInstance($slug); |
| | | if (!$registrar || !($registrar->hasFeature('is_content') ?? false)) { |