PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.11.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.11.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 / ecm-bookmark-list / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.11.1, at includes/blocks/ecm-bookmark-list/block.php

176 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ABlocks\Blocks\EcmBookmarkList;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 use ABlocks\Classes\BlockBaseAbstract;
10 use ABlocks\Classes\CssGenerator;
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\Range;
17 use ABlocks\Controls\BoxShadow;
18 use ABlocks\Controls\Color;
19 use ABlocks\Controls\TextShadow;
20 use ABlocks\Controls\TextStroke;
21
22 class Block extends BlockBaseAbstract {
23 protected $block_name = 'ecm-bookmark-list';
24
25 public function build_css( $attributes ) {
26 $css_generator = new CssGenerator( $attributes, $this->block_name );
27
28 $css_generator->add_class_styles(
29 '{{WRAPPER}} .ecm-shortcode--bookmark__list-item',
30 $this->getListCSS( $attributes ),
31 $this->getListCSS( $attributes, 'Tablet' ),
32 $this->getListCSS( $attributes, 'Mobile' ),
33
34 );
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} .ecm-shortcode--bookmark__list-item:hover',
37 $this->getListItemHoverCSS( $attributes ),
38 $this->getListItemHoverCSS( $attributes, 'Tablet' ),
39 $this->getListItemHoverCSS( $attributes, 'Mobile' ),
40
41 );
42 $css_generator->add_class_styles(
43 '{{WRAPPER}} .ecm-shortcode--bookmark__list',
44 $this->getListALignmentCSS( $attributes ),
45 $this->getListALignmentCSS( $attributes, 'Tablet' ),
46 $this->getListALignmentCSS( $attributes, 'Mobile' ),
47
48 );
49 $css_generator->add_class_styles(
50 '{{WRAPPER}} .ecm-shortcode--bookmark__list-title',
51 $this->getListTitleCSS( $attributes ),
52 $this->getListTitleCSS( $attributes, 'Tablet' ),
53 $this->getListTitleCSS( $attributes, 'Mobile' ),
54
55 );
56 $css_generator->add_class_styles(
57 '{{WRAPPER}} .ecm-shortcode--bookmark__list-date',
58 $this->getListDescriptionCSS( $attributes ),
59 $this->getListDescriptionCSS( $attributes, 'Tablet' ),
60 $this->getListDescriptionCSS( $attributes, 'Mobile' ),
61
62 );
63
64 $css_generator->add_class_styles(
65 '{{WRAPPER}}',
66 $this->getListNotFoundCSS($attributes),
67 $this->getListNotFoundCSS($attributes, 'Tablet'),
68 $this->getListNotFoundCSS($attributes, 'Mobile')
69 );
70
71 return $css_generator->generate_css();
72 }
73
74 public function render_block_content( $attributes, $content, $block_instance ) {
75 $attr_array = [
76 'user_id' => Helper::get_attribute_value( $attributes, 'user_id' ),
77 'not_found_text' => Helper::get_attribute_value( $attributes, 'not_found_text' ),
78 ];
79
80 $shortcode = '[ecm_bookmark_list ' . Helper::attr_shortcode( $attr_array ) . ']';
81 echo do_shortcode( $shortcode );
82 }
83
84 public function getListCSS( $attributes, $device = '' ) {
85 $css = [];
86 $cssPadding = [];
87 if ( $attributes['listBackground'] !== '' ) {
88 $css['background'] = $attributes['listBackground'];
89 }
90 if ( ! empty( $attributes['listPadding'] ) ) {
91 $cssPadding = Dimensions::get_css( $attributes['listPadding'], 'padding', $device );
92 }
93 return array_merge(
94 [ 'background' => Color::get_css( isset( $attributes['listBackground'] ) ? $attributes['listBackground'] : '' ) ],
95 $css,
96 Range::get_css([
97 'attributeValue' => $attributes['listWidth'],
98 'attribute_object_key' => 'value',
99 'isResponsive' => true,
100 'hasUnit' => true,
101 'defaultValue' => 33,
102 'unitDefaultValue' => '%',
103 'property' => 'width',
104 'device' => $device,
105 ]),
106 Border::get_css( $attributes['listBorder'], '', $device ),
107 $cssPadding,
108 BoxShadow::get_css( $attributes['listBoxShadow'], '', $device ),
109 );
110 }
111 public function getListItemHoverCSS( $attributes, $device = '' ) {
112 $css = [];
113 return array_merge(
114 $css,
115 BoxShadow::get_hover_css( $attributes['listBoxShadow'], '', $device ),
116 Border::get_hover_css( $attributes['listBorder'], '', $device )
117 );
118 }
119 public function getListALignmentCSS( $attributes, $device = '' ) {
120 $css = [];
121 $alignment_css = [];
122 $alignment_css['display'] = 'flex';
123
124 if ( ! empty( $attributes['listAlignment'][ 'value' . $device ] ) ) {
125 $alignment_css['align-items'] = $attributes['listAlignment'][ 'value' . $device ];
126 }
127 return array_merge(
128 $alignment_css,
129 );
130 }
131 public function getListTitleCSS( $attributes, $device = '' ) {
132 $css = [];
133 if ( $attributes['titleColor'] !== '' ) {
134 $css['color'] = $attributes['titleColor'];
135 }
136 $typographyValueGlobal = ! empty( $attributes['typographyGlobal'] ) ? $attributes['typographyGlobal'] : '';
137 $typography_css = ! empty( $attributes['titleTypography'] ) ? Typography::get_css( $attributes['titleTypography'], '', $device, $typographyValueGlobal ) : array();
138 $textShadowCss = ! empty( $attributes['titleTextShadow'] ) ? TextShadow::get_css( $attributes['titleTextShadow'], '', $device ) : array();
139 $textStrokeCss = ! empty( $attributes['titleTextStroke'] ) ? TextStroke::get_css( $attributes['titleTextStroke'], '', $device ) : array();
140
141 return array_merge(
142 $css,
143 $typography_css,
144 $textShadowCss,
145 $textStrokeCss
146 );
147 }
148 public function getListDescriptionCSS( $attributes, $device = '' ) {
149 $css = [];
150 if ( $attributes['desColor'] !== '' ) {
151 $css['color'] = $attributes['desColor'];
152 }
153 $typographyValueGlobal = ! empty( $attributes['typographyGlobal'] ) ? $attributes['typographyGlobal'] : '';
154 $typography_css = ! empty( $attributes['desTypography'] ) ? Typography::get_css( $attributes['desTypography'], '', $device, $typographyValueGlobal ) : array();
155 $textShadowCss = ! empty( $attributes['desTextShadow'] ) ? TextShadow::get_css( $attributes['desTextShadow'], '', $device ) : array();
156 $textStrokeCss = ! empty( $attributes['desTextStroke'] ) ? TextStroke::get_css( $attributes['desTextStroke'], '', $device ) : array();
157
158 return array_merge(
159 $css,
160 $typography_css,
161 $textShadowCss,
162 $textStrokeCss
163 );
164 }
165 public function getListNotFoundCSS( $attributes, $device = '' ) {
166 $css = [];
167 if ( ! empty( $attributes['notFoundAlignment'][ 'value' . $device ] ) ) {
168 $css['text-align'] = $attributes['notFoundAlignment'][ 'value' . $device ];
169 }
170 $color_css = ! empty( $attributes['notFoundColor'] ) ? [ 'color' => Color::get_css( $attributes['notFoundColor'] ) ] : [];
171 $typographyValueGlobal = ! empty( $attributes['typographyGlobal'] ) ? $attributes['typographyGlobal'] : '';
172 $typography_css = ! empty( $attributes['notFoundTypography'] ) ? Typography::get_css( $attributes['notFoundTypography'], '', $device, $typographyValueGlobal ) : [];
173 return array_merge( $css, $color_css, $typography_css );
174 }
175 }
176