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-list/block.php +213 -0 2.7.6 → 2.14.0 View file →
@@ -1,0 +1,213 @@
1 +<?php
2 +
3 +namespace ABlocks\Blocks\StoreengineCartList;
4 +
5 +if ( ! defined( 'ABSPATH' ) ) {
6 + exit;
7 +}
8 +
9 +use ABlocks\Classes\BlockBaseAbstract;
10 +use ABlocks\Classes\CssGenerator;
11 +use ABlocks\Helper;
12 +use ABlocks\Controls\Typography;
13 +use ABlocks\Controls\Background;
14 +use ABlocks\Controls\Border;
15 +use ABlocks\Controls\Dimensions;
16 +use ABlocks\Controls\Range;
17 +use ABlocks\Controls\Color;
18 +
19 +class Block extends BlockBaseAbstract {
20 + protected $block_name = 'storeengine-cart-list';
21 +
22 + public function build_css( $attributes ) {
23 + $css_generator = new CssGenerator( $attributes, $this->block_name );
24 +
25 + $css_generator->add_class_styles(
26 + '{{WRAPPER}} .storeengine-cart-table',
27 + $this->get_cart_list_table_css( $attributes ),
28 + $this->get_cart_list_table_css( $attributes, 'Tablet' ),
29 + $this->get_cart_list_table_css( $attributes, 'Mobile' ),
30 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_table_css( $attributes, $device ); } )
31 + );
32 + $css_generator->add_class_styles(
33 + '{{WRAPPER}} .storeengine-cart-table:hover',
34 + $this->get_cart_list_table_hover_css( $attributes ),
35 + $this->get_cart_list_table_hover_css( $attributes, 'Tablet' ),
36 + $this->get_cart_list_table_hover_css( $attributes, 'Mobile' ),
37 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_table_hover_css( $attributes, $device ); } )
38 + );
39 + $css_generator->add_class_styles(
40 + '{{WRAPPER}} .storeengine-cart-table .storeengine-cart-table__head tr',
41 + $this->get_cart_list_table_header_css( $attributes ),
42 + $this->get_cart_list_table_header_css( $attributes, 'Tablet' ),
43 + $this->get_cart_list_table_header_css( $attributes, 'Mobile' ),
44 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_table_header_css( $attributes, $device ); } )
45 + );
46 + $css_generator->add_class_styles(
47 + '{{WRAPPER}} .storeengine-cart-table .storeengine-cart-table__head tr:hover',
48 + $this->get_cart_list_table_header_hover_css( $attributes ),
49 + $this->get_cart_list_table_header_hover_css( $attributes, 'Tablet' ),
50 + $this->get_cart_list_table_header_hover_css( $attributes, 'Mobile' ),
51 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_table_header_hover_css( $attributes, $device ); } )
52 + );
53 + $css_generator->add_class_styles(
54 + '{{WRAPPER}} .storeengine-cart-list-table-shortcode .storeengine-cart-table__head tr th',
55 + $this->get_cart_list_table_header_text_css( $attributes ),
56 + $this->get_cart_list_table_header_text_css( $attributes, 'Tablet' ),
57 + $this->get_cart_list_table_header_text_css( $attributes, 'Mobile' ),
58 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_table_header_text_css( $attributes, $device ); } )
59 + );
60 + $css_generator->add_class_styles(
61 + '{{WRAPPER}} .storeengine-cart-product .storeengine-cart-product__content .storeengine-cart-product-title a',
62 + $this->get_cart_list_product_title( $attributes ),
63 + $this->get_cart_list_product_title( $attributes, 'Tablet' ),
64 + $this->get_cart_list_product_title( $attributes, 'Mobile' ),
65 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_product_title( $attributes, $device ); } )
66 + );
67 + $css_generator->add_class_styles(
68 + '{{WRAPPER}} .storeengine-cart-product .storeengine-cart-product__content .storeengine-cart-product-title a:hover',
69 + $this->get_cart_list_product_title_hover_css( $attributes ),
70 + $this->get_cart_list_product_title_hover_css( $attributes, 'Tablet' ),
71 + $this->get_cart_list_product_title_hover_css( $attributes, 'Mobile' ),
72 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_product_title_hover_css( $attributes, $device ); } )
73 + );
74 + $css_generator->add_class_styles(
75 + '{{WRAPPER}} .storeengine-cart-product__content .storeengine-cart-product-price',
76 + $this->get_cart_list_subtitle_css( $attributes ),
77 + $this->get_cart_list_subtitle_css( $attributes, 'Tablet' ),
78 + $this->get_cart_list_subtitle_css( $attributes, 'Mobile' ),
79 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_subtitle_css( $attributes, $device ); } )
80 + );
81 + $css_generator->add_class_styles(
82 + '{{WRAPPER}} .storeengine-cart-product__content .storeengine-cart-product-price:hover',
83 + $this->get_cart_list_subtitle_hover_css( $attributes ),
84 + $this->get_cart_list_subtitle_hover_css( $attributes, 'Tablet' ),
85 + $this->get_cart_list_subtitle_hover_css( $attributes, 'Mobile' ),
86 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_subtitle_hover_css( $attributes, $device ); } )
87 + );
88 + $css_generator->add_class_styles(
89 + '{{WRAPPER}} .storeengine-cart-list-table-shortcode .storeengine-cart-table__body-td .storeengine-price bdi',
90 + $this->get_cart_list_product_price_css( $attributes ),
91 + $this->get_cart_list_product_price_css( $attributes, 'Tablet' ),
92 + $this->get_cart_list_product_price_css( $attributes, 'Mobile' ),
93 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_product_price_css( $attributes, $device ); } )
94 + );
95 + $css_generator->add_class_styles(
96 + '{{WRAPPER}} .storeengine-cart-list-table-shortcode .storeengine-cart-table__body-td .storeengine-price bdi:hover',
97 + $this->get_cart_list_product_price_hover_css( $attributes ),
98 + $this->get_cart_list_product_price_hover_css( $attributes, 'Tablet' ),
99 + $this->get_cart_list_product_price_hover_css( $attributes, 'Mobile' ),
100 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_cart_list_product_price_hover_css( $attributes, $device ); } )
101 + );
102 +
103 + return $css_generator->generate_css();
104 + }
105 +
106 + public function get_cart_list_table_css( $attributes, $device = '' ) {
107 + return [ 'background' => Color::get_css( isset( $attributes['tableBackground'] ) ? $attributes['tableBackground'] : '' ) ];
108 +
109 + }
110 + public function get_cart_list_table_hover_css( $attributes, $device = '' ) {
111 + return array_merge(
112 + [ 'background' => Color::get_css( isset( $attributes['tableBackgroundH'] ) ? $attributes['tableBackgroundH'] : '' ) ],
113 + Range::get_css( [
114 + 'attributeValue' => isset( $attributes['tableTransition'] ) ? $attributes['tableTransition'] : '',
115 + 'attribute_object_key' => 'value',
116 + 'defaultValue' => 0,
117 + 'unitDefaultValue' => 's',
118 + 'property' => 'transition-duration',
119 + 'device' => $device,
120 + ] ),
121 + );
122 + }
123 +
124 + public function get_cart_list_table_header_css( $attributes, $device = '' ) {
125 + return [ 'background' => Color::get_css( isset( $attributes['tableHeaderBackground'] ) ? $attributes['tableHeaderBackground'] : '' ) ];
126 + }
127 +
128 + public function get_cart_list_table_header_hover_css( $attributes, $device = '' ) {
129 + return array_merge(
130 + Range::get_css( [
131 + 'attributeValue' => isset( $attributes['tableTransition'] ) ? $attributes['tableTransition'] : '',
132 + 'attribute_object_key' => 'value',
133 + 'defaultValue' => 0,
134 + 'unitDefaultValue' => 's',
135 + 'property' => 'transition-duration',
136 + 'device' => $device,
137 + ] ),
138 + [ 'background' => Color::get_css( isset( $attributes['tableHeaderBackgroundH'] ) ? $attributes['tableHeaderBackgroundH'] : '' ) ]
139 + );
140 + }
141 +
142 + public function get_cart_list_table_header_text_css( $attributes, $device = '' ) {
143 + $typography = isset( $attributes['tableHeaderTypography'] ) && is_array( $attributes['tableHeaderTypography'] )
144 + ? $attributes['tableHeaderTypography']
145 + : [];
146 +
147 + $typography_value = array_merge( $typography, [ 'font-weight' => '400' ] );
148 + $typographyValueGlobal = ( isset( $attributes['tableHeaderTypographyGlobal'] ) ? $attributes['tableHeaderTypographyGlobal'] : '' );
149 +
150 + return array_merge(
151 + Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
152 + );
153 + }
154 +
155 + public function get_cart_list_product_title( $attributes, $device = '' ) {
156 + $typography = isset( $attributes['productTilteTypography'] ) && is_array( $attributes['productTilteTypography'] )
157 + ? $attributes['productTilteTypography']
158 + : array();
159 +
160 + $typography_value = array_merge( $typography, [ 'font-weight' => '400' ] );
161 + $typographyValueGlobal = ( isset( $attributes['productTitleTypographyGlobal'] ) ? $attributes['productTitleTypographyGlobal'] : '' );
162 +
163 + return array_merge(
164 + Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
165 + [ 'color' => Color::get_css( isset( $attributes['productTitleColor'] ) ? $attributes['productTitleColor'] : '' ) ]
166 + );
167 +
168 + }
169 + public function get_cart_list_product_title_hover_css( $attributes, $device = '' ) {
170 + return [ 'color' => Color::get_css( isset( $attributes['productTitleColorH'] ) ? $attributes['productTitleColorH'] : '' ) ];
171 + }
172 +
173 + public function get_cart_list_subtitle_css( $attributes, $device = '' ) {
174 + $typography = isset( $attributes['productsubTitleTypography'] ) && is_array( $attributes['productsubTitleTypography'] )
175 + ? $attributes['productsubTitleTypography']
176 + : [];
177 +
178 + $typography_value = array_merge( $typography, [ 'font-weight' => '400' ] );
179 + $typographyValueGlobal = ( isset( $attributes['productsubTitleTypographyGlobal'] ) ? $attributes['productsubTitleTypographyGlobal'] : '' );
180 + return array_merge(
181 + Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
182 + [ 'color' => Color::get_css( isset( $attributes['productSubTiteColor'] ) ? $attributes['productSubTiteColor'] : '' ) ]
183 + );
184 +
185 + }
186 +
187 + public function get_cart_list_subtitle_hover_css( $attributes, $device = '' ) {
188 + return [ 'color' => Color::get_css( isset( $attributes['productSubTiteColorH'] ) ? $attributes['productSubTiteColorH'] : '' ) ];
189 + }
190 + public function get_cart_list_product_price_css( $attributes, $device = '' ) {
191 + $typography = isset( $attributes['productPriceTypography'] ) && is_array( $attributes['productPriceTypography'] )
192 + ? $attributes['productPriceTypography']
193 + : [];
194 +
195 + $typography_value = array_merge( $typography, [ 'font-weight' => '400' ] );
196 + $typographyValueGlobal = ( isset( $attributes['productPriceTypographyGlobal'] ) ? $attributes['productPriceTypographyGlobal'] : '' );
197 + return array_merge(
198 + Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
199 + [ 'color' => Color::get_css( isset( $attributes['productPriceColor'] ) ? $attributes['productPriceColor'] : '' ) ]
200 + );
201 +
202 + }
203 + public function get_cart_list_product_price_hover_css( $attributes, $device = '' ) {
204 + return [ 'color' => Color::get_css( isset( $attributes['productPriceColorH'] ) ? $attributes['productPriceColorH'] : '' ) ];
205 + }
206 +
207 + public function render_block_content( $attributes, $content, $block_instance ) {
208 + $attr_array = [];
209 + $shortcode = '[storeengine_cart_list_table ' . Helper::attr_shortcode( $attr_array ) . ']';
210 + echo do_shortcode( $shortcode );
211 + }
212 +
213 +}