mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Check if value allowed in configurator
This commit is contained in:
parent
3e35034832
commit
a87ca32a12
1 changed files with 10 additions and 4 deletions
|
@ -32,8 +32,8 @@ class ConfigFactory {
|
||||||
if ( in_array( $placement, array( 'category', 'homepage' ) ) ) {
|
if ( in_array( $placement, array( 'category', 'homepage' ) ) ) {
|
||||||
$config = array(
|
$config = array(
|
||||||
'layout' => 'flex',
|
'layout' => 'flex',
|
||||||
'color' => $this->get_or_default( $settings, "pay_later_{$location}_message_flex_color", 'black' ),
|
'color' => $this->get_or_default( $settings, "pay_later_{$location}_message_flex_color", 'black', array( 'black', 'blue', 'white', 'white-no-border' ) ),
|
||||||
'ratio' => $this->get_or_default( $settings, "pay_later_{$location}_message_flex_ratio", '8x1' ),
|
'ratio' => $this->get_or_default( $settings, "pay_later_{$location}_message_flex_ratio", '8x1', array( '8x1', '20x1' ) ),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$config = array(
|
$config = array(
|
||||||
|
@ -70,7 +70,13 @@ class ConfigFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_or_default( Settings $settings, string $key, $default ) {
|
private function get_or_default( Settings $settings, string $key, $default, ?array $allowed_values = null ) {
|
||||||
return $settings->has( $key ) ? $settings->get( $key ) : $default;
|
if ( $settings->has( $key ) ) {
|
||||||
|
$value = $settings->get( $key );
|
||||||
|
if ( ! $allowed_values || in_array( $value, $allowed_values, true ) ) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue