PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.8.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.8.0
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 1.2.0 1.2.1 All 78 releases
ablocks / includes / controls / mask.php

mask.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.8.0, at includes/controls/mask.php

131 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Controls;
3
4 use ABlocks\Classes\ControlBaseAbstract;
5
6 class Mask extends ControlBaseAbstract {
7 public static function get_attribute_default_value( $is_responsive = false ) {
8 if ( $is_responsive ) {
9 return [
10 'mask' => false,
11 'maskTablet' => false,
12 'maskMobile' => false,
13 'maskShape' => 'circle',
14 'customMaskShape' => '',
15 'maskSize' => '',
16 'maskSizeTablet' => '',
17 'maskSizeMobile' => '',
18 'maskPosition' => '',
19 'maskPositionTablet' => '',
20 'maskPositionMobile' => '',
21 'maskRepeat' => '',
22 'maskRepeatTablet' => '',
23 'maskRepeatMobile' => '',
24 'scaleUnit' => 'px',
25 'scaleUnitTablet' => 'px',
26 'scaleUnitMobile' => 'px',
27 'scale' => '0',
28 'scaleTablet' => '0',
29 'scaleMobile' => '0',
30 'xPositionUnit' => 'px',
31 'xPositionUnitTablet' => 'px',
32 'xPositionUnitMobile' => 'px',
33 'xPosition' => '',
34 'xPositionTablet' => '0',
35 'xPositionMobile' => '0',
36 'yPositionUnit' => '0',
37 'yPositionUnitTablet' => 'px',
38 'yPositionUnitMobile' => 'px',
39 'yPosition' => '0',
40 'yPositionTablet' => '0',
41 'yPositionMobile' => '0',
42 ];
43 }//end if
44 return [
45 'mask' => false,
46 'maskShape' => 'circle',
47 'maskSize' => '',
48 'maskPosition' => '',
49 'maskRepeat' => '',
50 'scaleUnit' => 'px',
51 'scale' => '0',
52 'xPosition' => '',
53 'xPositionUnit' => 'px',
54 'yPosition' => '',
55 'yPositionUnit' => 'px',
56 ];
57 }
58
59 public static function get_attribute( $attributeName, $isResponsive = false ) {
60 return [
61 $attributeName => [
62 'type' => 'object',
63 'default' => self::get_attribute_default_value( $isResponsive ),
64 ]
65 ];
66 }
67
68 public static function get_css( $attribute_value, $property = '', $device = '' ) {
69 $default_attar_value = self::get_attribute_default_value( (bool) $device );
70 $value = wp_parse_args( $attribute_value, $default_attar_value );
71
72 $css = [];
73
74 /**
75 * Generated CSS
76 * css property
77 * mask-image
78 * mask-size
79 * mask-position
80 * mask-repeat
81 */
82
83 if ( $value['mask'] ) {
84 if ( 'custom' === $value['maskShape'] ) {
85 $css['mask-image'] = 'url(' . $value['customMaskShape'] . ')';
86 } else {
87 $css['mask-image'] = 'url(' . ABLOCKS_ROOT_URL . '/assets/images/mask-shapes/' . $value['maskShape'] . '.svg)';
88 }
89 $css['mask-size'] = 'contain';
90 $css['mask-position'] = 'center center';
91 $css['mask-repeat'] = 'no-repeat';
92 }
93
94 if ( $value[ 'maskSize' . $device ] && 'custom' !== $value[ 'maskSize' . $device ] ) {
95 $css['mask-size'] = $value[ 'maskSize' . $device ];
96 }
97
98 if (
99 $value[ 'maskSize' . $device ] &&
100 'custom' === $value[ 'maskSize' . $device ] &&
101 $value[ 'scaleUnit' . $device ]
102 ) {
103 $css['mask-size'] = $value[ 'scale' . $device ] . $value[ 'scaleUnit' . $device ];
104 }
105
106 if (
107 'custom' === $value[ 'maskPosition' . $device ] &&
108 $value[ 'xPosition' . $device ] &&
109 $value[ 'xPositionUnit' . $device ]
110 ) {
111 $css['-webkit-mask-position-x'] = $value[ 'xPosition' . $device ] . $value[ 'xPositionUnit' . $device ];
112 $css['-webkit-mask-position-y'] = $value[ 'yPosition' . $device ] . $value[ 'yPositionUnit' . $device ];
113 }
114
115 if (
116 'custom' === $value[ 'maskPosition' . $device ] &&
117 $value[ 'yPosition' . $device ] &&
118 $value[ 'yPositionUnit' . $device ]
119 ) {
120 $css['-webkit-mask-position-y'] = $value[ 'yPosition' . $device ] . $value[ 'yPositionUnit' . $device ];
121 }
122
123 if ( $value[ 'maskRepeat' . $device ] ) {
124 $css['mask-repeat'] = $value[ 'maskRepeat' . $device ];
125 }
126 return $css;
127 }
128
129
130 }
131