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/divider/block.php +117 -14 2.9.1 → 2.14.0 View file →
@@ -1,8 +1,12 @@
1 1 <?php
2 2
3 3 namespace ABlocks\Blocks\Divider;
4 4
5 +if ( ! defined( 'ABSPATH' ) ) {
6 + exit;
7 +}
8 +
5 9 use ABlocks\Classes\BlockBaseAbstract;
6 10 use ABlocks\Classes\CssGenerator;
7 11 use ABlocks\Controls\Alignment;
8 12 use ABlocks\Controls\TextStroke;
@@ -8,14 +12,15 @@
8 12 use ABlocks\Controls\TextStroke;
9 13 use ABlocks\Controls\Typography;
10 14 use ABlocks\Controls\Icon;
11 15 use ABlocks\Controls\Range;
12 -
16 +use ABlocks\Classes\CssGeneratorV2;
17 +use ABlocks\Controls\Color;
13 18 class Block extends BlockBaseAbstract {
14 19
15 20 protected $block_name = 'divider';
16 21
17 - public function build_css( $attributes ) {
22 + public function build_css_v1( $attributes ) {
18 23 $css_generator = new CssGenerator( $attributes, $this->block_name );
19 24 $css_generator->add_class_styles(
20 25 '{{WRAPPER}}',
21 26 $this->get_wrapper_css( $attributes ),
@@ -48,15 +53,25 @@
48 53 $css_generator->add_class_styles(
49 54 '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap',
50 55 Icon::get_wrapper_css( $attributes ),
51 56 Icon::get_wrapper_css( $attributes, 'Tablet' ),
52 - Icon::get_wrapper_css( $attributes, 'Mobile' )
57 + Icon::get_wrapper_css( $attributes, 'Mobile' ),
58 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_css( $attributes, $device ); } )
53 59 );
54 60 $css_generator->add_class_styles(
61 + '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap:hover',
62 + Icon::get_wrapper_hover_css( $attributes ),
63 + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ),
64 + Icon::get_wrapper_hover_css( $attributes, 'Mobile' ),
65 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_hover_css( $attributes, $device ); } )
66 + );
67 +
68 + $css_generator->add_class_styles(
55 69 '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap',
56 70 array_merge( Icon::get_wrapper_css( $attributes ), $this->get_icon_spacing_margins( $attributes, '' ) ),
57 71 array_merge( Icon::get_wrapper_css( $attributes, 'Tablet' ), $this->get_icon_spacing_margins( $attributes, 'Tablet' ) ),
58 - array_merge( Icon::get_wrapper_css( $attributes, 'Mobile' ), $this->get_icon_spacing_margins( $attributes, 'Mobile' ) )
72 + array_merge( Icon::get_wrapper_css( $attributes, 'Mobile' ), $this->get_icon_spacing_margins( $attributes, 'Mobile' ) ),
73 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return array_merge( Icon::get_wrapper_css( $attributes, $device ), $this->get_icon_spacing_margins( $attributes, $device ) ); } )
59 74 );
60 75 $css_generator->add_class_styles(
61 76 '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap img.ablocks-image-icon',
62 77 Icon::get_element_image_css( $attributes ),
@@ -82,9 +97,102 @@
82 97 Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
83 98 );
84 99 return $css_generator->generate_css();
85 100 }
101 + public function build_css_v2( $attributes ) {
102 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
103 + $css_generator->add_class_styles(
104 + '{{WRAPPER}}.ablocks-block--divider:not(.ablocks-has-block-container),
105 + .ablocks-block--divider .ablocks-block-container',
106 + $this->get_wrapper_css( $attributes ),
107 + $this->get_wrapper_css( $attributes, 'Tablet' ),
108 + $this->get_wrapper_css( $attributes, 'Mobile' ),
109 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wrapper_css( $attributes, $device ); } )
110 + );
86 111
112 + $css_generator->add_class_styles(
113 + '{{WRAPPER}}.ablocks-block--divider:not(.ablocks-has-block-container),
114 + .ablocks-block--divider .ablocks-block-container',
115 + $this->get_divider_container_css( $attributes ),
116 + $this->get_divider_container_css( $attributes, 'Tablet' ),
117 + $this->get_divider_container_css( $attributes, 'Mobile' ),
118 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_divider_container_css( $attributes, $device ); } )
119 + );
120 +
121 + $css_generator->add_class_styles(
122 + '{{WRAPPER}} .ablocks-divider',
123 + $this->get_divider_css( $attributes ),
124 + $this->get_divider_css( $attributes, 'Tablet' ),
125 + $this->get_divider_css( $attributes, 'Mobile' ),
126 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_divider_css( $attributes, $device ); } )
127 + );
128 + // element text
129 +
130 + $css_generator->add_class_styles(
131 + '{{WRAPPER}} .ablocks-divider__element-text',
132 + $this->get_divider_element_text_css( $attributes ),
133 + $this->get_divider_element_text_css( $attributes, 'Tablet' ),
134 + $this->get_divider_element_text_css( $attributes, 'Mobile' ),
135 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_divider_element_text_css( $attributes, $device ); } )
136 + );
137 + // Icon Style
138 + $css_generator->add_class_styles(
139 + '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap',
140 + Icon::get_wrapper_css( $attributes ),
141 + Icon::get_wrapper_css( $attributes, 'Tablet' ),
142 + Icon::get_wrapper_css( $attributes, 'Mobile' ),
143 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_css( $attributes, $device ); } )
144 + );
145 + $css_generator->add_class_styles(
146 + '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap:hover',
147 + Icon::get_wrapper_hover_css( $attributes ),
148 + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ),
149 + Icon::get_wrapper_hover_css( $attributes, 'Mobile' ),
150 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_hover_css( $attributes, $device ); } )
151 + );
152 + $css_generator->add_class_styles(
153 + '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap',
154 + array_merge( Icon::get_wrapper_css( $attributes ), $this->get_icon_spacing_margins( $attributes, '' ) ),
155 + array_merge( Icon::get_wrapper_css( $attributes, 'Tablet' ), $this->get_icon_spacing_margins( $attributes, 'Tablet' ) ),
156 + array_merge( Icon::get_wrapper_css( $attributes, 'Mobile' ), $this->get_icon_spacing_margins( $attributes, 'Mobile' ) ),
157 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return array_merge( Icon::get_wrapper_css( $attributes, $device ), $this->get_icon_spacing_margins( $attributes, $device ) ); } )
158 + );
159 + $css_generator->add_class_styles(
160 + '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap img.ablocks-image-icon',
161 + Icon::get_element_image_css( $attributes ),
162 + Icon::get_element_image_css( $attributes, 'Tablet' ),
163 + Icon::get_element_image_css( $attributes, 'Mobile' ),
164 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_css( $attributes, $device ); } )
165 + );
166 + $css_generator->add_class_styles(
167 + '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap img.ablocks-image-icon:hover',
168 + Icon::get_element_image_hover_css( $attributes ),
169 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
170 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
171 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_hover_css( $attributes, $device ); } )
172 + );
173 + $css_generator->add_class_styles(
174 + '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap svg.ablocks-svg-icon',
175 + Icon::get_element_css( $attributes ),
176 + Icon::get_element_css( $attributes, 'Tablet' ),
177 + Icon::get_element_css( $attributes, 'Mobile' ),
178 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_css( $attributes, $device ); } )
179 + );
180 + $css_generator->add_class_styles(
181 + '{{WRAPPER}} .ablocks-divider__element-icon .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
182 + Icon::get_element_image_hover_css( $attributes ),
183 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
184 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
185 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_hover_css( $attributes, $device ); } )
186 + );
187 + return $css_generator->generate_css();
188 + }
189 + public function build_css( $attributes ) {
190 + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
191 + return $this->build_css_v2( $attributes );
192 + }
193 + return $this->build_css_v1( $attributes );
194 + }
87 195 public function get_wrapper_css( $attributes, $device = '' ) {
88 196 if ( isset( $attributes['alignment'] ) ) {
89 197 return Alignment::get_css( $attributes['alignment'], 'text-align', $device );
90 198 }
@@ -91,14 +199,12 @@
91 199 return [];
92 200 }
93 201
94 202 public function get_divider_element_text_css( $attributes, $device = '' ) {
95 - $divider_text_styles = [];
96 - if ( isset( $attributes['elementTextColor'] ) ) {
97 - $divider_text_styles['color'] = $attributes['elementTextColor'];
98 - }
203 + $typographyValueGlobal = ! empty( $attributes['elementTextTypographyGlobal'] ) ? $attributes['elementTextTypographyGlobal'] : '';
204 + $typography_value = isset( $attributes['elementTextTypographyGlobal'] ) ? $attributes['elementTextTypographyGlobal'] : [];
99 205 return array_merge(
100 - $divider_text_styles,
206 + [ 'color' => Color::get_css( isset( $attributes['elementTextColor'] ) ? $attributes['elementTextColor'] : '' ) ],
101 207 Range::get_css([
102 208 'attributeValue' => $attributes['elementTextSpacing'],
103 209 'attributeObjectKey' => 'value',
104 210 'isResponsive' => true,
@@ -117,9 +223,9 @@
117 223 'unitDefaultValue' => 'px',
118 224 'property' => 'padding-left',
119 225 'device' => $device,
120 226 ]),
121 - Typography::get_css( $attributes['elementTextTypography'], '', $device ),
227 + Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
122 228 TextStroke::get_css( $attributes['elementTextStroke'], '', $device ),
123 229 );
124 230 }
125 231
@@ -193,10 +299,7 @@
193 299 'unitDefaultValue' => 'px',
194 300 'property' => 'margin-right',
195 301 'device' => $device,
196 302 ]);
197 - return [
198 - ...$marginLeft,
199 - ...$marginRight
200 - ];
303 + return array_merge( $marginLeft, $marginRight );
201 304 }
202 305 }