| | |
| | | <?php |
| | | namespace JVBase\managers; |
| | | |
| | | use JVBase\JVB; |
| | | use JVBase\managers\queue\Queue; |
| | | use WP_Post; |
| | | use WP_Term; |
| | | use WP_Query; |
| | |
| | | */ |
| | | class NewsRelationships |
| | | { |
| | | private string $table_name; |
| | | private CacheManager $cache; |
| | | protected Cache $cache; |
| | | |
| | | public function __construct() |
| | | { |
| | | global $wpdb; |
| | | $this->table_name = $wpdb->prefix . BASE . 'news_relationships'; |
| | | $this->cache = CacheManager::for('news_relationships', WEEK_IN_SECONDS); |
| | | $this->cache = Cache::for('news_relationships', WEEK_IN_SECONDS)->connect('post', true)->connect('taxonomy', true)->connect('user',true); |
| | | |
| | | // Register hooks |
| | | add_action('init', [$this, 'registerHooks']); |
| | |
| | | */ |
| | | public function handleLinkChange(int $meta_id, int $object_id, string $meta_key, string|null $meta_value = null):void |
| | | { |
| | | // Only proceed for BASE.'link' meta key |
| | | // Only proceed for BASE.'profile_link' meta key |
| | | if ($meta_key !== BASE . 'link') { |
| | | return; |
| | | } |
| | |
| | | * Get all artists with news post counts |
| | | * @return array |
| | | */ |
| | | public function getAllArtistsWithNews():int |
| | | public function getAllArtistsWithNews():array |
| | | { |
| | | global $wpdb; |
| | | |
| | |
| | | } |
| | | |
| | | // Update cache |
| | | $this->cache->delete($shop_id); |
| | | $this->cache->forget($shop_id); |
| | | |
| | | // Update shop total count |
| | | $this->updateShopTotal($shop_id); |
| | |
| | | ); |
| | | |
| | | // Update cache |
| | | $this->cache->delete($shop_id); |
| | | $this->cache->forget($shop_id); |
| | | } |
| | | |
| | | /** |
| | |
| | | $wpdb->query("TRUNCATE TABLE {$this->table_name}"); |
| | | |
| | | |
| | | JVB()->queue()->queueOperation( |
| | | Queue::getInstance()->queueOperation( |
| | | 'rebuild_news', |
| | | 0, |
| | | [ |
| | |
| | | } |
| | | |
| | | /** |
| | | * @param WP_Error $result |
| | | * @param WP_Error|array $result |
| | | * @param object $operation |
| | | * @param array $data |
| | | * |