| | |
| | | $this->cache->clear(); |
| | | $this->checker = Checker::getInstance(); |
| | | |
| | | if (jvbSiteUsesUmami()) { |
| | | if (Features::hasIntegration('umami')) { |
| | | $this->tracker = JVB()->connect('umami'); |
| | | } |
| | | $this->setupCacheConnections(); |
| | |
| | | $item['taxonomies'] = array_merge($item['taxonomies'], $this->extractTaxonomies($f, $postID, jvbNoBase($post->post_type))); |
| | | $images[$f['post_thumbnail']] = jvbImageData((int) $f['post_thumbnail']); |
| | | } |
| | | $item['fields']['number'] = count($children); |
| | | $item['fields']['before'] = get_post_thumbnail_id($children[0]); |
| | | $item['fields']['after'] = get_post_thumbnail_id($children[array_key_last($children)]); |
| | | |
| | | $item['fields']['timeline'] = $subFields; |
| | | $item['images'] = $item['images'] + $images; |
| | |
| | | protected function extractTaxonomies(array $fields, int $postID, string $content):array { |
| | | $taxonomies = []; |
| | | foreach ($fields as $key => $value) { |
| | | if (array_key_exists($key, JVB_TAXONOMY)) { |
| | | $terms = array_map('absint', explode(',',$value)); |
| | | foreach($terms as $termID) { |
| | | $term = get_term($termID, jvbCheckBase($key)); |
| | | if ($term && !is_wp_error($term)) { |
| | | $taxonomies[$key][$termID] = $this->formatTaxonomy($term, $postID, $content); |
| | | } |
| | | if (empty($value)) { |
| | | continue; |
| | | } |
| | | if (!array_key_exists($key, JVB_TAXONOMY)) { |
| | | continue; |
| | | } |
| | | |
| | | $taxConfig = JVB_TAXONOMY[$key]; |
| | | if (isset($taxConfig['public']) && $taxConfig['public'] === false) { |
| | | continue; |
| | | } |
| | | $terms = array_map('absint', explode(',', $value)); |
| | | $terms = array_filter($terms); // Remove 0 values |
| | | |
| | | if (empty($terms)) { |
| | | continue; |
| | | } |
| | | foreach($terms as $termID) { |
| | | $term = get_term($termID, jvbCheckBase($key)); |
| | | if ($term && !is_wp_error($term)) { |
| | | $taxonomies[$key][$termID] = $this->formatTaxonomy($term, $postID, $content); |
| | | } |
| | | } |
| | | } |
| | |
| | | return $cache->remember( |
| | | 'feed_link_'.$term->term_id, |
| | | function () use ($term, $postID, $type) { |
| | | return [ |
| | | $base = [ |
| | | 'ID' => $term->term_id, |
| | | 'title' => htmlspecialchars_decode($term->name), |
| | | 'url' => get_term_link($term->term_id, $term->taxonomy), |
| | | 'umami_click' => $this->tracker->trackTaxonomyClick($term->term_id, $term->taxonomy, [ |
| | | 'from' => $type . '_' . $postID |
| | | ]) |
| | | ]; |
| | | if ($this->tracker) { |
| | | $base['umami_click'] =$this->tracker->trackTaxonomyClick($term->term_id, $term->taxonomy, [ |
| | | 'from' => $type . '_' . $postID |
| | | ]); |
| | | } |
| | | return $base; |
| | | } |
| | | ); |
| | | } |
| | |
| | | $args = $this->applyOrderFilters($args, $data); |
| | | $args = $this->applyDateFilters($args, $data); |
| | | |
| | | $args = $this->applyFavouritesFilter($args, $data); |
| | | return $args; |
| | | return $this->applyFavouritesFilter($args, $data); |
| | | } |
| | | |
| | | protected function applyTaxonomyFilters(array $args, array $data): array |