cleanupExpiredTokens(); ( new RefreshTokenRepository() )->cleanupExpiredTokens(); ( new SingleUseTokenRepository() )->cleanup_expired(); /** * Days a client may sit without any token before it is deleted. 0 keeps them. * * @since 1.5.0 * * @param int $days Default 7. */ $days = (int) apply_filters( 'albert/oauth/stale_client_days', 7 ); if ( $days > 0 ) { ( new ClientRepository() )->delete_stale_clients( $days ); } } catch ( \Throwable $e ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch // Never let a cron failure surface to the site. } } /** * Schedule the daily cleanup if not already scheduled. * * @return void * @since 1.4.0 */ public static function schedule(): void { if ( ! wp_next_scheduled( self::HOOK ) ) { wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', self::HOOK ); } } /** * Unschedule the daily cleanup. * * @return void * @since 1.4.0 */ public static function unschedule(): void { $timestamp = wp_next_scheduled( self::HOOK ); while ( $timestamp !== false ) { wp_unschedule_event( $timestamp, self::HOOK ); $timestamp = wp_next_scheduled( self::HOOK ); } } }