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 / classes / block-global.php

block-global.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.8.0, at includes/classes/block-global.php

160 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Classes;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Controls\Dimensions;
9 use ABlocks\Controls\Width;
10 use ABlocks\Controls\Border;
11 use ABlocks\Controls\Position;
12 use ABlocks\Controls\Background;
13 use ABlocks\Controls\Zindex;
14 use ABlocks\Controls\Transform;
15 use ABlocks\Controls\Mask;
16 use ABlocks\Controls\Animation;
17 use ABlocks\Controls\BoxShadow;
18 use ABlocks\Controls\GsapAnimation;
19 use ABlocks\Helper;
20
21 class BlockGlobal {
22 public static function get_attributes() {
23 $attributes = [
24 '_hide_on_desktop' => [
25 'type' => 'boolean',
26 'default' => false,
27 ],
28 '_hide_on_tablet' => [
29 'type' => 'boolean',
30 'default' => false,
31 ],
32 '_hide_on_mobile' => [
33 'type' => 'boolean',
34 'default' => false,
35 ],
36 '_custom_css' => [
37 'type' => 'string',
38 'default' => '',
39 ],
40 '_animation_element_trigger' => [
41 'type' => 'array',
42 'default' => [],
43 'items' => [
44 'type' => 'object'
45 ]
46 ],
47 '_animation_page_trigger' => [
48 'type' => 'array',
49 'default' => [],
50 'items' => [
51 'type' => 'object'
52 ]
53 ],
54 ];
55 $attributes = array_merge(
56 Dimensions::get_attribute( '_margin', true ),
57 Dimensions::get_attribute( '_padding', true ),
58 Width::get_attribute( '_width', true ),
59 Border::get_attribute( '_border', true ),
60 Position::get_attribute( '_position', true ),
61 Background::get_attribute( '_background', true ),
62 Zindex::get_attribute( '_zIndex', true ),
63 Transform::get_attribute( '_transform', true ),
64 Mask::get_attribute( '_mask', true ),
65 Animation::get_attribute( '_animation', true ),
66 BoxShadow::get_attribute( '_boxShadow', true ),
67 Transform::get_attribute( '_transform', true ),
68 GsapAnimation::get_attribute( '_gsapAnimation', true ),
69 $attributes,
70 );
71 return apply_filters( 'ablocks/get_block_common_attributes', $attributes );
72 }
73 public static function get_wrapper_css( $attribute, $device = '' ) {
74 $transitions = [];
75 $transition_types = [
76 '_border' => 'border',
77 '_background' => 'background',
78 '_boxShadow' => 'box-shadow',
79 ];
80 foreach ( $transition_types as $key => $property ) {
81 if ( isset( $attribute[ $key ] ) ) {
82 $duration = ! empty( $attribute[ $key ]['transitionDuration'] ) ? $attribute[ $key ]['transitionDuration'] : '0';
83 $transitions[] = "{$property} {$duration}s ease";
84 }
85 }
86 $transition_string = implode( ',', $transitions );
87
88 $css = array_merge(
89 Dimensions::get_css( $attribute['_margin'], 'margin', $device ),
90 Dimensions::get_css( $attribute['_padding'], 'padding', $device ),
91 Mask::get_css( $attribute['_mask'], $device ),
92 Background::get_css( $attribute['_background'], 'background', $device ),
93 Border::get_css( $attribute['_border'], '', $device ),
94 Width::get_css( $attribute['_width'], 'width', $device ),
95 BoxShadow::get_css( $attribute['_boxShadow'], $device ),
96 Position::get_css( $attribute['_position'], 'position', $device ),
97 Zindex::get_css( $attribute['_zIndex'], 'z-index', $device ),
98 [ 'transition' => $transition_string ]
99 );
100 return apply_filters( 'ablocks/get_block_common_wrapper_css', $css, $attribute, $device );
101 }
102 public static function get_wrapper_hover_css( $attribute, $device = '' ) {
103 $css = array_merge(
104 Background::get_hover_css( $attribute['_background'], 'background', $device ),
105 Border::get_hover_css( $attribute['_border'], '', $device ),
106 BoxShadow::get_hover_css( $attribute['_boxShadow'], '', $device ),
107 );
108 return apply_filters( 'ablocks/get_block_common_wrapper_hover_css', $css, $attribute, $device );
109 }
110 public static function get_container_css( $attribute, $device = '' ) {
111 $css = array_merge(
112 Transform::get_css( $attribute['_transform'], 'transform', $device ),
113 );
114 return apply_filters( 'ablocks/get_block_common_container_css', $css, $attribute, $device );
115 }
116 public static function get_container_hover_css( $attribute, $device = '' ) {
117 $css = array_merge(
118 Transform::get_hover_css( $attribute['_transform'], 'transform', $device ),
119 );
120 return apply_filters( 'ablocks/get_block_common_container_hover_css', $css, $attribute, $device );
121 }
122 public static function get_wrapper_device_responsive_css( $attribute, $device = '' ) {
123 if (
124 ! isset( $attribute['_hide_on_desktop'] ) &&
125 ! isset( $attribute['_hide_on_tablet'] ) &&
126 ! isset( $attribute['_hide_on_mobile'] )
127 ) {
128 return [];
129 }
130
131 // Desktop (default view)
132 if ( '' === $device && Helper::has_value( $attribute['_hide_on_desktop'] ) ) {
133 return [ 'display' => 'none' ];
134 }
135
136 // Tablet
137 if ( 'Tablet' === $device ) {
138 if ( Helper::has_value( $attribute['_hide_on_tablet'] ) ) {
139 return [ 'display' => 'none' ];
140 }
141 if ( Helper::has_value( $attribute['_hide_on_desktop'] ) ) {
142 return [ 'display' => 'block' ];
143 }
144 }
145
146 // Mobile
147 if ( 'Mobile' === $device ) {
148 if ( Helper::has_value( $attribute['_hide_on_mobile'] ) ) {
149 return [ 'display' => 'none' ];
150 }
151 if ( Helper::has_value( $attribute['_hide_on_tablet'] ) ) {
152 return [ 'display' => 'block' ];
153 }
154 }
155
156 return [];
157 }
158
159 }
160