wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_connectors_parse_application_password_credentials › WordPress Function

Seit7.1.0
Veraltetn/v
wp_connectors_parse_application_password_credentials ( $value )
Zugriff:
  • private
Parameter:
  • (string) $value The raw credentials string.
    Erforderlich: Ja
Gibt zurück:
  • (array{username: string, password: string}) Parsed credentials. Both values
    are empty when the string is malformed.
Definiert in:
Codex:

Parses a `username:password` credentials string.

Splits on the first colon, matching the HTTP Basic authentication userinfo format, so passwords may contain colons.


Quellcode

function wp_connectors_parse_application_password_credentials( string $value ): array {
	$separator = strpos( $value, ':' );
	// Trim so surrounding whitespace or a trailing newline (common when the
	// value comes from a file or `.env`) does not become part of the credentials.
	$username = false === $separator ? '' : trim( substr( $value, 0, $separator ) );
	$password = false === $separator ? '' : trim( substr( $value, $separator + 1 ) );

	if ( '' === $username || '' === $password ) {
		return array(
			'username' => '',
			'password' => '',
		);
	}

	return array(
		'username' => $username,
		'password' => $password,
	);
}