PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.1
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.1, at includes/classes/control-base-abstract-two.php

40 lines 1.1 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 abstract class ControlBaseAbstractTwo {
9 abstract public static function get_attribute_default_value( $args );
10 abstract public static function get_attribute( $args );
11 abstract public static function get_css( $args );
12
13 public static function get_unit( $args ) {
14 $defaultUnit = $args['unitDefaultValue'];
15 $value = $args['attributeValue'];
16 $device = $args['device'];
17 $keyPrefix = $args['attributeObjectKey'] . 'Unit';
18
19 // 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
23
24 // Return the appropriate unit based on the device
25 if ( '' === $device ) {
26 return $unitDesktop; // Desktop
27 }
28
29 if ( 'Tablet' === $device ) {
30 return $unitTablet; // Tablet
31 }
32
33 if ( 'Mobile' === $device ) {
34 return $unitMobile; // Mobile
35 }
36
37 return $defaultUnit; // Default fallback
38 }
39 }
40