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 / blocks / form-checkbox / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.0, at includes/blocks/form-checkbox/block.php

62 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\FormCheckbox;
3
4 use ABlocks\Controls\Range;
5
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 use ABlocks\Classes\BlockBaseAbstract;
12 use ABlocks\Classes\CssGenerator;
13
14 class Block extends BlockBaseAbstract {
15 protected $parent_block_name = 'form-builder';
16 protected $block_name = 'form-checkbox';
17
18 public function build_css( $attributes ) {
19 $css_generator = new CssGenerator( $attributes );
20 $css_generator->add_class_styles(
21 '{{WRAPPER}}',
22 $this->get_wrapper_css( $attributes ),
23 $this->get_wrapper_css( $attributes, 'Tablet' ),
24 $this->get_wrapper_css( $attributes, 'Mobile' )
25 );
26 $css_generator->add_class_styles(
27 '{{WRAPPER}}.ablocks-block--form-checkbox',
28 $this->get_input_block_main_wrapper( $attributes ),
29 $this->get_input_block_main_wrapper( $attributes, 'Tablet' ),
30 $this->get_input_block_main_wrapper( $attributes, 'Mobile' ),
31 );
32 return $css_generator->generate_css();
33 }
34 public function get_wrapper_css() {
35 return [];
36 }
37
38 public function get_input_block_main_wrapper( $attributes, $device = '' ) {
39 $css = [];
40 $css['box-sizing'] = 'border-box';
41
42 $valueKey = $device === 'Tablet' ? 'valueTablet' : ( $device === 'Mobile' ? 'valueMobile' : 'value' );
43 $unitKey = $device === 'Tablet' ? 'valueUnitTablet' : ( $device === 'Mobile' ? 'valueUnitMobile' : 'valueUnit' );
44
45 $widthValue = isset( $attributes['inputWidth'][ $valueKey ] ) && $attributes['inputWidth'][ $valueKey ] !== ''
46 ? $attributes['inputWidth'][ $valueKey ]
47 : ( isset( $attributes['inputWidth']['value'] ) ? $attributes['inputWidth']['value'] : 100 );
48
49 $widthUnit = isset( $attributes['inputWidth'][ $unitKey ] ) && $attributes['inputWidth'][ $unitKey ] !== ''
50 ? $attributes['inputWidth'][ $unitKey ]
51 : '%';
52
53 if ( is_numeric( $widthValue ) ) {
54 $widthValue = max( 0, floatval( $widthValue ) - 1 );
55 }
56
57 $css['width'] = $widthValue . $widthUnit;
58
59 return $css;
60 }
61 }
62