mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
PCP-26 / introduce new password field for settings
This commit is contained in:
parent
2af06b180e
commit
585d5350ff
3 changed files with 37 additions and 4 deletions
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue