private function mark_job_post_completed($job_post_id, $flush_cache = true) { // If called before `init`, we need to modify directly because post types aren't registered earlier if (did_action('init')) { wp_trash_post($job_post_id); } else { global $wpdb; $wpdb->update($wpdb->posts, array('post_status' => self::POST_STATUS_COMPLETED), array('ID' => $job_post_id)); wp_add_trashed_suffix_to_post_name_for_post($job_post_id); $this->posts_to_clean[] = $job_post_id; } // Delete internal cache // Should only be skipped when deleting duplicates, as they are excluded from the cache if ($flush_cache) { wp_cache_delete(self::CACHE_KEY); } return true; }