reveal(); } /** * Store a secret. * * @param string $name Secret name. * @param string $value Plaintext value. * * @return true|\WP_Error */ public function set( string $name, string $value ) { return wp_set_secret( $name, $value ); } /** * Delete a secret. * * @param string $name Secret name. * * @return true|\WP_Error */ public function delete( string $name ) { return wp_delete_secret( $name ); } /** * Names of this plugin's secrets. * * @return string[] */ public function list_names(): array { $listing = wp_list_secrets( AO_Secrets::NAMESPACE_PREFIX ); if ( is_wp_error( $listing ) || ! is_array( $listing ) ) { return []; } // Each entry is ['name' => ..., 'fingerprint' => ..., ...]; a corrupted record is still listed. $names = array_column( $listing, 'name' ); return array_values( array_filter( array_map( 'strval', $names ) ) ); } /** * Whether the active provider accepts writes. * * @return bool */ public function is_writable(): bool { return ! function_exists( 'wp_secrets_provider_is_writable' ) || wp_secrets_provider_is_writable(); } /** * Description of the active provider. * * @return string */ public function label(): string { return function_exists( 'wp_secrets_provider_label' ) ? wp_secrets_provider_label() : 'WordPress Secrets API'; } }