PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.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 All 81 releases
← All changes | includes/blocks/form-textarea/block.php +57 -0 2.7.5 → 2.14.0 View file →
@@ -1,0 +1,57 @@
1 +<?php
2 +namespace ABlocks\Blocks\FormTextarea;
3 +
4 +use ABlocks\Controls\Range;
5 +
6 +if ( ! defined( 'ABSPATH' ) ) {
7 + exit;
8 +}
9 +
10 +use ABlocks\Classes\BlockBaseAbstract;
11 +use ABlocks\Classes\CssGenerator;
12 +
13 +class Block extends BlockBaseAbstract {
14 + protected $parent_block_name = 'form-builder';
15 + protected $block_name = 'form-textarea';
16 +
17 + public function build_css( $attributes ) {
18 + $css_generator = new CssGenerator( $attributes );
19 + $css_generator->add_class_styles(
20 + '{{WRAPPER}}',
21 + $this->get_wrapper_css( $attributes ),
22 + $this->get_wrapper_css( $attributes, 'Tablet' ),
23 + $this->get_wrapper_css( $attributes, 'Mobile' ),
24 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wrapper_css( $attributes, $device ); } )
25 + );
26 + $css_generator->add_class_styles(
27 + '{{WRAPPER}}.ablocks-block--form-textarea',
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 + public function get_input_block_main_wrapper( $attributes, $device = '' ) {
38 + $css = [];
39 + $css['box-sizing'] = 'border-box';
40 +
41 + // The device's own width, else the nearest containing wider device's
42 + // (custom breakpoints included), else Desktop's.
43 + $input_width = isset( $attributes['inputWidth'] ) ? (array) $attributes['inputWidth'] : [];
44 + $widthValue = \ABlocks\Helper::get_responsive_value( $input_width, 'value', $device );
45 + $widthValue = false === $widthValue ? 100 : $widthValue;
46 + $widthUnit = \ABlocks\Helper::get_responsive_value( $input_width, 'valueUnit', $device );
47 + $widthUnit = false === $widthUnit ? '%' : $widthUnit;
48 +
49 + if ( is_numeric( $widthValue ) ) {
50 + $widthValue = max( 0, floatval( $widthValue ) - 1 );
51 + }
52 +
53 + $css['width'] = $widthValue . $widthUnit;
54 +
55 + return $css;
56 + }
57 +}