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-review-list/block.php +306 -0 2.7.6 → 2.14.0 View file →
@@ -1,0 +1,306 @@
1 +<?php
2 +namespace ABlocks\Blocks\AcademyReviewList;
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
8 +use ABlocks\Classes\BlockBaseAbstract;
9 +use ABlocks\Classes\CssGenerator;
10 +use ABlocks\Classes\CssGeneratorV2;
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\BoxShadow;
18 +use ABlocks\Controls\Color;
19 +
20 +
21 +class Block extends BlockBaseAbstract {
22 + protected $block_name = 'academy-review-list';
23 +
24 + public function build_css( $attributes ) {
25 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
26 +
27 + $css_generator->add_class_styles(
28 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-thumnail img',
29 + $this->get_avatar_css( $attributes, '' ),
30 + $this->get_avatar_css( $attributes, 'Tablet' ),
31 + $this->get_avatar_css( $attributes, 'Mobile' ),
32 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_avatar_css( $attributes, $device ); } )
33 + );
34 + $css_generator->add_class_styles(
35 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-content .academy-review-meta__author',
36 + $this->get_author_css( $attributes, '' ),
37 + $this->get_author_css( $attributes, 'Tablet' ),
38 + $this->get_author_css( $attributes, 'Mobile' ),
39 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_author_css( $attributes, $device ); } )
40 + );
41 + $css_generator->add_class_styles(
42 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-content .academy-review-meta__author:hover',
43 + $this->get_author_hover_css( $attributes, '' ),
44 + $this->get_author_hover_css( $attributes, 'Tablet' ),
45 + $this->get_author_hover_css( $attributes, 'Mobile' ),
46 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_author_hover_css( $attributes, $device ); } )
47 + );
48 + $css_generator->add_class_styles(
49 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-content .academy-review-meta__published-date',
50 + $this->get_date_time_css( $attributes, '' ),
51 + $this->get_date_time_css( $attributes, 'Tablet' ),
52 + $this->get_date_time_css( $attributes, 'Mobile' ),
53 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_date_time_css( $attributes, $device ); } )
54 + );
55 + $css_generator->add_class_styles(
56 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-content .academy-review-meta__published-date:hover',
57 + $this->get_date_time_hover_css( $attributes, '' ),
58 + $this->get_date_time_hover_css( $attributes, 'Tablet' ),
59 + $this->get_date_time_hover_css( $attributes, 'Mobile' ),
60 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_date_time_hover_css( $attributes, $device ); } )
61 + );
62 + $css_generator->add_class_styles(
63 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-content .academy-review-description p',
64 + $this->get_description_css( $attributes, '' ),
65 + $this->get_description_css( $attributes, 'Tablet' ),
66 + $this->get_description_css( $attributes, 'Mobile' ),
67 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_description_css( $attributes, $device ); } )
68 + );
69 + $css_generator->add_class_styles(
70 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-content .academy-review-description p:hover',
71 + $this->get_description_hover_css( $attributes, '' ),
72 + $this->get_description_hover_css( $attributes, 'Tablet' ),
73 + $this->get_description_hover_css( $attributes, 'Mobile' ),
74 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_description_hover_css( $attributes, $device ); } )
75 + );
76 + $css_generator->add_class_styles(
77 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-thumnail .academy-review__rating',
78 + $this->get_summary_css( $attributes, '' ),
79 + $this->get_summary_css( $attributes, 'Tablet' ),
80 + $this->get_summary_css( $attributes, 'Mobile' ),
81 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_summary_css( $attributes, $device ); } )
82 + );
83 + $css_generator->add_class_styles(
84 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-thumnail .academy-review__rating:hover',
85 + $this->get_summary_hover_css( $attributes, '' ),
86 + $this->get_summary_hover_css( $attributes, 'Tablet' ),
87 + $this->get_summary_hover_css( $attributes, 'Mobile' ),
88 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_summary_hover_css( $attributes, $device ); } )
89 + );
90 + $css_generator->add_class_styles(
91 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-thumnail .academy-group-star i',
92 + $this->get_summary_icon_css( $attributes, '' ),
93 + $this->get_summary_icon_css( $attributes, 'Tablet' ),
94 + $this->get_summary_icon_css( $attributes, 'Mobile' ),
95 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_summary_icon_css( $attributes, $device ); } )
96 + );
97 + $css_generator->add_class_styles(
98 + '{{WRAPPER}} .academy-review-list li .academy-review_container .academy-review-thumnail .academy-group-star i:hover',
99 + $this->get_summary_icon_hover_css( $attributes, '' ),
100 + $this->get_summary_icon_hover_css( $attributes, 'Tablet' ),
101 + $this->get_summary_icon_hover_css( $attributes, 'Mobile' ),
102 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_summary_icon_hover_css( $attributes, $device ); } )
103 + );
104 +
105 + return $css_generator->generate_css();
106 + }
107 +
108 + public function get_avatar_css( $attributes, $device = '' ) {
109 + return array_merge(
110 + Range::get_css([
111 + 'attributeValue' => $attributes['avatarWidth'],
112 + 'attribute_object_key' => 'value',
113 + 'isResponsive' => true,
114 + 'defaultValue' => 50,
115 + 'hasUnit' => true,
116 + 'unitDefaultValue' => 'px',
117 + 'property' => 'width',
118 + 'device' => $device,
119 + ]),
120 + Range::get_css([
121 + 'attributeValue' => $attributes['avatarHeight'],
122 + 'attribute_object_key' => 'value',
123 + 'isResponsive' => true,
124 + 'defaultValue' => 50,
125 + 'hasUnit' => true,
126 + 'unitDefaultValue' => 'px',
127 + 'property' => 'height',
128 + 'device' => $device,
129 + ]),
130 + );
131 + }
132 +
133 + public function get_author_css( $attributes, $device = '' ) {
134 + $typographyValueGlobal = ! empty( $attributes['authorTypographyGlobal'] ) ? $attributes['authorTypographyGlobal'] : '';
135 + $typography_value = ! empty( $attributes['authorTypography'] ) ?
136 + Typography::get_css( $attributes['authorTypography'], '', $device, $typographyValueGlobal )
137 + : array();
138 +
139 + return array_merge(
140 + [ 'color' => Color::get_css( isset( $attributes['authorColor'] ) ? $attributes['authorColor'] : '#111' ) ],
141 + $typography_value,
142 + );
143 + }
144 +
145 + public function get_author_hover_css( $attributes, $device = '' ) {
146 + return array_merge(
147 + [ 'color' => Color::get_css( isset( $attributes['authorHoverColor'] ) ? $attributes['authorHoverColor'] : '#111' ) ],
148 + Range::get_css([
149 + 'attributeValue' => $attributes['authorTransition'],
150 + 'attribute_object_key' => 'value',
151 + 'isResponsive' => false,
152 + 'defaultValue' => 0,
153 + 'hasUnit' => false,
154 + 'unitDefaultValue' => 's',
155 + 'property' => 'transition-duration',
156 + 'device' => $device,
157 + ]),
158 + );
159 +
160 + }
161 +
162 + public function get_date_time_css( $attributes, $device = '' ) {
163 + $typographyValueGlobal = ! empty( $attributes['dateTypographyGlobal'] ) ? $attributes['dateTypographyGlobal'] : '';
164 + $typography_value = ! empty( $attributes['dateTypography'] ) ?
165 + Typography::get_css( $attributes['dateTypography'], '', $device, $typographyValueGlobal )
166 + : array();
167 +
168 + return array_merge(
169 + [ 'color' => Color::get_css( isset( $attributes['dateColor'] ) ? $attributes['dateColor'] : '#111' ) ],
170 + $typography_value,
171 + );
172 + }
173 +
174 + public function get_date_time_hover_css( $attributes, $device = '' ) {
175 + return array_merge(
176 + [ 'color' => Color::get_css( isset( $attributes['dateHoverColor'] ) ? $attributes['dateHoverColor'] : '#111' ) ],
177 + Range::get_css([
178 + 'attributeValue' => $attributes['dateTransition'],
179 + 'attribute_object_key' => 'value',
180 + 'isResponsive' => false,
181 + 'defaultValue' => 0,
182 + 'hasUnit' => false,
183 + 'unitDefaultValue' => 's',
184 + 'property' => 'transition-duration',
185 + 'device' => $device,
186 + ]),
187 + );
188 +
189 + }
190 + public function get_description_css( $attributes, $device = '' ) {
191 + $typographyValueGlobal = ! empty( $attributes['desTypographyGlobal'] ) ? $attributes['desTypographyGlobal'] : '';
192 + $typography_value = ! empty( $attributes['desTypography'] ) ?
193 + Typography::get_css( $attributes['desTypography'], '', $device, $typographyValueGlobal )
194 + : array();
195 +
196 + return array_merge(
197 + [ 'color' => Color::get_css( isset( $attributes['desColor'] ) ? $attributes['desColor'] : '#111' ) ],
198 + $typography_value,
199 + );
200 + }
201 +
202 + public function get_description_hover_css( $attributes, $device = '' ) {
203 + return array_merge(
204 + [ 'color' => Color::get_css( isset( $attributes['desHoverColor'] ) ? $attributes['desHoverColor'] : '#111' ) ],
205 + Range::get_css([
206 + 'attributeValue' => $attributes['desTransition'],
207 + 'attribute_object_key' => 'value',
208 + 'isResponsive' => false,
209 + 'defaultValue' => 0,
210 + 'hasUnit' => false,
211 + 'unitDefaultValue' => 's',
212 + 'property' => 'transition-duration',
213 + 'device' => $device,
214 + ]),
215 + );
216 +
217 + }
218 +
219 + public function get_summary_css( $attributes, $device = '' ) {
220 + $typographyValueGlobal = ! empty( $attributes['sumTypographyGlobal'] ) ? $attributes['sumTypographyGlobal'] : '';
221 + $typography_value = ! empty( $attributes['sumTypography'] ) ?
222 + Typography::get_css( $attributes['sumTypography'], '', $device, $typographyValueGlobal )
223 + : array();
224 +
225 + return array_merge(
226 + [ 'color' => Color::get_css( isset( $attributes['sumColor'] ) ? $attributes['sumColor'] : '#111' ) ],
227 + $typography_value,
228 + );
229 + }
230 +
231 + public function get_summary_hover_css( $attributes, $device = '' ) {
232 + return array_merge(
233 + [ 'color' => Color::get_css( isset( $attributes['sumColorH'] ) ? $attributes['sumColorH'] : '#111' ) ],
234 + Range::get_css([
235 + 'attributeValue' => $attributes['sumTransition'],
236 + 'attribute_object_key' => 'value',
237 + 'isResponsive' => false,
238 + 'defaultValue' => 0,
239 + 'hasUnit' => false,
240 + 'unitDefaultValue' => 's',
241 + 'property' => 'transition-duration',
242 + 'device' => $device,
243 + ]),
244 + );
245 + }
246 +
247 + public function get_summary_icon_css( $attributes, $device = '' ) {
248 + return array_merge(
249 + [ 'color' => Color::get_css( isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '#f4c150' ) ],
250 + Range::get_css([
251 + 'attributeValue' => $attributes['iconSize'],
252 + 'attribute_object_key' => 'value',
253 + 'isResponsive' => true,
254 + 'defaultValue' => 50,
255 + 'hasUnit' => true,
256 + 'unitDefaultValue' => 'px',
257 + 'property' => 'font-size',
258 + 'device' => $device,
259 + ]),
260 + );
261 +
262 + }
263 +
264 + public function get_summary_icon_hover_css( $attributes, $device = '' ) {
265 + return [ 'color' => Color::get_css( isset( $attributes['iconColorH'] ) ? $attributes['iconColorH'] : '#f4c150' ) ];
266 + }
267 +
268 + public function render_block_content( $attributes, $content, $block_instance ) {
269 + $course_addition_info_id = method_exists( Helper::class, 'get_attribute_value' ) ? (int) Helper::get_attribute_value( $attributes, 'course_id' ) : (int) ( $attributes['course_id'] ?? 0 );
270 + $course_addition_info_attr = method_exists( Helper::class, 'attr_shortcode' ) ? Helper::attr_shortcode( [ 'course_id' => $course_addition_info_id ] ) : 'course_id="' . esc_attr( $course_addition_info_id ) . '"';
271 + $course_addition_info_shortcode = '[academy_course_reviews ' . trim( $course_addition_info_attr ) . ']';
272 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
273 + $course_addition_info_is_edit = defined( 'REST_REQUEST' ) && REST_REQUEST && ( $_REQUEST['context'] ?? '' ) === 'edit';
274 + if ( $course_addition_info_is_edit && $course_addition_info_id && ( $course_addition_info_post = get_post( $course_addition_info_id ) ) ) {
275 + global $post, $wp_query;
276 + $course_addition_info_prev_post = $post;
277 + $course_addition_info_prev_query = $wp_query;
278 + $post = $course_addition_info_post;
279 + setup_postdata( $post );
280 + $wp_query = new \WP_Query( [
281 + 'p' => $course_addition_info_id,
282 + 'post_type' => $course_addition_info_post->post_type,
283 + 'no_found_rows' => 1,
284 + 'posts_per_page' => 1
285 + ] );
286 + $wp_query->is_singular = 1;
287 + $wp_query->is_single = ( $course_addition_info_post->post_type !== 'page' );
288 + $wp_query->is_page = ( $course_addition_info_post->post_type === 'page' );
289 + $wp_query->is_home = $wp_query->is_front_page = 0;
290 + if ( method_exists( $wp_query, 'set' ) ) {
291 + $wp_query->set( 'is_main_query', 1 );
292 + }
293 + $course_addition_info_html = do_shortcode( $course_addition_info_shortcode );
294 + wp_reset_postdata();
295 + $wp_query = $course_addition_info_prev_query;
296 + $post = $course_addition_info_prev_post;
297 + } else {
298 + $course_addition_info_html = do_shortcode( $course_addition_info_shortcode );
299 + }//end if
300 + if ( $course_addition_info_is_edit && trim( wp_strip_all_tags( $course_addition_info_html ) ) === '' ) {
301 + $course_addition_info_html = '<div class="no-data-message"><strong>Editor Only:</strong> No output. Check course ID or data.</div>';
302 + }
303 + return $course_addition_info_html;
304 + }
305 +
306 +}