mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Merge pull request #181 from woocommerce/PCP-158-mini-cart-button-size
Add button height setting for mini cart
This commit is contained in:
commit
1711628cf7
3 changed files with 32 additions and 0 deletions
|
@ -650,6 +650,7 @@ class SmartButton implements SmartButtonInterface {
|
|||
'shape' => $this->style_for_context( 'shape', 'mini-cart' ),
|
||||
'label' => $this->style_for_context( 'label', 'mini-cart' ),
|
||||
'tagline' => $this->style_for_context( 'tagline', 'mini-cart' ),
|
||||
'height' => $this->settings->has( 'button_mini-cart_height' ) && $this->settings->get( 'button_mini-cart_height' ) ? $this->normalize_height( (int) $this->settings->get( 'button_mini-cart_height' ) ) : 35,
|
||||
),
|
||||
'style' => array(
|
||||
'layout' => $this->style_for_context( 'layout', $this->context() ),
|
||||
|
@ -943,4 +944,21 @@ class SmartButton implements SmartButtonInterface {
|
|||
}
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value between 25 and 55.
|
||||
*
|
||||
* @param int $height The input value.
|
||||
* @return int The normalized output value.
|
||||
*/
|
||||
private function normalize_height( int $height ): int {
|
||||
if ( $height < 25 ) {
|
||||
return 25;
|
||||
}
|
||||
if ( $height > 55 ) {
|
||||
return 55;
|
||||
}
|
||||
|
||||
return $height;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1734,6 +1734,19 @@ return array(
|
|||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
'button_mini-cart_height' => array(
|
||||
'title' => __( 'Button Height', 'woocommerce-paypal-payments' ),
|
||||
'type' => 'number',
|
||||
'default' => '35',
|
||||
'desc_tip' => true,
|
||||
'description' => __( 'Add a value from 25 to 55.', 'woocommerce-paypal-payments' ),
|
||||
'screens' => array(
|
||||
State::STATE_PROGRESSIVE,
|
||||
State::STATE_ONBOARDED,
|
||||
),
|
||||
'requirements' => array(),
|
||||
'gateway' => 'paypal',
|
||||
),
|
||||
|
||||
'disable_cards' => array(
|
||||
'title' => __( 'Disable specific credit cards', 'woocommerce-paypal-payments' ),
|
||||
|
|
|
@ -315,6 +315,7 @@ class SettingsListener {
|
|||
$settings[ $key ] = isset( $raw_data[ $key ] );
|
||||
break;
|
||||
case 'text':
|
||||
case 'number':
|
||||
case 'ppcp-text-input':
|
||||
case 'ppcp-password':
|
||||
$settings[ $key ] = isset( $raw_data[ $key ] ) ? sanitize_text_field( $raw_data[ $key ] ) : '';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue