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 / academy-course-instructor / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.11.1, at includes/blocks/academy-course-instructor/block.php

217 lines 8.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\AcademyCourseInstructor;
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
22 class Block extends BlockBaseAbstract {
23 protected $block_name = 'academy-course-instructor';
24
25 public function build_css( $attributes ) {
26 $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
27
28 $css_generator->add_class_styles(
29 '{{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-info__thumbnail img',
30 $this->get_avatar_image_css( $attributes, '' ),
31 $this->get_avatar_image_css( $attributes, 'Tablet' ),
32 $this->get_avatar_image_css( $attributes, 'Mobile' )
33 );
34
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-review__title,
37 {{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-info__content .instructor-title',
38 $this->get_title_css( $attributes, '' ),
39 $this->get_title_css( $attributes, 'Tablet' ),
40 $this->get_title_css( $attributes, 'Mobile' )
41 );
42
43 $css_generator->add_class_styles(
44 '{{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-review__title:hover,
45 {{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-info__content .instructor-title:hover',
46 $this->get_title_hover_css( $attributes, '' ),
47 $this->get_title_hover_css( $attributes, 'Tablet' ),
48 $this->get_title_hover_css( $attributes, 'Mobile' )
49 );
50
51 $css_generator->add_class_styles(
52 '{{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-review__rating span',
53 $this->get_review_text_css( $attributes, '' ),
54 $this->get_review_text_css( $attributes, 'Tablet' ),
55 $this->get_review_text_css( $attributes, 'Mobile' )
56 );
57
58 $css_generator->add_class_styles(
59 '{{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-review__rating span:hover',
60 $this->get_review_text_hover_css( $attributes, '' ),
61 $this->get_review_text_hover_css( $attributes, 'Tablet' ),
62 $this->get_review_text_hover_css( $attributes, 'Mobile' )
63 );
64 $css_generator->add_class_styles(
65 '{{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-review__rating .academy-group-star .academy-icon:before',
66 $this->get_review_icon_css( $attributes, '' ),
67 $this->get_review_icon_css( $attributes, 'Tablet' ),
68 $this->get_review_icon_css( $attributes, 'Mobile' )
69 );
70 $css_generator->add_class_styles(
71 '{{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-review__rating .academy-group-star .academy-icon:hover:before',
72 $this->get_review_icon_hover_css( $attributes, '' ),
73 $this->get_review_icon_hover_css( $attributes, 'Tablet' ),
74 $this->get_review_icon_hover_css( $attributes, 'Mobile' )
75 );
76 $css_generator->add_class_styles(
77 '{{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-info__content .instructor-name a',
78 $this->get_instructor_css( $attributes, '' ),
79 $this->get_instructor_css( $attributes, 'Tablet' ),
80 $this->get_instructor_css( $attributes, 'Mobile' )
81 );
82 $css_generator->add_class_styles(
83 '{{WRAPPER}} .academy-single-course__content-item--instructors .course-single-instructor .instructor-info__content .instructor-name a:hover',
84 $this->get_instructor_hover_css( $attributes, '' ),
85 $this->get_instructor_hover_css( $attributes, 'Tablet' ),
86 $this->get_instructor_hover_css( $attributes, 'Mobile' )
87 );
88
89 return $css_generator->generate_css();
90 }
91
92 public function get_avatar_image_css( $attributes, $device = '' ) {
93 return array_merge(
94 Range::get_css([
95 'attributeValue' => $attributes['avatarH'],
96 'attribute_object_key' => 'value',
97 'isResponsive' => true,
98 'defaultValue' => 62,
99 'hasUnit' => true,
100 'unitDefaultValue' => 'px',
101 'property' => 'height',
102 'device' => $device,
103 ]),
104 Range::get_css([
105 'attributeValue' => $attributes['avatarW'],
106 'attribute_object_key' => 'value',
107 'isResponsive' => true,
108 'defaultValue' => 62,
109 'hasUnit' => true,
110 'unitDefaultValue' => 'px',
111 'property' => 'width',
112 'device' => $device,
113 ]),
114 );
115 }
116
117 public function get_title_css( $attributes, $device = '' ) {
118 $typographyValueGlobal = ! empty( $attributes['titleTypographyGlobal'] ) ? $attributes['titleTypographyGlobal'] : '';
119 $typography_value = ! empty( $attributes['titleTypography'] ) ?
120 Typography::get_css( $attributes['titleTypography'], '', $device, $typographyValueGlobal )
121 : array();
122
123 return array_merge(
124 [ 'color' => Color::get_css( isset( $attributes['titleColor'] ) ? $attributes['titleColor'] : '#999' ) ],
125 $typography_value,
126 );
127 }
128
129 public function get_title_hover_css( $attributes, $device = '' ) {
130 return array_merge(
131 [ 'color' => Color::get_css( isset( $attributes['titleColorH'] ) ? $attributes['titleColorH'] : '#999' ) ],
132 Range::get_css([
133 'attributeValue' => $attributes['titleTransition'],
134 'attribute_object_key' => 'value',
135 'isResponsive' => false,
136 'defaultValue' => 0,
137 'hasUnit' => false,
138 'unitDefaultValue' => 's',
139 'property' => 'transition-duration',
140 'device' => $device,
141 ]),
142 );
143
144 }
145
146 public function get_review_text_css( $attributes, $device = '' ) {
147 $typographyValueGlobal = ! empty( $attributes['textTypographyGlobal'] ) ? $attributes['textTypographyGlobal'] : '';
148 $typography_value = ! empty( $attributes['textTypography'] ) ?
149 Typography::get_css( $attributes['textTypography'], '', $device, $typographyValueGlobal )
150 : array();
151
152 return array_merge(
153 [ 'color' => Color::get_css( isset( $attributes['textColor'] ) ? $attributes['textColor'] : '#111' ) ],
154 $typography_value,
155 );
156 }
157
158 public function get_review_text_hover_css( $attributes, $device = '' ) {
159 return array_merge(
160 [ 'color' => Color::get_css( isset( $attributes['textColorH'] ) ? $attributes['textColorH'] : '#111' ) ],
161 Range::get_css([
162 'attributeValue' => $attributes['textTransition'],
163 'attribute_object_key' => 'value',
164 'isResponsive' => false,
165 'defaultValue' => 0,
166 'hasUnit' => false,
167 'unitDefaultValue' => 's',
168 'property' => 'transition-duration',
169 'device' => $device,
170 ]),
171 );
172
173 }
174 public function get_review_icon_css( $attributes, $device = '' ) {
175 return array_merge(
176 [ 'color' => Color::get_css( isset( $attributes['star_color'] ) ? $attributes['star_color'] : '#f4c150' ) ],
177 Range::get_css([
178 'attributeValue' => $attributes['star_size'],
179 'attribute_object_key' => 'value',
180 'isResponsive' => true,
181 'defaultValue' => 16,
182 'hasUnit' => true,
183 'unitDefaultValue' => 'px',
184 'property' => 'font-size',
185 'device' => $device,
186 ]),
187 );
188 }
189
190 public function get_review_icon_hover_css( $attributes, $device = '' ) {
191 return [ 'color' => Color::get_css( isset( $attributes['star_colorH'] ) ? $attributes['star_colorH'] : '#f4c150' ) ];
192 }
193 public function get_instructor_css( $attributes, $device = '' ) {
194 $typographyValueGlobal = ! empty( $attributes['insTypographyGlobal'] ) ? $attributes['insTypographyGlobal'] : '';
195 $typography_value = ! empty( $attributes['insTypography'] ) ?
196 Typography::get_css( $attributes['insTypography'], '', $device, $typographyValueGlobal )
197 : array();
198 return array_merge(
199 [ 'color' => Color::get_css( isset( $attributes['insColor'] ) ? $attributes['insColor'] : '#111' ) ],
200 $typography_value
201 );
202 }
203
204 public function get_instructor_hover_css( $attributes, $device = '' ) {
205 return [ 'color' => Color::get_css( isset( $attributes['insColorH'] ) ? $attributes['insColorH'] : '#111' ) ];
206 }
207
208
209 public function render_block_content( $attributes, $content, $block_instance ) {
210 $attr_array = [];
211
212 $shortcode = '[academy_course_instructors ' . Helper::attr_shortcode( $attr_array ) . ']';
213 echo do_shortcode( $shortcode );
214 }
215
216 }
217