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

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

92 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\AcademyCourseSearch;
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\Color;
17 class Block extends BlockBaseAbstract {
18 protected $block_name = 'academy-course-search';
19
20 public function build_css( $attributes ) {
21 $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
22
23 $css_generator->add_class_styles(
24 '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-input',
25 $this->get_search_form_css( $attributes ),
26 $this->get_search_form_css( $attributes, 'Tablet' ),
27 $this->get_search_form_css( $attributes, 'Mobile' )
28 );
29 $css_generator->add_class_styles(
30 '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-input:hover',
31 $this->get_search_form_hover_css( $attributes ),
32 $this->get_search_form_hover_css( $attributes, 'Tablet' ),
33 $this->get_search_form_hover_css( $attributes, 'Mobile' )
34 );
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-icon span',
37 $this->get_search_box_icon_css( $attributes ),
38 $this->get_search_box_icon_css( $attributes, 'Tablet' ),
39 $this->get_search_box_icon_css( $attributes, 'Mobile' )
40 );
41
42 $css_generator->add_class_styles(
43 '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-input::placeholder',
44 $this->get_search_box_placeholder_css( $attributes ),
45 $this->get_search_box_placeholder_css( $attributes, 'Tablet' ),
46 $this->get_search_box_placeholder_css( $attributes, 'Mobile' )
47 );
48
49 return $css_generator->generate_css();
50 }
51
52
53 public function get_search_form_css( $attributes, $device = '' ) {
54 $typographyValueGlobal = ! empty( $attributes['search_typographyGlobal'] ) ? $attributes['search_typographyGlobal'] : '';
55 $typography_value = isset( $attributes['search_typography'] ) ? $attributes['search_typography'] : [];
56 $search_border_css = ! empty( $attributes['search_border'] ) ? Border::get_css( $attributes['search_border'], '', $device ) : array();
57
58 return array_merge(
59 Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
60 $search_border_css,
61 [ 'color' => Color::get_css( isset( $attributes['search_box_color'] ) ? $attributes['search_box_color'] : '' ) ],
62 [ 'background' => Color::get_css( isset( $attributes['search_background_color'] ) ? $attributes['search_background_color'] : '' ) ],
63 );
64 }
65 public function get_search_form_hover_css( $attributes, $device = '' ) {
66 $css = array();
67
68 $search_border_hover_css = ! empty( $attributes['search_border'] ) ? Border::get_hover_css( $attributes['search_border'], '', $device ) : array();
69
70 return array_merge(
71 $search_border_hover_css,
72 $css,
73 );
74 }
75 public function get_search_box_icon_css( $attributes, $device = '' ) {
76 return [ 'color' => Color::get_css( isset( $attributes['search_icon_color'] ) ? $attributes['search_icon_color'] : '' ) ];
77 }
78 public function get_search_box_placeholder_css( $attributes, $device = '' ) {
79 return [ 'color' => Color::get_css( isset( $attributes['search_placeholder_color'] ) ? $attributes['search_placeholder_color'] : '' ) ];
80 }
81
82
83 public function render_block_content( $attributes, $content, $block_instance ) {
84 $attr_array = [
85 'placeholder' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'placeholder' ) ),
86 ];
87 $shortcode = '[academy_course_search ' . Helper::attr_shortcode( $attr_array ) . ']';
88 echo do_shortcode( $shortcode );
89 }
90
91 }
92