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/storeengine-cart-sub-table/block.php +191 -0 2.7.5 → 2.14.0 View file →
@@ -1,0 +1,191 @@
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 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_wrapper_css( $attributes, $device ); } )
32 + );
33 + $css_generator->add_class_styles(
34 + '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode',
35 + $this->get_cart_sub_css( $attributes ),
36 + $this->get_cart_sub_css( $attributes, 'Tablet' ),
37 + $this->get_cart_sub_css( $attributes, 'Mobile' ),
38 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_css( $attributes, $device ); } )
39 + );
40 + $css_generator->add_class_styles(
41 + '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child',
42 + $this->get_cart_sub_row_css( $attributes ),
43 + $this->get_cart_sub_row_css( $attributes, 'Tablet' ),
44 + $this->get_cart_sub_row_css( $attributes, 'Mobile' ),
45 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_row_css( $attributes, $device ); } )
46 + );
47 + $css_generator->add_class_styles(
48 + '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child:hover',
49 + $this->get_cart_sub_row_hover_css( $attributes ),
50 + $this->get_cart_sub_row_hover_css( $attributes, 'Tablet' ),
51 + $this->get_cart_sub_row_hover_css( $attributes, 'Mobile' ),
52 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_row_hover_css( $attributes, $device ); } )
53 + );
54 + $css_generator->add_class_styles(
55 + '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child td,
56 + {{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child th',
57 + $this->get_cart_sub_row_text_css( $attributes ),
58 + $this->get_cart_sub_row_text_css( $attributes, 'Tablet' ),
59 + $this->get_cart_sub_row_text_css( $attributes, 'Mobile' ),
60 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_row_text_css( $attributes, $device ); } )
61 + );
62 + $css_generator->add_class_styles(
63 + '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child td:hover,
64 + {{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:first-child th:hover',
65 + $this->get_cart_sub_row_text_hover_css( $attributes ),
66 + $this->get_cart_sub_row_text_hover_css( $attributes, 'Tablet' ),
67 + $this->get_cart_sub_row_text_hover_css( $attributes, 'Mobile' ),
68 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_row_text_hover_css( $attributes, $device ); } )
69 + );
70 + $css_generator->add_class_styles(
71 + '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr',
72 + $this->get_cart_sub_row_last_css( $attributes ),
73 + $this->get_cart_sub_row_last_css( $attributes, 'Tablet' ),
74 + $this->get_cart_sub_row_last_css( $attributes, 'Mobile' ),
75 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_row_last_css( $attributes, $device ); } )
76 + );
77 + $css_generator->add_class_styles(
78 + '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr:hover',
79 + $this->get_cart_sub_row_last_hover_css( $attributes ),
80 + $this->get_cart_sub_row_last_hover_css( $attributes, 'Tablet' ),
81 + $this->get_cart_sub_row_last_hover_css( $attributes, 'Mobile' ),
82 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_row_last_hover_css( $attributes, $device ); } )
83 + );
84 + $css_generator->add_class_styles(
85 + '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr td,
86 + {{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr th',
87 + $this->get_cart_sub_row_last_text_css( $attributes ),
88 + $this->get_cart_sub_row_last_text_css( $attributes, 'Tablet' ),
89 + $this->get_cart_sub_row_last_text_css( $attributes, 'Mobile' ),
90 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_row_last_text_css( $attributes, $device ); } )
91 + );
92 + $css_generator->add_class_styles(
93 + '{{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr td:hover,
94 + {{WRAPPER}} .storeengine-cart-sub-total-table-shortcode .storeengine-cart-sub-total-table tr th:hover',
95 + $this->get_cart_sub_row_last_text_hover_css( $attributes ),
96 + $this->get_cart_sub_row_last_text_hover_css( $attributes, 'Tablet' ),
97 + $this->get_cart_sub_row_last_text_hover_css( $attributes, 'Mobile' ),
98 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_sub_row_last_text_hover_css( $attributes, $device ); } )
99 + );
100 +
101 + return $css_generator->generate_css();
102 + }
103 + public function get_cart_sub_wrapper_css( $attributes, $device = '' ) {
104 + $css = [];
105 +
106 + $css['width'] = $attributes['tableWidth'] . '%';
107 +
108 + return array_merge(
109 + $css,
110 + );
111 + }
112 +
113 + public function get_cart_sub_css( $attributes, $device = '' ) {
114 + $alignment_css = [];
115 + $css = [];
116 +
117 + $css['display'] = 'flex';
118 + $css['width'] = '100%';
119 +
120 + if ( ! empty( $attributes['tableAlignment'][ 'value' . $device ] ) ) {
121 + $alignment_css['justify-content'] = $attributes['tableAlignment'][ 'value' . $device ];
122 + }
123 +
124 + return array_merge(
125 + $alignment_css,
126 + $css,
127 + );
128 + }
129 +
130 + public function get_cart_sub_row_css( $attributes, $device = '' ) {
131 + return [ 'background' => Color::get_css( isset( $attributes['tableBackground'] ) ? $attributes['tableBackground'] : '' ) ];
132 + }
133 + public function get_cart_sub_row_hover_css( $attributes, $device = '' ) {
134 + return [ 'background' => Color::get_css( isset( $attributes['tableBackgroundH'] ) ? $attributes['tableBackgroundH'] : '' ) ];
135 + }
136 +
137 + public function get_cart_sub_row_text_css( $attributes, $device = '' ) {
138 + $typography_css = isset( $attributes['firstTableTypography'] ) && is_array( $attributes['firstTableTypography'] )
139 + ? $attributes['firstTableTypography']
140 + : [];
141 +
142 + $typography_value = array_merge( $typography_css, [ 'font-weight' => '400' ] );
143 + $typographyValueGlobal = ( isset( $attributes['firstTableTypographyGlobal'] ) ? $attributes['firstTableTypographyGlobal'] : '' );
144 +
145 + return array_merge(
146 + Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
147 + [ 'color' => Color::get_css( isset( $attributes['tableColor'] ) ? $attributes['tableColor'] : '' ) ]
148 + );
149 +
150 + }
151 +
152 + public function get_cart_sub_row_text_hover_css( $attributes, $device = '' ) {
153 + return [ 'color' => Color::get_css( isset( $attributes['tableColorH'] ) ? $attributes['tableColorH'] : '' ) ];
154 +
155 + }
156 +
157 +
158 + public function get_cart_sub_row_last_css( $attributes, $device = '' ) {
159 + return [ 'background' => Color::get_css( isset( $attributes['tableLastBackground'] ) ? $attributes['tableLastBackground'] : '' ) ];
160 + }
161 + public function get_cart_sub_row_last_hover_css( $attributes, $device = '' ) {
162 + return [ 'background' => Color::get_css( isset( $attributes['tableLastBackgroundH'] ) ? $attributes['tableLastBackgroundH'] : '' ) ];
163 + }
164 +
165 + public function get_cart_sub_row_last_text_css( $attributes, $device = '' ) {
166 +
167 + $typography_css = isset( $attributes['lastTableTypography'] ) && is_array( $attributes['lastTableTypography'] )
168 + ? $attributes['lastTableTypography']
169 + : [];
170 +
171 + $typography_value = array_merge( $typography_css, [ 'font-weight' => '400' ] );
172 + $typographyValueGlobal = ( isset( $attributes['lastTableTypographyGlobal'] ) ? $attributes['lastTableTypographyGlobal'] : '' );
173 +
174 + return array_merge(
175 + Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
176 + [ 'color' => Color::get_css( isset( $attributes['tableLastColor'] ) ? $attributes['tableLastColor'] : '' ) ]
177 + );
178 +
179 + }
180 + public function get_cart_sub_row_last_text_hover_css( $attributes, $device = '' ) {
181 + return [ 'color' => Color::get_css( isset( $attributes['tableLastColorH'] ) ? $attributes['tableLastColorH'] : '' ) ];
182 +
183 + }
184 +
185 + public function render_block_content( $attributes, $content, $block_instance ) {
186 + $attr_array = [];
187 + $shortcode = '[storeengine_cart_sub_total_table ' . Helper::attr_shortcode( $attr_array ) . ']';
188 + echo do_shortcode( $shortcode );
189 + }
190 +
191 +}