= 3600 ) { self::run(); } } public static function pending_deactivations() { $value = Settings::get( 'license_pending_deactivation', [] ); if ( ! is_array( $value ) ) { return []; } if ( isset( $value['key'], $value['site'] ) ) { $value = [ $value ]; } return array_values( array_filter( $value, static function( $record ) { return is_array( $record ) && ! empty( $record['key'] ) && ! empty( $record['site'] ); } ) ); } public static function run() { $pending = self::pending_deactivations(); $remaining = []; foreach ( $pending as $record ) { // A copied database must never release the original site's slot. if ( License_Client::site_hash( $record['site'] ) !== License_Client::site_hash( home_url() ) ) { $remaining[] = $record; continue; } $result = License_Client::deactivate( $record['key'], $record['site'] ); if ( ! $result['success'] ) { $remaining[] = $record; } } if ( $pending ) { Settings::set_license( [ 'license_pending_deactivation' => $remaining, 'license_last_verified' => time() ] ); } $key = Settings::get( 'license_key' ); if ( ! $key ) { return; } $was_valid = Settings::has_pro(); $result = License_Client::verify( $key, home_url() ); if ( $result['success'] ) { Settings::set_license( [ 'license_status' => 'active', 'license_plan' => $result['plan'], 'license_activation_limit' => $result['activation_limit'], 'license_site_hash' => $result['site_hash'], 'license_expires_at' => $result['expires_at'], 'license_last_error' => '', 'license_last_verified' => time(), 'license_last_validated' => time(), ] ); } else { Settings::set_license( [ 'license_status' => ! empty( $result['temporary'] ) && $was_valid ? 'active' : 'error', 'license_last_error' => $result['error'], 'license_last_verified' => time(), ] ); } } }