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/academy-enroll-content/block.php +226 -0 2.7.6 → 2.14.0 View file →
@@ -1,0 +1,226 @@
1 +<?php
2 +namespace ABlocks\Blocks\AcademyEnrollContent;
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +use ABlocks\Classes\BlockBaseAbstract;
8 +use ABlocks\Classes\CssGenerator;
9 +use ABlocks\Classes\CssGeneratorV2;
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 +class Block extends BlockBaseAbstract {
19 + protected $block_name = 'academy-enroll-content';
20 +
21 + public function build_css( $attributes ) {
22 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
23 +
24 + $css_generator->add_class_styles(
25 + '{{WRAPPER}} .academy-widget-enroll__content-lists',
26 + $this->get_content_css( $attributes, '' ),
27 + $this->get_content_css( $attributes, 'Tablet' ),
28 + $this->get_content_css( $attributes, 'Mobile' ),
29 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_css( $attributes, $device ); } )
30 + );
31 + $css_generator->add_class_styles(
32 + '{{WRAPPER}} .academy-widget-enroll__content-lists:hover',
33 + $this->get_content_hover_css( $attributes, '' ),
34 + $this->get_content_hover_css( $attributes, 'Tablet' ),
35 + $this->get_content_hover_css( $attributes, 'Mobile' ),
36 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_hover_css( $attributes, $device ); } )
37 + );
38 + $css_generator->add_class_styles(
39 + '{{WRAPPER}} .academy-widget-enroll__content-lists li .academy-icon,
40 + {{WRAPPER}} .academy-icon--level:before,
41 + {{WRAPPER}} .academy-icon--video-lesson:before',
42 + $this->get_content_icon_css( $attributes, '' ),
43 + $this->get_content_icon_css( $attributes, 'Tablet' ),
44 + $this->get_content_icon_css( $attributes, 'Mobile' ),
45 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_icon_css( $attributes, $device ); } )
46 + );
47 + $css_generator->add_class_styles(
48 + '{{WRAPPER}} .academy-widget-enroll__content-lists li .academy-icon:hover,
49 + {{WRAPPER}} .academy-icon--level:hover::before,
50 + {{WRAPPER}} .academy-icon--video-lesson:hover::before',
51 + $this->get_content_icon_hover_css( $attributes, '' ),
52 + $this->get_content_icon_hover_css( $attributes, 'Tablet' ),
53 + $this->get_content_icon_hover_css( $attributes, 'Mobile' ),
54 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_icon_hover_css( $attributes, $device ); } )
55 + );
56 + $css_generator->add_class_styles(
57 + '{{WRAPPER}} .academy-widget-enroll__content-lists li',
58 + $this->get_content_list_css( $attributes, '' ),
59 + $this->get_content_list_css( $attributes, 'Tablet' ),
60 + $this->get_content_list_css( $attributes, 'Mobile' ),
61 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_list_css( $attributes, $device ); } )
62 + );
63 + $css_generator->add_class_styles(
64 + '{{WRAPPER}} .academy-widget-enroll__content-lists li:hover',
65 + $this->get_content_list_hover_css( $attributes, '' ),
66 + $this->get_content_list_hover_css( $attributes, 'Tablet' ),
67 + $this->get_content_list_hover_css( $attributes, 'Mobile' ),
68 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_list_hover_css( $attributes, $device ); } )
69 + );
70 + $css_generator->add_class_styles(
71 + '{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-btn',
72 + $this->get_share_button_css( $attributes, '' ),
73 + $this->get_share_button_css( $attributes, 'Tablet' ),
74 + $this->get_share_button_css( $attributes, 'Mobile' ),
75 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_share_button_css( $attributes, $device ); } )
76 + );
77 + $css_generator->add_class_styles(
78 + '{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-btn:hover',
79 + $this->get_share_button_hover_css( $attributes, '' ),
80 + $this->get_share_button_hover_css( $attributes, 'Tablet' ),
81 + $this->get_share_button_hover_css( $attributes, 'Mobile' ),
82 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_share_button_hover_css( $attributes, $device ); } )
83 + );
84 + $css_generator->add_class_styles(
85 + '{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-course__wishlist',
86 + $this->get_wishlist_button_css( $attributes, '' ),
87 + $this->get_wishlist_button_css( $attributes, 'Tablet' ),
88 + $this->get_wishlist_button_css( $attributes, 'Mobile' ),
89 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wishlist_button_css( $attributes, $device ); } )
90 + );
91 + $css_generator->add_class_styles(
92 + '{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-course__wishlist:hover',
93 + $this->get_wishlist_button_hover_css( $attributes, '' ),
94 + $this->get_wishlist_button_hover_css( $attributes, 'Tablet' ),
95 + $this->get_wishlist_button_hover_css( $attributes, 'Mobile' ),
96 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wishlist_button_hover_css( $attributes, $device ); } )
97 + );
98 + $css_generator->add_class_styles(
99 + '{{WRAPPER}} .academy-widget-enroll__wishlist-and-share .academy-btn i.academy-icon',
100 + $this->get_button_icon_css( $attributes, '' ),
101 + $this->get_button_icon_css( $attributes, 'Tablet' ),
102 + $this->get_button_icon_css( $attributes, 'Mobile' ),
103 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_button_icon_css( $attributes, $device ); } )
104 + );
105 +
106 + return $css_generator->generate_css();
107 + }
108 +
109 + public function get_content_css( $attributes, $device = '' ) {
110 + return [ 'background' => Color::get_css( isset( $attributes['contentBg'] ) ? $attributes['contentBg'] : '#fff' ) ];
111 + }
112 +
113 + public function get_content_hover_css( $attributes, $device = '' ) {
114 + return array_merge(
115 + [ 'background' => Color::get_css( isset( $attributes['contentBgH'] ) ? $attributes['contentBgH'] : '#fff' ) ],
116 + Range::get_css([
117 + 'attributeValue' => $attributes['contentTransition'],
118 + 'attribute_object_key' => 'value',
119 + 'isResponsive' => false,
120 + 'defaultValue' => 0,
121 + 'hasUnit' => false,
122 + 'unitDefaultValue' => 's',
123 + 'property' => 'transition-duration',
124 + 'device' => $device,
125 + ]),
126 + );
127 +
128 + }
129 +
130 + public function get_content_icon_css( $attributes, $device = '' ) {
131 + return array_merge(
132 + [ 'color' => Color::get_css( isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '#595959' ) ],
133 + Range::get_css([
134 + 'attributeValue' => $attributes['iconSize'],
135 + 'attribute_object_key' => 'value',
136 + 'isResponsive' => true,
137 + 'defaultValue' => 14,
138 + 'hasUnit' => true,
139 + 'unitDefaultValue' => 'px',
140 + 'property' => 'font-size',
141 + 'device' => $device,
142 + ]),
143 + );
144 + }
145 +
146 + public function get_content_icon_hover_css( $attributes, $device = '' ) {
147 + return [ 'color' => Color::get_css( isset( $attributes['iconColorH'] ) ? $attributes['iconColorH'] : '#595959' ) ];
148 + }
149 +
150 + public function get_content_list_css( $attributes, $device = '' ) {
151 + $typographyValueGlobal = ! empty( $attributes['listTypographyGlobal'] ) ? $attributes['listTypographyGlobal'] : '';
152 + $typography_value = ! empty( $attributes['listTypography'] ) ?
153 + Typography::get_css( $attributes['listTypography'], '', $device, $typographyValueGlobal )
154 + : array();
155 +
156 + return array_merge(
157 + [ 'color' => Color::get_css( isset( $attributes['listColor'] ) ? $attributes['listColor'] : '#111' ) ],
158 + $typography_value
159 + );
160 +
161 + }
162 +
163 + public function get_content_list_hover_css( $attributes, $device = '' ) {
164 + return [ 'color' => Color::get_css( isset( $attributes['listColorH'] ) ? $attributes['listColorH'] : '#111' ) ];
165 + }
166 +
167 + public function get_share_button_css( $attributes, $device = '' ) {
168 + $typographyValueGlobal = ! empty( $attributes['shareTypographyGlobal'] ) ? $attributes['shareTypographyGlobal'] : '';
169 + $typography_value = ! empty( $attributes['shareTypography'] ) ?
170 + Typography::get_css( $attributes['shareTypography'], '', $device, $typographyValueGlobal )
171 + : array();
172 +
173 + return array_merge(
174 + [ 'color' => Color::get_css( isset( $attributes['shareColor'] ) ? $attributes['shareColor'] : '#444' ) ],
175 + [ 'background' => Color::get_css( isset( $attributes['shareBg'] ) ? $attributes['shareBg'] : '#fff' ) ],
176 + $typography_value,
177 + Dimensions::get_css( $attributes['sharePadding'], 'padding', $device ),
178 + Border::get_css( $attributes['shareBorder'], '', $device ),
179 + );
180 + }
181 +
182 + public function get_share_button_hover_css( $attributes, $device = '' ) {
183 + return array_merge(
184 + [ 'color' => Color::get_css( isset( $attributes['shareColorH'] ) ? $attributes['shareColorH'] : '#444' ) ],
185 + [ 'background' => Color::get_css( isset( $attributes['shareBgH'] ) ? $attributes['shareBgH'] : '#fff' ) ],
186 + Border::get_hover_css( $attributes['shareBorder'], '', $device )
187 + );
188 + }
189 +
190 + public function get_wishlist_button_css( $attributes, $device = '' ) {
191 + return array_merge(
192 + [ 'color' => Color::get_css( isset( $attributes['wishlistColor'] ) ? $attributes['wishlistColor'] : '#fff' ) ],
193 + [ 'background' => Color::get_css( isset( $attributes['wishlistBg'] ) ? $attributes['wishlistBg'] : '#7b68ee' ) ],
194 + );
195 + }
196 +
197 + public function get_wishlist_button_hover_css( $attributes, $device = '' ) {
198 + return array_merge(
199 + [ 'color' => Color::get_css( isset( $attributes['wishlistColorH'] ) ? $attributes['wishlistColorH'] : '#fff' ) ],
200 + [ 'background' => Color::get_css( isset( $attributes['wishlistBgH'] ) ? $attributes['wishlistBgH'] : '#7b68ee' ) ],
201 + );
202 +
203 + }
204 +
205 + public function get_button_icon_css( $attributes, $device = '' ) {
206 + return array_merge(
207 + Range::get_css([
208 + 'attributeValue' => $attributes['buttonIconSize'],
209 + 'attribute_object_key' => 'value',
210 + 'isResponsive' => true,
211 + 'defaultValue' => 14,
212 + 'hasUnit' => true,
213 + 'unitDefaultValue' => 'px',
214 + 'property' => 'font-size',
215 + 'device' => $device,
216 + ]),
217 + );
218 + }
219 +
220 + public function render_block_content( $attributes, $content, $block_instance ) {
221 + $attr_array = [];
222 +
223 + $shortcode = '[academy_course_enroll_widget_content ' . Helper::attr_shortcode( $attr_array ) . ']';
224 + echo do_shortcode( $shortcode );
225 + }
226 +}