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/controls/background.php +14 -55 2.9.1 → 2.14.0 View file →
@@ -5,8 +5,10 @@
5 5 exit;
6 6 }
7 7
8 8 use ABlocks\Classes\ControlBaseAbstract;
9 +use ABlocks\Controls\Color;
10 +use ABlocks\Helper;
9 11
10 12 class Background extends ControlBaseAbstract {
11 13 public static function get_attribute_default_value( $is_responsive = false ) {
12 14 if ( $is_responsive ) {
@@ -171,32 +173,11 @@
171 173 $value = wp_parse_args( $attribute_value, self::get_attribute_default_value( (bool) $device ) );
172 174 $css = [];
173 175
174 176 if ( $device ) {
175 - $unitXPositionUnit = self::get_unit(
176 - [
177 - 'unit' => isset( $value['imgXPositionUnit'] ) ? $value['imgXPositionUnit'] : '',
178 - 'unitTablet' => isset( $value['imgXPositionUnitTablet'] ) ? $value['imgXPositionUnitTablet'] : '',
179 - 'unitMobile' => isset( $value['imgXPositionUnitMobile'] ) ? $value['imgXPositionUnitMobile'] : '',
180 - ],
181 - $device
182 - );
183 - $unitYPositionUnit = self::get_unit(
184 - [
185 - 'unit' => isset( $value['imgYPositionUnit'] ) ? $value['imgYPositionUnit'] : '',
186 - 'unitTablet' => isset( $value['imgYPositionUnitTablet'] ) ? $value['imgYPositionUnitTablet'] : '',
187 - 'unitMobile' => isset( $value['imgYPositionUnitMobile'] ) ? $value['imgYPositionUnitMobile'] : '',
188 - ],
189 - $device
190 - );
191 - $imgDisplaySizeWidthUnit = self::get_unit(
192 - [
193 - 'unit' => isset( $value['imgDisplaySizeWidthUnit'] ) ? $value['imgDisplaySizeWidthUnit'] : '',
194 - 'unitTablet' => isset( $value['imgDisplaySizeWidthUnitTablet'] ) ? $value['imgDisplaySizeWidthUnitTablet'] : '',
195 - 'unitMobile' => isset( $value['imgDisplaySizeWidthUnitMobile'] ) ? $value['imgDisplaySizeWidthUnitMobile'] : '',
196 - ],
197 - $device
198 - );
177 + $unitXPositionUnit = Helper::get_responsive_value( $value, 'imgXPositionUnit', $device );
178 + $unitYPositionUnit = Helper::get_responsive_value( $value, 'imgYPositionUnit', $device );
179 + $imgDisplaySizeWidthUnit = Helper::get_responsive_value( $value, 'imgDisplaySizeWidthUnit', $device );
199 180 } else {
200 181 $unitXPositionUnit = isset( $value['imgXPositionUnit'] ) ? $value['imgXPositionUnit'] : '';
201 182 $unitYPositionUnit = isset( $value['imgYPositionUnit'] ) ? $value['imgYPositionUnit'] : '';
202 183 $imgDisplaySizeWidthUnit = isset( $value['imgDisplaySizeWidthUnit'] ) ? $value['imgDisplaySizeWidthUnit'] : '';
@@ -230,13 +211,13 @@
230 211 } else {
231 212 $css[ $property . '-size' ] = $value[ 'imgDisplaySize' . $device ];
232 213 }
233 214 }
234 - } elseif ( 'video' === $value['backgroundType'] && '' !== $value['fallbackImageUrl'] ) {
215 + } elseif ( 'video' === $value['backgroundType'] && '' !== $value['fallbackImageUrl'] && ( $value['videoSource'] == 'none' || ( $value['videoSource'] == 'selfHosted' && empty( $value['videoUrl'] ) ) || ( $value['videoSource'] == 'youtube' && empty( $value['youtubeURL'] ) ) || ( $value['videoSource'] == 'vimeo' && empty( $value['vimeoURL'] ) ) ) ) {
235 216 $css[ $property . '-image' ] = 'url("' . $value['fallbackImageUrl'] . '")';
236 217 $css[ $property . '-size' ] = 'cover';
237 218 } elseif ( 'color' === $value['backgroundType'] && $value['backgroundColor'] ) {
238 - $css[ $property ] = $value['backgroundColor'];
219 + $css[ $property ] = Color::get_css( $value['backgroundColor'] );
239 220 }//end if
240 221
241 222 if ( '' !== $value['transitionDuration'] ) {
242 223 $css['transition'] = $property . ' ' . $value['transitionDuration'] . 's ease';
@@ -249,32 +230,11 @@
249 230 $value = wp_parse_args( $attribute_value, self::get_attribute_default_value( (bool) $device ) );
250 231 $css = [];
251 232
252 233 if ( $device ) {
253 - $unitXPositionUnitH = self::get_unit(
254 - [
255 - 'unit' => isset( $value['imgXPositionUnitH'] ) ? $value['imgXPositionUnitH'] : '',
256 - 'unitTablet' => isset( $value['imgXPositionUnitHTablet'] ) ? $value['imgXPositionUnitHTablet'] : '',
257 - 'unitMobile' => isset( $value['imgXPositionUnitHMobile'] ) ? $value['imgXPositionUnitHMobile'] : '',
258 - ],
259 - $device
260 - );
261 - $unitYPositionUnitH = self::get_unit(
262 - [
263 - 'unit' => isset( $value['imgYPositionUnitH'] ) ? $value['imgYPositionUnitH'] : '',
264 - 'unitTablet' => isset( $value['imgYPositionUnitHTablet'] ) ? $value['imgYPositionUnitHTablet'] : '',
265 - 'unitMobile' => isset( $value['imgYPositionUnitHMobile'] ) ? $value['imgYPositionUnitHMobile'] : '',
266 - ],
267 - $device
268 - );
269 - $imgDisplaySizeWidthUnitH = self::get_unit(
270 - [
271 - 'unit' => isset( $value['imgDisplaySizeWidthHUnit'] ) ? $value['imgDisplaySizeWidthHUnit'] : '',
272 - 'unitTablet' => isset( $value['imgDisplaySizeWidthHUnitTablet'] ) ? $value['imgDisplaySizeWidthHUnitTablet'] : '',
273 - 'unitMobile' => isset( $value['imgDisplaySizeWidthHUnitMobile'] ) ? $value['imgDisplaySizeWidthHUnitMobile'] : '',
274 - ],
275 - $device
276 - );
234 + $unitXPositionUnitH = Helper::get_responsive_value( $value, 'imgXPositionUnitH', $device );
235 + $unitYPositionUnitH = Helper::get_responsive_value( $value, 'imgYPositionUnitH', $device );
236 + $imgDisplaySizeWidthUnitH = Helper::get_responsive_value( $value, 'imgDisplaySizeWidthHUnit', $device );
277 237 } else {
278 238 $unitXPositionUnitH = isset( $value['imgXPositionUnitH'] ) ? $value['imgXPositionUnitH'] : '';
279 239 $unitYPositionUnitH = isset( $value['imgYPositionUnitH'] ) ? $value['imgYPositionUnitH'] : '';
280 240 $imgDisplaySizeWidthUnitH = isset( $value['imgDisplaySizeWidthHUnit'] ) ? $value['imgDisplaySizeWidthHUnit'] : '';
@@ -294,9 +254,9 @@
294 254 }
295 255 }
296 256 // background-attachments css
297 257 if ( '' !== isset( $value[ 'imgAttachmentH' . $device ] ) ) {
298 - $css[ $property . '-attachment' ] = isset( $value[ 'imgAttachmentH' . $device ] );
258 + $css[ $property . '-attachment' ] = $value[ 'imgAttachmentH' . $device ];
299 259 }
300 260 // background-repeat css
301 261 if ( '' !== $value[ 'imgRepeatH' . $device ] ) {
302 262 $css[ $property . '-repeat' ] = $value[ 'imgRepeatH' . $device ];
@@ -308,13 +268,12 @@
308 268 } else {
309 269 $css[ $property . '-size' ] = $value[ 'imgDisplaySizeH' . $device ];
310 270 }
311 271 }
312 - } elseif ( 'video' === $value['backgroundTypeH'] && '' !== $value['fallbackImageUrlH'] ) {
313 - $css[ $property . '-image' ] = 'url("' . $value['fallbackImageUrlH'] . '")';
314 - $css[ $property . '-size' ] = 'cover';
272 + } elseif ( 'video' === $value['backgroundTypeH'] ) {
273 +
315 274 } elseif ( 'color' === $value['backgroundTypeH'] && $value['backgroundColorH'] ) {
316 - $css[ $property ] = $value['backgroundColorH'];
275 + $css[ $property ] = Color::get_css( $value['backgroundColorH'] );
317 276 }//end if
318 277
319 278 return $css;
320 279 }