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/icon/block.php +148 -0 2.7.6 → 2.14.0 View file →
@@ -1,0 +1,148 @@
1 +<?php
2 +namespace ABlocks\Blocks\Icon;
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
8 +use ABlocks\Classes\BlockBaseAbstract;
9 +use ABlocks\Classes\CssGenerator;
10 +use ABlocks\Controls\Dimensions;
11 +use ABlocks\Controls\Icon;
12 +use ABlocks\Classes\CssGeneratorV2;
13 +
14 +class Block extends BlockBaseAbstract {
15 + protected $block_name = 'icon';
16 +
17 + public function build_css_v1( $attributes ) {
18 + $css_generator = new CssGenerator( $attributes, $this->block_name );
19 +
20 + // Generate wrapper CSS start
21 + $css_generator->add_class_styles(
22 + '{{WRAPPER}} .ablocks-block-container',
23 + $this->get_wrapper_css( $attributes ),
24 + $this->get_wrapper_css( $attributes, 'Tablet' ),
25 + $this->get_wrapper_css( $attributes, 'Mobile' ),
26 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wrapper_css( $attributes, $device ); } )
27 + );
28 +
29 + // Icon Style
30 + $css_generator->add_class_styles(
31 + '{{WRAPPER}} .ablocks-icon-wrap',
32 + Icon::get_wrapper_css( $attributes ),
33 + Icon::get_wrapper_css( $attributes, 'Tablet' ),
34 + Icon::get_wrapper_css( $attributes, 'Mobile' ),
35 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_css( $attributes, $device ); } )
36 + );
37 + $css_generator->add_class_styles(
38 + '{{WRAPPER}} .ablocks-icon-wrap:hover',
39 + Icon::get_wrapper_hover_css( $attributes ),
40 + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ),
41 + Icon::get_wrapper_hover_css( $attributes, 'Mobile' ),
42 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_hover_css( $attributes, $device ); } )
43 + );
44 + $css_generator->add_class_styles(
45 + '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon',
46 + Icon::get_element_image_css( $attributes ),
47 + Icon::get_element_image_css( $attributes, 'Tablet' ),
48 + Icon::get_element_image_css( $attributes, 'Mobile' ),
49 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_css( $attributes, $device ); } )
50 + );
51 + $css_generator->add_class_styles(
52 + '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon:hover',
53 + Icon::get_element_image_hover_css( $attributes ),
54 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
55 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
56 + );
57 + $css_generator->add_class_styles(
58 + '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon',
59 + Icon::get_element_css( $attributes ),
60 + Icon::get_element_css( $attributes, 'Tablet' ),
61 + Icon::get_element_css( $attributes, 'Mobile' ),
62 + );
63 + $css_generator->add_class_styles(
64 + '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
65 + Icon::get_element_image_hover_css( $attributes ),
66 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
67 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
68 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_hover_css( $attributes, $device ); } )
69 + );
70 +
71 + return $css_generator->generate_css();
72 + }
73 + public function build_css_v2( $attributes ) {
74 + $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
75 +
76 + // Generate wrapper CSS start
77 + $css_generator->add_class_styles(
78 + '{{WRAPPER}}',
79 + $this->get_wrapper_css( $attributes ),
80 + $this->get_wrapper_css( $attributes, 'Tablet' ),
81 + $this->get_wrapper_css( $attributes, 'Mobile' ),
82 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wrapper_css( $attributes, $device ); } )
83 + );
84 +
85 + // Icon Style
86 + $css_generator->add_class_styles(
87 + '{{WRAPPER}} .ablocks-icon-wrap',
88 + Icon::get_wrapper_css( $attributes ),
89 + Icon::get_wrapper_css( $attributes, 'Tablet' ),
90 + Icon::get_wrapper_css( $attributes, 'Mobile' ),
91 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_css( $attributes, $device ); } )
92 + );
93 + $css_generator->add_class_styles(
94 + '{{WRAPPER}} .ablocks-icon-wrap:hover',
95 + Icon::get_wrapper_hover_css( $attributes ),
96 + Icon::get_wrapper_hover_css( $attributes, 'Tablet' ),
97 + Icon::get_wrapper_hover_css( $attributes, 'Mobile' ),
98 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_wrapper_hover_css( $attributes, $device ); } )
99 + );
100 + $css_generator->add_class_styles(
101 + '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon',
102 + Icon::get_element_image_css( $attributes ),
103 + Icon::get_element_image_css( $attributes, 'Tablet' ),
104 + Icon::get_element_image_css( $attributes, 'Mobile' ),
105 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_css( $attributes, $device ); } )
106 + );
107 + $css_generator->add_class_styles(
108 + '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon:hover',
109 + Icon::get_element_image_hover_css( $attributes ),
110 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
111 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
112 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_hover_css( $attributes, $device ); } )
113 + );
114 + $css_generator->add_class_styles(
115 + '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon',
116 + Icon::get_element_css( $attributes ),
117 + Icon::get_element_css( $attributes, 'Tablet' ),
118 + Icon::get_element_css( $attributes, 'Mobile' ),
119 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_css( $attributes, $device ); } )
120 + );
121 + $css_generator->add_class_styles(
122 + '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
123 + Icon::get_element_image_hover_css( $attributes ),
124 + Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
125 + Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
126 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return Icon::get_element_image_hover_css( $attributes, $device ); } )
127 + );
128 +
129 + return $css_generator->generate_css();
130 + }
131 +
132 + public function build_css( $attributes ) {
133 + if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
134 + return $this->build_css_v2( $attributes );
135 + }
136 + return $this->build_css_v1( $attributes );
137 + }
138 +
139 + public function get_wrapper_css( $attributes = [], $device = '' ) {
140 + $css = [];
141 + $css['display'] = 'flex';
142 + $css['align-items'] = 'flex-start';
143 + if ( ! empty( $attributes['alignment'][ 'value' . $device ] ) ) {
144 + $css['justify-content'] = $attributes['alignment'][ 'value' . $device ];
145 + }
146 + return $css;
147 + }
148 +}