PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.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-search / block.php

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

111 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\AcademyCourseSearch;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
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
16 class Block extends BlockBaseAbstract {
17 protected $block_name = 'academy-course-search';
18
19 public function build_css( $attributes ) {
20 $css_generator = new CssGenerator( $attributes );
21
22 $css_generator->add_class_styles(
23 '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-input',
24 $this->get_search_form_css( $attributes ),
25 $this->get_search_form_css( $attributes, 'Tablet' ),
26 $this->get_search_form_css( $attributes, 'Mobile' )
27 );
28 $css_generator->add_class_styles(
29 '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-input:hover',
30 $this->get_search_form_hover_css( $attributes ),
31 $this->get_search_form_hover_css( $attributes, 'Tablet' ),
32 $this->get_search_form_hover_css( $attributes, 'Mobile' )
33 );
34 $css_generator->add_class_styles(
35 '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-icon span',
36 $this->get_search_box_icon_css( $attributes ),
37 $this->get_search_box_icon_css( $attributes, 'Tablet' ),
38 $this->get_search_box_icon_css( $attributes, 'Mobile' )
39 );
40
41 $css_generator->add_class_styles(
42 '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-input::placeholder',
43 $this->get_search_box_placeholder_css( $attributes ),
44 $this->get_search_box_placeholder_css( $attributes, 'Tablet' ),
45 $this->get_search_box_placeholder_css( $attributes, 'Mobile' )
46 );
47
48 return $css_generator->generate_css();
49 }
50
51
52
53 public function get_search_form_css( $attributes, $device = '' ) {
54 $css = array();
55 if ( ! empty( $attributes['search_background_color'] ) ) {
56 $css['background'] = $attributes['search_background_color'];
57 }
58 if ( ! empty( $attributes['search_box_color'] ) ) {
59 $css['color'] = $attributes['search_box_color'];
60 }
61 $search_typography_css = ! empty( $attributes['search_typography'] ) ? Typography::get_css( $attributes['search_typography'], '', $device ) : array();
62 $search_border_css = ! empty( $attributes['search_border'] ) ? Border::get_css( $attributes['search_border'], '', $device ) : array();
63
64 return array_merge(
65 $search_typography_css,
66 $search_border_css,
67 $css,
68 );
69 }
70 public function get_search_form_hover_css( $attributes, $device = '' ) {
71 $css = array();
72
73 $search_border_hover_css = ! empty( $attributes['search_border'] ) ? Border::get_hover_css( $attributes['search_border'], '', $device ) : array();
74
75 return array_merge(
76 $search_border_hover_css,
77 $css,
78 );
79 }
80 public function get_search_box_icon_css( $attributes, $device = '' ) {
81 $css = array();
82
83 if ( ! empty( $attributes['search_icon_color'] ) ) {
84 $css['color'] = $attributes['search_icon_color'];
85 }
86
87 return $css;
88 }
89 public function get_search_box_placeholder_css( $attributes, $device = '' ) {
90 $css = array();
91
92 if ( ! empty( $attributes['search_placeholder_color'] ) ) {
93 $css['color'] = $attributes['search_placeholder_color'];
94 }
95
96 return $css;
97 }
98
99
100
101
102 public function render_block_content( $attributes, $content, $block_instance ) {
103 $attr_array = [
104 'placeholder' => Helper::get_attribute_value( $attributes, 'placeholder' ),
105 ];
106 $shortcode = '[academy_course_search ' . Helper::attr_shortcode( $attr_array ) . ']';
107 echo do_shortcode( $shortcode );
108 }
109
110 }
111