PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.0
2.16.0 2.15.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 All 83 releases
← All changes | includes/blocks/notice/block.php +160 -0 2.7.6 → 2.13.0 View file →
@@ -1,0 +1,160 @@
1 +<?php
2 +namespace ABlocks\Blocks\Notice;
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
8 +use ABlocks\Classes\BlockBaseAbstract;
9 +use ABlocks\Classes\CssGenerator;
10 +use ABlocks\Controls\Alignment;
11 +use ABlocks\Controls\Typography;
12 +use ABlocks\Controls\TextShadow;
13 +use ABlocks\Controls\TextStroke;
14 +use ABlocks\Controls\Dimensions;
15 +use ABlocks\Controls\Icon;
16 +use ABlocks\Classes\CssGeneratorV2;
17 +use ABlocks\Controls\Color;
18 +
19 +class Block extends BlockBaseAbstract {
20 + protected $block_name = 'notice';
21 +
22 + public function build_css_v1( $attributes ) {
23 + $css_generator = new CssGenerator( $attributes, $this->block_name );
24 + $css_generator->add_class_styles(
25 + '{{WRAPPER}} .ablocks-notice-header',
26 + $this->get_notice_header_css( $attributes ),
27 + $this->get_notice_header_css( $attributes, 'Tablet' ),
28 + $this->get_notice_header_css( $attributes, 'Mobile' )
29 + );
30 + $css_generator->add_class_styles(
31 + '{{WRAPPER}} .ablocks-notice-header .ablocks-notice-title',
32 + $this->get_notice_header_title_css( $attributes ),
33 + $this->get_notice_header_title_css( $attributes, 'Tablet' ),
34 + $this->get_notice_header_title_css( $attributes, 'Mobile' )
35 + );
36 +
37 + // Icon CSS
38 + $css_generator->add_class_styles(
39 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap',
40 + Icon::get_wrapper_css( $attributes ),
41 + Icon::get_wrapper_css( $attributes, 'Tablet' ),
42 + Icon::get_wrapper_css( $attributes, 'Mobile' )
43 + );
44 + $css_generator->add_class_styles(
45 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap:hover',
46 + Icon::get_wrapper_hover_css( $attributes ),
47 + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ),
48 + Icon::get_wrapper_hover_css( $attributes, 'Mobile' )
49 + );
50 +
51 + $css_generator->add_class_styles(
52 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap img.ablocks-image-icon',
53 + Icon::get_element_image_css( $attributes ),
54 + Icon::get_element_image_css( $attributes, 'Tablet' ),
55 + Icon::get_element_image_css( $attributes, 'Mobile' ),
56 + );
57 + $css_generator->add_class_styles(
58 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap img.ablocks-image-icon:hover',
59 + Icon::get_element_image_hover_css( $attributes ),
60 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
61 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
62 + );
63 + $css_generator->add_class_styles(
64 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap svg.ablocks-svg-icon',
65 + Icon::get_element_css( $attributes ),
66 + Icon::get_element_css( $attributes, 'Tablet' ),
67 + Icon::get_element_css( $attributes, 'Mobile' ),
68 + );
69 + $css_generator->add_class_styles(
70 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
71 + Icon::get_element_image_hover_css( $attributes ),
72 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
73 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
74 + );
75 +
76 + return $css_generator->generate_css();
77 + }
78 + public function build_css_v2( $attributes ) {
79 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
80 +
81 + $css_generator->add_class_styles(
82 + '{{WRAPPER}} .ablocks-notice-header',
83 + $this->get_notice_header_css( $attributes ),
84 + $this->get_notice_header_css( $attributes, 'Tablet' ),
85 + $this->get_notice_header_css( $attributes, 'Mobile' )
86 + );
87 + $css_generator->add_class_styles(
88 + '{{WRAPPER}} .ablocks-notice-header .ablocks-notice-title',
89 + $this->get_notice_header_title_css( $attributes ),
90 + $this->get_notice_header_title_css( $attributes, 'Tablet' ),
91 + $this->get_notice_header_title_css( $attributes, 'Mobile' )
92 + );
93 +
94 + // Icon CSS
95 + $css_generator->add_class_styles(
96 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap',
97 + Icon::get_wrapper_css( $attributes ),
98 + Icon::get_wrapper_css( $attributes, 'Tablet' ),
99 + Icon::get_wrapper_css( $attributes, 'Mobile' )
100 + );
101 + $css_generator->add_class_styles(
102 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap:hover',
103 + Icon::get_wrapper_hover_css( $attributes ),
104 + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ),
105 + Icon::get_wrapper_hover_css( $attributes, 'Mobile' )
106 + );
107 +
108 + $css_generator->add_class_styles(
109 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap img.ablocks-image-icon',
110 + Icon::get_element_image_css( $attributes ),
111 + Icon::get_element_image_css( $attributes, 'Tablet' ),
112 + Icon::get_element_image_css( $attributes, 'Mobile' ),
113 + );
114 + $css_generator->add_class_styles(
115 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap img.ablocks-image-icon:hover',
116 + Icon::get_element_image_hover_css( $attributes ),
117 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
118 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
119 + );
120 + $css_generator->add_class_styles(
121 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap svg.ablocks-svg-icon',
122 + Icon::get_element_css( $attributes ),
123 + Icon::get_element_css( $attributes, 'Tablet' ),
124 + Icon::get_element_css( $attributes, 'Mobile' ),
125 + );
126 + $css_generator->add_class_styles(
127 + '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
128 + Icon::get_element_image_hover_css( $attributes ),
129 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
130 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
131 + );
132 +
133 + return $css_generator->generate_css();
134 + }
135 +
136 + public function build_css( $attributes ) {
137 + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
138 + return $this->build_css_v2( $attributes );
139 + }
140 + return $this->build_css_v1( $attributes );
141 + }
142 + public function get_notice_header_css( $attributes, $device = '' ) {
143 + return array_merge(
144 + [ 'background' => Color::get_css( isset( $attributes['backgroundColor'] ) ? $attributes['backgroundColor'] : '' ) ],
145 + Dimensions::get_css( $attributes['noticeHeaderPadding'], 'padding', $device )
146 + );
147 + }
148 +
149 + public function get_notice_header_title_css( $attributes, $device = '' ) {
150 + $typographyValueGlobal = ! empty( $attributes['typographyGlobal'] ) ? $attributes['typographyGlobal'] : array();
151 + return array_merge(
152 + [ 'color' => Color::get_css( isset( $attributes['textColor'] ) ? $attributes['textColor'] : '' ) ],
153 + Alignment::get_css( $attributes['alignment'], 'justify-content', $device ),
154 + Typography::get_css( $attributes['typography'], '', $device, $typographyValueGlobal ),
155 + TextShadow::get_css( $attributes['textShadow'], '', $device ),
156 + TextStroke::get_css( $attributes['textStroke'], '', $device ),
157 + );
158 + }
159 +
160 +}