| @@ -4,8 +4,10 @@ | ||
| 4 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | +use ABlocks\Helper; | |
| 9 | + | |
| 8 | 10 | abstract class ControlBaseAbstractTwo { |
| 9 | 11 | abstract public static function get_attribute_default_value( $args ); |
| 10 | 12 | abstract public static function get_attribute( $args ); |
| 11 | 13 | abstract public static function get_css( $args ); |
| @@ -16,11 +18,11 @@ | ||
| 16 | 18 | $device = $args['device']; |
| 17 | 19 | $keyPrefix = $args['attributeObjectKey'] . 'Unit'; |
| 18 | 20 | |
| 19 | 21 | // Retrieve units with fallback to default |
| 20 | - $unitDesktop = $value[ $keyPrefix ] ?? $defaultUnit; // Desktop | |
| 21 | - $unitTablet = $value[ $keyPrefix . 'Tablet' ] ?? $unitDesktop; // Tablet inherits from Desktop | |
| 22 | - $unitMobile = $value[ $keyPrefix . 'Mobile' ] ?? $unitTablet; // Mobile inherits from Tablet | |
| 22 | + $unitDesktop = Helper::get_array_value( $value, $keyPrefix, $defaultUnit ); // Desktop | |
| 23 | + $unitTablet = Helper::get_array_value( $value, $keyPrefix . 'Tablet', $unitDesktop ); // Tablet inherits from Desktop | |
| 24 | + $unitMobile = Helper::get_array_value( $value, $keyPrefix . 'Mobile', $unitTablet ); // Mobile inherits from Tablet | |
| 23 | 25 | |
| 24 | 26 | // Return the appropriate unit based on the device |
| 25 | 27 | if ( '' === $device ) { |
| 26 | 28 | return $unitDesktop; // Desktop |