wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_connectors_sanitize_application_password_credentials is private and should not be used in themes or plugins directly.
wp_connectors_sanitize_application_password_credentials › WordPress Function
Seit7.1.0
Veraltetn/v
› wp_connectors_sanitize_application_password_credentials ( $value, $option = '' )
| Zugriff: |
|
| Parameter: (2) |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Sanitizes stored application-password credentials for a connector.
Credential fields that are missing or not strings keep their currently stored values, so partial updates cannot silently clear a stored secret. A password matching the mask that_wp_connectors_rest_settings_dispatch()
places in REST responses also keeps the stored password, so a masked
settings response can be submitted back to the endpoint unchanged.
Pass an empty string to clear a field.
If the sanitized username is empty, both fields are discarded so partial
credentials cannot leave an orphaned secret.Quellcode
function wp_connectors_sanitize_application_password_credentials( $value, string $option = '' ): array {
if ( ! is_array( $value ) ) {
$value = array();
}
if ( '' === $option ) {
$option = str_replace( 'sanitize_option_', '', (string) current_filter() );
}
$stored = get_option( $option );
if ( ! is_array( $stored ) ) {
$stored = array();
}
$credentials = array();
foreach ( array( 'username', 'password' ) as $field ) {
if ( isset( $value[ $field ] ) && is_string( $value[ $field ] ) ) {
$credentials[ $field ] = sanitize_text_field( $value[ $field ] );
} else {
$credentials[ $field ] = isset( $stored[ $field ] ) && is_string( $stored[ $field ] ) ? $stored[ $field ] : '';
}
}
// A masked password means a client resubmitted a masked REST response.
if ( str_repeat( "\u{2022}", 16 ) === $credentials['password'] ) {
$credentials['password'] = isset( $stored['password'] ) && is_string( $stored['password'] ) ? $stored['password'] : '';
}
if ( '' === $credentials['username'] ) {
return array(
'username' => '',
'password' => '',
);
}
return $credentials;
}