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-course-media/block.php +115 -0 2.7.7 → 2.14.0 View file →
@@ -1,0 +1,115 @@
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 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_featured_image_css( $attributes, $device ); } )
33 + );
34 + $css_generator->add_class_styles(
35 + '{{WRAPPER}}.ablocks-block--academy-course-media:not(.ablocks-block-container),
36 + {{WRAPPER}}.ablocks-block--academy-course-media .ablocks-block-container',
37 + $this->get_featured_image_container_css( $attributes ),
38 + $this->get_featured_image_container_css( $attributes, 'Tablet' ),
39 + $this->get_featured_image_container_css( $attributes, 'Mobile' ),
40 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_featured_image_container_css( $attributes, $device ); } )
41 + );
42 + $css_generator->add_class_styles(
43 + '{{WRAPPER}}.ablocks-block--academy-course-image:not(.ablocks-block-container),
44 + {{WRAPPER}} .academy-default-featured-image:hover,
45 + {{WRAPPER}} .plyr--video:hover',
46 + $this->get_featured_image_hover_css( $attributes ),
47 + $this->get_featured_image_hover_css( $attributes, 'Tablet' ),
48 + $this->get_featured_image_hover_css( $attributes, 'Mobile' ),
49 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_featured_image_hover_css( $attributes, $device ); } )
50 + );
51 +
52 + return $css_generator->generate_css();
53 + }
54 +
55 + public function get_featured_image_css( $attributes, $device = '' ) {
56 + $css = [];
57 + $css['opacity'] = $attributes['imageOpacity'] ?? '';
58 +
59 + return array_merge(
60 + $css,
61 + isset( $attributes['border'] ) ? Border::get_css( $attributes['border'], '', $device ) : [],
62 + isset( $attributes['boxShadow'] ) ? BoxShadow::get_css( $attributes['boxShadow'], $device ) : [],
63 + Range::get_css([
64 + 'attributeValue' => $attributes['imageWidth'],
65 + 'attribute_object_key' => 'value',
66 + 'isResponsive' => true,
67 + 'defaultValue' => 100,
68 + 'hasUnit' => true,
69 + 'unitDefaultValue' => '%',
70 + 'property' => 'width',
71 + 'device' => $device,
72 + ]),
73 + Range::get_css([
74 + 'attributeValue' => $attributes['imageHeight'],
75 + 'attribute_object_key' => 'value',
76 + 'isResponsive' => true,
77 + 'defaultValue' => 100,
78 + 'hasUnit' => true,
79 + 'unitDefaultValue' => '%',
80 + 'property' => 'height',
81 + 'device' => $device,
82 + ]),
83 + );
84 +
85 + }
86 +
87 + public function get_featured_image_container_css( $attributes, $device = '' ) {
88 + $alignment_value = $attributes['alignment'][ 'value' . $device ] ?? '';
89 + $css = [];
90 + if ( ! empty( $alignment_value ) ) {
91 + $css['display'] = 'flex';
92 + $css['width'] = '100%';
93 + $css['justify-content'] = $alignment_value;
94 + }
95 + return $css;
96 + }
97 +
98 + public function get_featured_image_hover_css( $attributes, $device = '' ) {
99 + $css = [];
100 + $css['opacity'] = $attributes['imageOpacityH'] ?? '';
101 + return array_merge(
102 + Border::get_hover_css( $attributes['border'], '', $device ),
103 + BoxShadow::get_hover_css( $attributes['boxShadow'], '', $device ),
104 + );
105 + }
106 +
107 +
108 + public function render_block_content( $attributes, $content, $block_instance ) {
109 + $attr_array = [];
110 +
111 + $shortcode = '[academy_course_featured_image ' . Helper::attr_shortcode( $attr_array ) . ']';
112 + echo do_shortcode( $shortcode );
113 + }
114 +
115 +}