PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.11.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.11.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 / blocks / ecm-claim-list / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.11.1, at includes/blocks/ecm-claim-list/block.php

206 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ABlocks\Blocks\EcmClaimList;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 use ABlocks\Classes\BlockBaseAbstract;
10 use ABlocks\Classes\CssGenerator;
11 use ABlocks\Helper;
12 use ABlocks\Controls\Typography;
13 use ABlocks\Controls\Background;
14 use ABlocks\Controls\Border;
15 use ABlocks\Controls\Dimensions;
16 use ABlocks\Controls\Range;
17 use ABlocks\Controls\BoxShadow;
18 use ABlocks\Controls\Color;
19 use ABlocks\Controls\TextShadow;
20 use ABlocks\Controls\TextStroke;
21
22 class Block extends BlockBaseAbstract {
23 protected $block_name = 'ecm-claim-list';
24
25 public function build_css( $attributes ) {
26 $css_generator = new CssGenerator( $attributes, $this->block_name );
27
28 $css_generator->add_class_styles(
29 '{{WRAPPER}} .ecm-shortcode--claim__list-item',
30 $this->getListCSS( $attributes ),
31 $this->getListCSS( $attributes, 'Tablet' ),
32 $this->getListCSS( $attributes, 'Mobile' ),
33
34 );
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} .ecm-shortcode--claim__list',
37 $this->getListALignmentCSS( $attributes ),
38 $this->getListALignmentCSS( $attributes, 'Tablet' ),
39 $this->getListALignmentCSS( $attributes, 'Mobile' ),
40
41 );
42 $css_generator->add_class_styles(
43 '{{WRAPPER}} .ecm-shortcode--claim__list-title',
44 $this->getListTitleCSS( $attributes ),
45 $this->getListTitleCSS( $attributes, 'Tablet' ),
46 $this->getListTitleCSS( $attributes, 'Mobile' ),
47
48 );
49 $css_generator->add_class_styles(
50 '{{WRAPPER}} .ecm-shortcode--claim__list-date',
51 $this->getListDescriptionCSS( $attributes ),
52 $this->getListDescriptionCSS( $attributes, 'Tablet' ),
53 $this->getListDescriptionCSS( $attributes, 'Mobile' ),
54
55 );
56 $css_generator->add_class_styles(
57 '{{WRAPPER}} ul.ecm-shortcode--claim__list',
58 $this->getListStyleCSS( $attributes ),
59 $this->getListStyleCSS( $attributes, 'Tablet' ),
60 $this->getListStyleCSS( $attributes, 'Mobile' ),
61
62 );
63
64 $css_generator->add_class_styles(
65 '{{WRAPPER}} .ecm-shortcode--claim__list-item:hover',
66 $this->getListHoverCSS( $attributes ),
67 $this->getListHoverCSS( $attributes, 'Tablet' ),
68 $this->getListHoverCSS( $attributes, 'Mobile' ),
69 );
70 $css_generator->add_class_styles(
71 '{{WRAPPER}} .ecm-shortcode--claim__not-found',
72 $this->getNotFoundTextStyle( $attributes ),
73 $this->getNotFoundTextStyle( $attributes, 'Tablet' ),
74 $this->getNotFoundTextStyle( $attributes, 'Mobile' ),
75 );
76
77 return $css_generator->generate_css();
78 }
79
80 public function render_block_content( $attributes, $content, $block_instance ) {
81 $attr_array = [
82 'user_id' => Helper::get_attribute_value( $attributes, 'user_id' ),
83 'status' => Helper::get_attribute_value( $attributes, 'status' ),
84 'not_found_text' => Helper::get_attribute_value( $attributes, 'not_found_text' ),
85 ];
86
87 $shortcode = '[ecm_claim_list ' . Helper::attr_shortcode( $attr_array ) . ']';
88 echo do_shortcode( $shortcode );
89 }
90
91 public function getListCSS( $attributes, $device = '' ) {
92 $css = [];
93 $cssPadding = [];
94 if ( $attributes['listBackground'] !== '' ) {
95 $css['background'] = $attributes['listBackground'];
96 }
97 if ( ! empty( $attributes['listPadding'] ) ) {
98 $cssPadding = Dimensions::get_css( $attributes['listPadding'], 'padding', $device );
99 }
100 return array_merge(
101 [ 'background' => Color::get_css( isset( $attributes['listBackground'] ) ? $attributes['listBackground'] : '' ) ],
102 $css,
103 Range::get_css([
104 'attributeValue' => $attributes['listWidth'],
105 'attribute_object_key' => 'value',
106 'isResponsive' => true,
107 'hasUnit' => true,
108 'defaultValue' => 33,
109 'unitDefaultValue' => '%',
110 'property' => 'width',
111 'device' => $device,
112 ]),
113 Border::get_css( $attributes['listBorder'], '', $device ),
114 $cssPadding,
115 BoxShadow::get_css( $attributes['listBoxShadow'], '', $device ),
116 );
117 }
118 public function getListALignmentCSS( $attributes, $device = '' ) {
119 $css = [];
120 $css['display'] = 'flex';
121 $css['flex-direction'] = 'column';
122 $alignment_css = [];
123
124 if ( ! empty( $attributes['listAlignment'][ 'value' . $device ] ) ) {
125 $alignment_css['align-items'] = $attributes['listAlignment'][ 'value' . $device ];
126 }
127 return array_merge(
128 $alignment_css,
129 $css
130 );
131 }
132 public function getListTitleCSS( $attributes, $device = '' ) {
133 $css = [];
134 if ( $attributes['titleColor'] !== '' ) {
135 $css['color'] = $attributes['titleColor'];
136 }
137 $typographyValueGlobal = ! empty( $attributes['typographyGlobal'] ) ? $attributes['typographyGlobal'] : '';
138 $typography_css = ! empty( $attributes['titleTypography'] ) ? Typography::get_css( $attributes['titleTypography'], '', $device, $typographyValueGlobal ) : array();
139 $textShadowCss = ! empty( $attributes['titleTextShadow'] ) ? TextShadow::get_css( $attributes['titleTextShadow'], '', $device ) : array();
140 $textStrokeCss = ! empty( $attributes['titleTextStroke'] ) ? TextStroke::get_css( $attributes['titleTextStroke'], '', $device ) : array();
141
142 return array_merge(
143 $css,
144 $typography_css,
145 $textShadowCss,
146 $textStrokeCss
147 );
148 }
149 public function getListDescriptionCSS( $attributes, $device = '' ) {
150 $css = [];
151 if ( $attributes['desColor'] !== '' ) {
152 $css['color'] = $attributes['desColor'];
153 }
154 $typographyValueGlobal = ! empty( $attributes['typographyGlobal'] ) ? $attributes['typographyGlobal'] : '';
155 $typography_css = ! empty( $attributes['desTypography'] ) ? Typography::get_css( $attributes['desTypography'], '', $device, $typographyValueGlobal ) : array();
156 $textShadowCss = ! empty( $attributes['desTextShadow'] ) ? TextShadow::get_css( $attributes['desTextShadow'], '', $device ) : array();
157 $textStrokeCss = ! empty( $attributes['desTextStroke'] ) ? TextStroke::get_css( $attributes['desTextStroke'], '', $device ) : array();
158
159 return array_merge(
160 $css,
161 $typography_css,
162 $textShadowCss,
163 $textStrokeCss
164 );
165 }
166 public function getListStyleCSS( $attributes, $device = '' ) {
167 $css = [];
168 if ( $attributes['listStyle'] !== '' ) {
169 $css['list-style'] = $attributes['listStyle'];
170 }
171 return array_merge(
172 $css,
173 );
174 }
175 public function getListHoverCSS( $attributes, $device = '' ) {
176 return array_merge(
177 Border::get_hover_css( $attributes['listBorder'], '', $device ),
178 BoxShadow::get_hover_css( $attributes['listBoxShadow'], '', $device )
179 );
180 }
181 public function getNotFoundTextStyle( $attributes, $device = '' ) {
182 $css = [];
183 if ( ! empty( $attributes['notFoundAlignment'] ) && ! empty( $attributes['notFoundAlignment']['value' . $device] ) ) {
184 $css['text-align'] = $attributes['notFoundAlignment']['value' . $device];
185 }
186
187 if ( ! empty( $attributes['notFoundPadding'] ) ) {
188 $css = array_merge(
189 $css,
190 Dimensions::get_css($attributes['notFoundPadding'], 'padding', $device)
191 );
192 }
193 if ( ! empty( $attributes['notFoundColor'] ) && $attributes['notFoundColor'] !== '' ) {
194 $css['color'] = $attributes['notFoundColor'];
195 }
196
197 $typographyValueGlobal = ! empty( $attributes['notFoundTypographyGlobal'] ) ? $attributes['notFoundTypographyGlobal'] : '';
198 $typography_css = ! empty( $attributes['notFoundTypography'] ) ? Typography::get_css( $attributes['notFoundTypography'], '', $device, $typographyValueGlobal ) : array();
199 return array_merge(
200 $css,
201 $typography_css
202 );
203 }
204
205 }
206