ID ) ) { return; } $grants = AgentAdapt_Grants::for_user( (int) $user->ID ); $desc = AgentAdapt_Signin::descriptions(); echo '

' . esc_html__( 'Connected personal agents', 'agent-adapt' ) . '

'; if ( ! AgentAdapt_Eligibility::eligible( (int) $user->ID ) ) { echo '

' . esc_html__( 'Personal agents cannot sign in to this account: it is not a customer account, or it has store management permissions.', 'agent-adapt' ) . '

'; } if ( ! $grants ) { echo '

' . esc_html__( 'No personal agent is connected to this account.', 'agent-adapt' ) . '

'; return; } echo ''; foreach ( array( __( 'Agent', 'agent-adapt' ), __( 'Client ID', 'agent-adapt' ), __( 'It can', 'agent-adapt' ), __( 'Connected', 'agent-adapt' ), __( 'Last used', 'agent-adapt' ), __( 'Access until', 'agent-adapt' ) ) as $h ) { echo ''; } echo ''; foreach ( $grants as $g ) { $client_id = (string) $g['client_id']; $domain = (string) wp_parse_url( $client_id, PHP_URL_HOST ); $can = array_map( static fn( $s ) => $desc[ $s ] ?? $s, array_filter( explode( ' ', (string) $g['scope'] ) ) ); echo ''; echo ''; echo ''; echo ''; echo ''; /* translators: %s: human time difference */ echo ''; echo ''; echo ''; } echo '
' . esc_html( $h ) . '
' . esc_html( '' !== (string) $g['name'] ? (string) $g['name'] : $domain ) . '' . esc_html( $client_id ) . '' . esc_html( implode( '; ', $can ) ) . '' . esc_html( wp_date( get_option( 'date_format' ), (int) $g['created'] ) ) . '' . esc_html( sprintf( __( '%s ago', 'agent-adapt' ), human_time_diff( (int) $g['last_used'] ) ) ) . '' . esc_html( wp_date( get_option( 'date_format' ), (int) $g['expires'] ) ) . '
'; echo '

' . esc_html__( 'The customer can disconnect an agent from My Account โ†’ Connected agents. Changing the account\'s password or email address disconnects them all.', 'agent-adapt' ) . '

'; } }