| | |
| | | namespace JVBase\managers; |
| | | |
| | | use Exception; |
| | | use JVBase\Instance; |
| | | use WP_Error; |
| | | use WP_Post; |
| | | use WP_Query; |
| | |
| | | |
| | | class TaxonomyRelationships |
| | | { |
| | | use Instance; |
| | | protected Cache $cache; |
| | | protected CustomTable $relationships; |
| | | |
| | | public function __construct() |
| | | private function __construct() |
| | | { |
| | | $this->defineTables(); |
| | | |
| | | $this->cache = Cache::for('term_relationship', WEEK_IN_SECONDS); |
| | | $this->cache->connect('terms'); |
| | | $this->cache = Cache::for('term_relationship', 'term', WEEK_IN_SECONDS); |
| | | |
| | | // Ensure the table exists |
| | | // $this->create_table_if_not_exists(); |
| | |
| | | { |
| | | |
| | | $term_posts = $this->cache->remember( |
| | | $this->cache->generateKey(['term' => $term_id, 'taxonomy' => $taxonomy]), |
| | | ['id' => $term_id, 'taxonomy' => $taxonomy], |
| | | function () use ($term_id, $taxonomy) { |
| | | global $wpdb; |
| | | return $wpdb->get_col($wpdb->prepare( |
| | |
| | | |
| | | |
| | | $related_term_posts = $this->cache->remember( |
| | | $this->cache->generateKey(['term' => $related_term_id, 'taxonomy' => $related_taxonomy]), |
| | | ['id' => $related_term_id, 'taxonomy' => $related_taxonomy], |
| | | function () use($related_term_id, $related_taxonomy) { |
| | | global $wpdb; |
| | | return $wpdb->get_col($wpdb->prepare( |
| | |
| | | |
| | | |
| | | // Queue the operation |
| | | $queue = JVB()->queue(); |
| | | $queue = Queue::getInstance(); |
| | | |
| | | $queue->queueOperation( |
| | | 'taxonomy_relationships', |