PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.10.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.10.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
ablocks / includes / blocks / academy-course-media / block.php

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

113 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\AcademyCourseMedia;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
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\Color;
17 use ABlocks\Controls\BoxShadow;
18
19 class Block extends BlockBaseAbstract {
20 protected $block_name = 'academy-course-media';
21
22 public function build_css( $attributes ) {
23 $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
24
25 $css_generator->add_class_styles(
26 '{{WRAPPER}}.ablocks-block--academy-course-image:not(.ablocks-block-container),
27 {{WRAPPER}} .academy-default-featured-image,
28 {{WRAPPER}} .plyr--video',
29 $this->get_featured_image_css( $attributes ),
30 $this->get_featured_image_css( $attributes, 'Tablet' ),
31 $this->get_featured_image_css( $attributes, 'Mobile' )
32 );
33 $css_generator->add_class_styles(
34 '{{WRAPPER}}.ablocks-block--academy-course-media:not(.ablocks-block-container),
35 {{WRAPPER}}.ablocks-block--academy-course-media .ablocks-block-container',
36 $this->get_featured_image_container_css( $attributes ),
37 $this->get_featured_image_container_css( $attributes, 'Tablet' ),
38 $this->get_featured_image_container_css( $attributes, 'Mobile' )
39 );
40 $css_generator->add_class_styles(
41 '{{WRAPPER}}.ablocks-block--academy-course-image:not(.ablocks-block-container),
42 {{WRAPPER}} .academy-default-featured-image:hover,
43 {{WRAPPER}} .plyr--video:hover',
44 $this->get_featured_image_hover_css( $attributes ),
45 $this->get_featured_image_hover_css( $attributes, 'Tablet' ),
46 $this->get_featured_image_hover_css( $attributes, 'Mobile' )
47 );
48
49 return $css_generator->generate_css();
50 }
51
52 public function get_featured_image_css( $attributes, $device = '' ) {
53 $css = [];
54 $css['opacity'] = $attributes['imageOpacity'] ?? '';
55
56 return array_merge(
57 $css,
58 isset( $attributes['border'] ) ? Border::get_css( $attributes['border'], '', $device ) : [],
59 isset( $attributes['boxShadow'] ) ? BoxShadow::get_css( $attributes['boxShadow'], $device ) : [],
60 Range::get_css([
61 'attributeValue' => $attributes['imageWidth'],
62 'attribute_object_key' => 'value',
63 'isResponsive' => true,
64 'defaultValue' => 100,
65 'hasUnit' => true,
66 'unitDefaultValue' => '%',
67 'property' => 'width',
68 'device' => $device,
69 ]),
70 Range::get_css([
71 'attributeValue' => $attributes['imageHeight'],
72 'attribute_object_key' => 'value',
73 'isResponsive' => true,
74 'defaultValue' => 100,
75 'hasUnit' => true,
76 'unitDefaultValue' => '%',
77 'property' => 'height',
78 'device' => $device,
79 ]),
80 );
81
82 }
83
84 public function get_featured_image_container_css( $attributes, $device = '' ) {
85 $alignment_value = $attributes['alignment'][ 'value' . $device ] ?? '';
86 $css = [];
87 if ( ! empty( $alignment_value ) ) {
88 $css['display'] = 'flex';
89 $css['width'] = '100%';
90 $css['justify-content'] = $alignment_value;
91 }
92 return $css;
93 }
94
95 public function get_featured_image_hover_css( $attributes, $device = '' ) {
96 $css = [];
97 $css['opacity'] = $attributes['imageOpacityH'] ?? '';
98 return array_merge(
99 Border::get_hover_css( $attributes['border'], '', $device ),
100 BoxShadow::get_hover_css( $attributes['boxShadow'], '', $device ),
101 );
102 }
103
104
105 public function render_block_content( $attributes, $content, $block_instance ) {
106 $attr_array = [];
107
108 $shortcode = '[academy_course_featured_image ' . Helper::attr_shortcode( $attr_array ) . ']';
109 echo do_shortcode( $shortcode );
110 }
111
112 }
113