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
ablocks / includes / blocks / academy-course-description / block.php

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

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