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 / storeengine-cart-sub-table / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.11.1, at includes/blocks/storeengine-cart-sub-table/block.php

182 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\StoreengineCartSubTable;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Helper;
11 use ABlocks\Controls\Typography;
12 use ABlocks\Controls\Background;
13 use ABlocks\Controls\Border;
14 use ABlocks\Controls\Dimensions;
15 use ABlocks\Controls\Range;
16 use ABlocks\Controls\BoxShadow;
17 use ABlocks\Controls\Color;
18
19 class Block extends BlockBaseAbstract {
20
21 protected $block_name = 'storeengine-cart-sub-table';
22
23 public function build_css( $attributes ) {
24 $css_generator = new CssGenerator( $attributes, $this->block_name );
25
26 $css_generator->add_class_styles(
27 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode table',
28 $this->get_cart_sub_wrapper_css( $attributes ),
29 $this->get_cart_sub_wrapper_css( $attributes, 'Tablet' ),
30 $this->get_cart_sub_wrapper_css( $attributes, 'Mobile' )
31 );
32 $css_generator->add_class_styles(
33 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode',
34 $this->get_cart_sub_css( $attributes ),
35 $this->get_cart_sub_css( $attributes, 'Tablet' ),
36 $this->get_cart_sub_css( $attributes, 'Mobile' )
37 );
38 $css_generator->add_class_styles(
39 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child',
40 $this->get_cart_sub_row_css( $attributes ),
41 $this->get_cart_sub_row_css( $attributes, 'Tablet' ),
42 $this->get_cart_sub_row_css( $attributes, 'Mobile' )
43 );
44 $css_generator->add_class_styles(
45 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child:hover',
46 $this->get_cart_sub_row_hover_css( $attributes ),
47 $this->get_cart_sub_row_hover_css( $attributes, 'Tablet' ),
48 $this->get_cart_sub_row_hover_css( $attributes, 'Mobile' )
49 );
50 $css_generator->add_class_styles(
51 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child td,
52 {{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child th',
53 $this->get_cart_sub_row_text_css( $attributes ),
54 $this->get_cart_sub_row_text_css( $attributes, 'Tablet' ),
55 $this->get_cart_sub_row_text_css( $attributes, 'Mobile' )
56 );
57 $css_generator->add_class_styles(
58 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child td:hover,
59 {{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child th:hover',
60 $this->get_cart_sub_row_text_hover_css( $attributes ),
61 $this->get_cart_sub_row_text_hover_css( $attributes, 'Tablet' ),
62 $this->get_cart_sub_row_text_hover_css( $attributes, 'Mobile' )
63 );
64 $css_generator->add_class_styles(
65 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr',
66 $this->get_cart_sub_row_last_css( $attributes ),
67 $this->get_cart_sub_row_last_css( $attributes, 'Tablet' ),
68 $this->get_cart_sub_row_last_css( $attributes, 'Mobile' )
69 );
70 $css_generator->add_class_styles(
71 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:hover',
72 $this->get_cart_sub_row_last_hover_css( $attributes ),
73 $this->get_cart_sub_row_last_hover_css( $attributes, 'Tablet' ),
74 $this->get_cart_sub_row_last_hover_css( $attributes, 'Mobile' )
75 );
76 $css_generator->add_class_styles(
77 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr td,
78 {{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr th',
79 $this->get_cart_sub_row_last_text_css( $attributes ),
80 $this->get_cart_sub_row_last_text_css( $attributes, 'Tablet' ),
81 $this->get_cart_sub_row_last_text_css( $attributes, 'Mobile' )
82 );
83 $css_generator->add_class_styles(
84 '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr td:hover,
85 {{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr th:hover',
86 $this->get_cart_sub_row_last_text_hover_css( $attributes ),
87 $this->get_cart_sub_row_last_text_hover_css( $attributes, 'Tablet' ),
88 $this->get_cart_sub_row_last_text_hover_css( $attributes, 'Mobile' )
89 );
90
91 return $css_generator->generate_css();
92 }
93 public function get_cart_sub_wrapper_css( $attributes, $device = '' ) {
94 $css = [];
95
96 $css['width'] = $attributes['tableWidth'] . '%';
97
98 return array_merge(
99 $css,
100 );
101 }
102
103 public function get_cart_sub_css( $attributes, $device = '' ) {
104 $alignment_css = [];
105 $css = [];
106
107 $css['display'] = 'flex';
108 $css['width'] = '100%';
109
110 if ( ! empty( $attributes['tableAlignment'][ 'value' . $device ] ) ) {
111 $alignment_css['justify-content'] = $attributes['tableAlignment'][ 'value' . $device ];
112 }
113
114 return array_merge(
115 $alignment_css,
116 $css,
117 );
118 }
119
120 public function get_cart_sub_row_css( $attributes, $device = '' ) {
121 return [ 'background' => Color::get_css( isset( $attributes['tableBackground'] ) ? $attributes['tableBackground'] : '' ) ];
122 }
123 public function get_cart_sub_row_hover_css( $attributes, $device = '' ) {
124 return [ 'background' => Color::get_css( isset( $attributes['tableBackgroundH'] ) ? $attributes['tableBackgroundH'] : '' ) ];
125 }
126
127 public function get_cart_sub_row_text_css( $attributes, $device = '' ) {
128 $typography_css = isset( $attributes['firstTableTypography'] ) && is_array( $attributes['firstTableTypography'] )
129 ? $attributes['firstTableTypography']
130 : [];
131
132 $typography_value = array_merge( $typography_css, [ 'font-weight' => '400' ] );
133 $typographyValueGlobal = ( isset( $attributes['firstTableTypographyGlobal'] ) ? $attributes['firstTableTypographyGlobal'] : '' );
134
135 return array_merge(
136 Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
137 [ 'color' => Color::get_css( isset( $attributes['tableColor'] ) ? $attributes['tableColor'] : '' ) ]
138 );
139
140 }
141
142 public function get_cart_sub_row_text_hover_css( $attributes, $device = '' ) {
143 return [ 'color' => Color::get_css( isset( $attributes['tableColorH'] ) ? $attributes['tableColorH'] : '' ) ];
144
145 }
146
147
148 public function get_cart_sub_row_last_css( $attributes, $device = '' ) {
149 return [ 'background' => Color::get_css( isset( $attributes['tableLastBackground'] ) ? $attributes['tableLastBackground'] : '' ) ];
150 }
151 public function get_cart_sub_row_last_hover_css( $attributes, $device = '' ) {
152 return [ 'background' => Color::get_css( isset( $attributes['tableLastBackgroundH'] ) ? $attributes['tableLastBackgroundH'] : '' ) ];
153 }
154
155 public function get_cart_sub_row_last_text_css( $attributes, $device = '' ) {
156
157 $typography_css = isset( $attributes['lastTableTypography'] ) && is_array( $attributes['lastTableTypography'] )
158 ? $attributes['lastTableTypography']
159 : [];
160
161 $typography_value = array_merge( $typography_css, [ 'font-weight' => '400' ] );
162 $typographyValueGlobal = ( isset( $attributes['lastTableTypographyGlobal'] ) ? $attributes['lastTableTypographyGlobal'] : '' );
163
164 return array_merge(
165 Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
166 [ 'color' => Color::get_css( isset( $attributes['tableLastColor'] ) ? $attributes['tableLastColor'] : '' ) ]
167 );
168
169 }
170 public function get_cart_sub_row_last_text_hover_css( $attributes, $device = '' ) {
171 return [ 'color' => Color::get_css( isset( $attributes['tableLastColorH'] ) ? $attributes['tableLastColorH'] : '' ) ];
172
173 }
174
175 public function render_block_content( $attributes, $content, $block_instance ) {
176 $attr_array = [];
177 $shortcode = '[storeengine_cart_sub_total_table ' . Helper::attr_shortcode( $attr_array ) . ']';
178 echo do_shortcode( $shortcode );
179 }
180
181 }
182