PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.0
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / classes / control-base-abstract-two.php

control-base-abstract-two.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.0, at includes/classes/control-base-abstract-two.php

42 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Classes;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Helper;
9
10 abstract class ControlBaseAbstractTwo {
11 abstract public static function get_attribute_default_value( $args );
12 abstract public static function get_attribute( $args );
13 abstract public static function get_css( $args );
14
15 public static function get_unit( $args ) {
16 $defaultUnit = $args['unitDefaultValue'];
17 $value = $args['attributeValue'];
18 $device = $args['device'];
19 $keyPrefix = $args['attributeObjectKey'] . 'Unit';
20
21 // Retrieve units with fallback to default
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
25
26 // Return the appropriate unit based on the device
27 if ( '' === $device ) {
28 return $unitDesktop; // Desktop
29 }
30
31 if ( 'Tablet' === $device ) {
32 return $unitTablet; // Tablet
33 }
34
35 if ( 'Mobile' === $device ) {
36 return $unitMobile; // Mobile
37 }
38
39 return $defaultUnit; // Default fallback
40 }
41 }
42