pre_bootstrap_tasks = $pre_bootstrap_tasks; $this->post_bootstrap_tasks = $post_bootstrap_tasks; $this->db = $db; } /** * Attempt to execute any pre bootstrap tasks. * * WARNING: This runs BEFORE WordPress is fully bootstrapped, so not all WP functions are available. * * @return void */ public function run_pre_bootstrap_tasks(): void { foreach ( $this->pre_bootstrap_tasks as $task ) { if ( ! $task->should_run() ) { continue; } $task->run(); } } /** * Attempt to execute any post bootstrap tasks. * * @action plugins_loaded * * @return void */ public function run_post_bootstrap_tasks(): void { foreach ( $this->post_bootstrap_tasks as $task ) { if ( ! $task->should_run() ) { continue; } $this->should_flush = true; $task->run(); } } /** * Clear the key/value store if any of the post bootstrap tasks ran. * * @action shutdown * @action solidwp/performance/terminate * * @return void */ public function terminate(): void { if ( ! $this->should_flush ) { return; } // Terminable shutdown runs twice, we only need this once. $this->should_flush = false; $this->db->flush(); } }