wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_connectors_get_application_password_credentials is private and should not be used in themes or plugins directly.
wp_connectors_get_application_password_credentials › WordPress Function
Seit7.1.0
Veraltetn/v
› wp_connectors_get_application_password_credentials ( $auth )
| Zugriff: |
|
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Resolves application-password credentials for a connector.
Checks in order: environment variable, PHP constant, database. The environment variable and constant are only checked when their respective names are provided, and must contain the credentials as a singleusername:password string. A non-empty environment variable or constant
that cannot be parsed as username:password is reported with
_doing_it_wrong() and ignored, so resolution falls through to the next
source.Quellcode
function wp_connectors_get_application_password_credentials( array $auth ): array {
// Check environment variable first.
$env_var_name = $auth['env_var_name'] ?? '';
if ( '' !== $env_var_name ) {
$env_value = getenv( $env_var_name );
if ( false !== $env_value && '' !== $env_value ) {
$credentials = wp_connectors_parse_application_password_credentials( $env_value );
if ( '' !== $credentials['username'] && '' !== $credentials['password'] ) {
$credentials['source'] = 'env';
return $credentials;
}
_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: %s: Environment variable name. */
__( 'The %s environment variable must contain application password credentials in "username:password" format.' ),
esc_html( $env_var_name )
),
'7.1.0'
);
}
}
// Check PHP constant.
$constant_name = $auth['constant_name'] ?? '';
if ( '' !== $constant_name && defined( $constant_name ) ) {
$const_value = constant( $constant_name );
if ( is_string( $const_value ) && '' !== $const_value ) {
$credentials = wp_connectors_parse_application_password_credentials( $const_value );
if ( '' !== $credentials['username'] && '' !== $credentials['password'] ) {
$credentials['source'] = 'constant';
return $credentials;
}
_doing_it_wrong(
__FUNCTION__,
sprintf(
/* translators: %s: PHP constant name. */
__( 'The %s constant must contain application password credentials in "username:password" format.' ),
esc_html( $constant_name )
),
'7.1.0'
);
}
}
// Check database.
$stored = get_option( $auth['setting_name'] ?? '', array() );
$username = is_array( $stored ) && isset( $stored['username'] ) && is_string( $stored['username'] ) ? $stored['username'] : '';
$password = is_array( $stored ) && isset( $stored['password'] ) && is_string( $stored['password'] ) ? $stored['password'] : '';
return array(
'username' => $username,
'password' => $password,
'source' => '' !== $username && '' !== $password ? 'database' : 'none',
);
}