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-description / 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-description/block.php

129 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\AcademyCourseDescription;
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-course-description';
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-single-course__content-item--description-title',
29 $this->get_overview_heading_css( $attributes, '' ),
30 $this->get_overview_heading_css( $attributes, 'Tablet' ),
31 $this->get_overview_heading_css( $attributes, 'Mobile' )
32 );
33
34 $css_generator->add_class_styles(
35 '{{WRAPPER}} .academy-single-course__content-item--description-title:hover',
36 $this->get_overview_heading_hover_css( $attributes, '' ),
37 $this->get_overview_heading_hover_css( $attributes, 'Tablet' ),
38 $this->get_overview_heading_hover_css( $attributes, 'Mobile' )
39 );
40 $css_generator->add_class_styles(
41 '{{WRAPPER}} .academy-single-course__content-item--description p,
42 {{WRAPPER}} .academy-single-course__content-item--description',
43 $this->get_description_css( $attributes, '' ),
44 $this->get_description_css( $attributes, 'Tablet' ),
45 $this->get_description_css( $attributes, 'Mobile' )
46 );
47 $css_generator->add_class_styles(
48 '{{WRAPPER}} .academy-single-course__content-item--description p:hover,
49 {{WRAPPER}} .academy-single-course__content-item--description:hover',
50 $this->get_description_hover_css( $attributes, '' ),
51 $this->get_description_hover_css( $attributes, 'Tablet' ),
52 $this->get_description_hover_css( $attributes, 'Mobile' )
53 );
54 return $css_generator->generate_css();
55 }
56
57
58 public function get_overview_heading_css( $attributes, $device = '' ) {
59 $typographyValueGlobal = ! empty( $attributes['heading_typographyGlobal'] ) ? $attributes['heading_typographyGlobal'] : '';
60 $typography_value = ! empty( $attributes['heading_typography'] ) ?
61 Typography::get_css( $attributes['heading_typography'], '', $device, $typographyValueGlobal )
62 : array();
63
64 return array_merge(
65 [ 'color' => Color::get_css( isset( $attributes['heading_color'] ) ? $attributes['heading_color'] : '#999' ) ],
66 $typography_value,
67 );
68 }
69
70 public function get_overview_heading_hover_css( $attributes, $device = '' ) {
71 return array_merge(
72 [ 'color' => Color::get_css( isset( $attributes['heading_colorH'] ) ? $attributes['heading_colorH'] : '#999' ) ],
73 Range::get_css([
74 'attributeValue' => $attributes['heading_transition'],
75 'attribute_object_key' => 'value',
76 'isResponsive' => false,
77 'defaultValue' => 0,
78 'hasUnit' => false,
79 'unitDefaultValue' => 's',
80 'property' => 'transition-duration',
81 'device' => $device,
82 ]),
83 );
84
85 }
86 public function get_description_css( $attributes, $device = '' ) {
87 $typographyValueGlobal = ! empty( $attributes['description_typographyGlobal'] ) ? $attributes['description_typographyGlobal'] : '';
88 $typography_value = ! empty( $attributes['description_typography'] ) ?
89 Typography::get_css( $attributes['description_typography'], '', $device, $typographyValueGlobal )
90 : array();
91
92 return array_merge(
93 [ 'color' => Color::get_css( isset( $attributes['description_color'] ) ? $attributes['description_color'] : '#999' ) ],
94 $typography_value,
95 );
96 }
97
98 public function get_description_hover_css( $attributes, $device = '' ) {
99 return array_merge(
100 [ 'color' => Color::get_css( isset( $attributes['description_colorH'] ) ? $attributes['description_colorH'] : '#999' ) ],
101 Range::get_css([
102 'attributeValue' => $attributes['description_transition'],
103 'attribute_object_key' => 'value',
104 'isResponsive' => false,
105 'defaultValue' => 0,
106 'hasUnit' => false,
107 'unitDefaultValue' => 's',
108 'property' => 'transition-duration',
109 'device' => $device,
110 ]),
111 );
112
113 }
114
115 public function render_block_content( $attributes, $content, $block_instance ) {
116 static $guard = false;
117 if ( $guard ) {
118 return '';
119 }
120 $guard = true;
121 $attr_array = [];
122 $shortcode = '[academy_single_course_description ' . Helper::attr_shortcode( $attr_array ) . ']';
123 echo do_shortcode( $shortcode );
124 $guard = false;
125 return '';
126 }
127
128 }
129