PCP-26 / introduce new password field for settings

This commit is contained in:
David Remer 2020-07-28 12:18:57 +03:00
parent 2af06b180e
commit 585d5350ff
3 changed files with 37 additions and 4 deletions

View file

@ -206,7 +206,7 @@ return [
],
'client_secret' => [
'title' => __('Secret Key', 'woocommerce-paypal-commerce-gateway'),
'type' => 'password',
'type' => 'ppcp-password',
'desc_tip' => true,
'description' => __('The secret key of your api', 'woocommerce-paypal-commerce-gateway'),
'default' => false,

View file

@ -51,13 +51,36 @@ class SettingsRenderer
class="%s"
name="%s"
>%s</select>',
implode(' ', $config['class']),
$key . '[]',
esc_attr(implode(' ', $config['class'])),
esc_attr($key) . '[]',
implode('', $options)
);
return $html;
}
public function renderPassword($field, $key, $config, $value): string
{
if ($config['type'] !== 'ppcp-password') {
return $field;
}
$html = sprintf(
'<input
type="password"
autocomplete="new-password"
class="%s"
name="%s"
value="%s"
>',
esc_attr(implode(' ', $config['class'])),
esc_attr($key),
esc_attr($value)
);
return $html;
}
//phpcs:enable Inpsyde.CodeQuality.ArgumentTypeDeclaration.NoArgumentType
public function render()

View file

@ -117,7 +117,17 @@ class WcGatewayModule implements ModuleInterface
/**
* @var SettingsRenderer $renderer
*/
return $renderer->renderMultiSelect($field, $key, $args, $value);
return $renderer->renderPassword(
$renderer->renderMultiSelect(
$field,
$key,
$args,
$value
),
$key,
$args,
$value
);
},
10,
4