> $rich Rich license list; loads from storage when empty. * * @return void */ public static function schedule_license_expiry( array $rich = [] ): void { if ( ! function_exists( 'as_schedule_single_action' ) || ! function_exists( 'as_unschedule_all_actions' ) ) { return; } if ( [] === $rich ) { if ( ! License::has_stored_licenses() ) { return; } $rich = License::get_licenses(); } $now = time(); foreach ( License::normalize_list( $rich ) as $row ) { $key = trim( (string) ( $row['licenseKey'] ?? '' ) ); if ( '' === $key ) { continue; } $ts = License_Utils::license_expiry_timestamps( $row ); $args = [ $key ]; foreach ( Constants::LICENSE_EXPIRY_CRONS as $hook => $level ) { as_unschedule_all_actions( $hook, $args, Constants::CRON_GROUP_ADVANCED_ADS ); $t = $ts[ $level ] ?? 0; if ( $t > $now ) { as_schedule_single_action( $t, $hook, $args, Constants::CRON_GROUP_ADVANCED_ADS ); } } } } /** * Run a scheduled license expiry action for one license key — refreshes the license from the shop, then either sets an admin notice flag (one month / ten days) or syncs local expiry state after the grace period. * * @param string $license_key License key (Action Scheduler passes indexed args). * * @return void */ public function run_license_expiry( string $license_key ): void { $key = trim( $license_key ); $level = Constants::LICENSE_EXPIRY_CRONS[ current_action() ] ?? null; if ( '' === $key || null === $level ) { return; } $rich = License::get_licenses(); if ( null === License_Utils::get_rich_license_row_by_key( $rich, $key ) ) { return; } $rich = License::sync_persisted_license_from_shop( $key ); $row = License_Utils::get_rich_license_row_by_key( $rich, $key ); if ( null === $row ) { return; } if ( 'grace' === $level ) { if ( ! License_Utils::license_expiry_is_future( $row ) ) { License::sync_local_expiry( $rich, $key ); } return; } if ( License_Utils::license_expiry_is_future( $row ) && License_Utils::is_license_expiring_soon( $row ) ) { License_Utils::update_expiry_notices( $key, $level ); } } }