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-search/block.php +95 -0 2.7.4 → 2.14.0 View file →
@@ -1,0 +1,95 @@
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 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_search_form_css( $attributes, $device ); } )
29 + );
30 + $css_generator->add_class_styles(
31 + '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-input:hover',
32 + $this->get_search_form_hover_css( $attributes ),
33 + $this->get_search_form_hover_css( $attributes, 'Tablet' ),
34 + $this->get_search_form_hover_css( $attributes, 'Mobile' ),
35 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_search_form_hover_css( $attributes, $device ); } )
36 + );
37 + $css_generator->add_class_styles(
38 + '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-icon span',
39 + $this->get_search_box_icon_css( $attributes ),
40 + $this->get_search_box_icon_css( $attributes, 'Tablet' ),
41 + $this->get_search_box_icon_css( $attributes, 'Mobile' ),
42 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_search_box_icon_css( $attributes, $device ); } )
43 + );
44 +
45 + $css_generator->add_class_styles(
46 + '{{WRAPPER}} .academy-search-form-wrap .academy-search-form__field-input::placeholder',
47 + $this->get_search_box_placeholder_css( $attributes ),
48 + $this->get_search_box_placeholder_css( $attributes, 'Tablet' ),
49 + $this->get_search_box_placeholder_css( $attributes, 'Mobile' ),
50 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_search_box_placeholder_css( $attributes, $device ); } )
51 + );
52 +
53 + return $css_generator->generate_css();
54 + }
55 +
56 +
57 + public function get_search_form_css( $attributes, $device = '' ) {
58 + $typographyValueGlobal = ! empty( $attributes['search_typographyGlobal'] ) ? $attributes['search_typographyGlobal'] : '';
59 + $typography_value = isset( $attributes['search_typography'] ) ? $attributes['search_typography'] : [];
60 + $search_border_css = ! empty( $attributes['search_border'] ) ? Border::get_css( $attributes['search_border'], '', $device ) : array();
61 +
62 + return array_merge(
63 + Typography::get_css( $typography_value, '', $device, $typographyValueGlobal ),
64 + $search_border_css,
65 + [ 'color' => Color::get_css( isset( $attributes['search_box_color'] ) ? $attributes['search_box_color'] : '' ) ],
66 + [ 'background' => Color::get_css( isset( $attributes['search_background_color'] ) ? $attributes['search_background_color'] : '' ) ],
67 + );
68 + }
69 + public function get_search_form_hover_css( $attributes, $device = '' ) {
70 + $css = array();
71 +
72 + $search_border_hover_css = ! empty( $attributes['search_border'] ) ? Border::get_hover_css( $attributes['search_border'], '', $device ) : array();
73 +
74 + return array_merge(
75 + $search_border_hover_css,
76 + $css,
77 + );
78 + }
79 + public function get_search_box_icon_css( $attributes, $device = '' ) {
80 + return [ 'color' => Color::get_css( isset( $attributes['search_icon_color'] ) ? $attributes['search_icon_color'] : '' ) ];
81 + }
82 + public function get_search_box_placeholder_css( $attributes, $device = '' ) {
83 + return [ 'color' => Color::get_css( isset( $attributes['search_placeholder_color'] ) ? $attributes['search_placeholder_color'] : '' ) ];
84 + }
85 +
86 +
87 + public function render_block_content( $attributes, $content, $block_instance ) {
88 + $attr_array = [
89 + 'placeholder' => sanitize_text_field( Helper::get_attribute_value( $attributes, 'placeholder' ) ),
90 + ];
91 + $shortcode = '[academy_course_search ' . Helper::attr_shortcode( $attr_array ) . ']';
92 + echo do_shortcode( $shortcode );
93 + }
94 +
95 +}