unschedule(); return; } add_action( 'action_scheduler_init', [ $this, 'unschedule' ] ); } /** * Removes the retired action from the queue. Public because it doubles as the deferred callback. * * @since 5.0.1 * * @return void */ public function unschedule() { if ( empty( aioseo()->actionScheduler ) ) { return; } aioseo()->actionScheduler->unschedule( $this->actionName ); } /** * {@inheritdoc} * * NOTE: reads the queue straight from the Action Scheduler table, since the procedural API is * off limits at preLoad() time. A missing table means there is no queue to clean. * * @since 5.0.1 */ public function verify() { $db = aioseo()->core->db->db; $tableName = $db->prefix . 'actionscheduler_actions'; $tableExists = $db->get_var( $db->prepare( 'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = %s', $tableName ) ); if ( empty( $tableExists ) ) { return true; } $pending = $db->get_var( $db->prepare( "SELECT COUNT(*) FROM {$tableName} WHERE hook = %s AND status IN ('pending', 'in-progress')", $this->actionName ) ); return empty( $pending ); } }