PluginProbe
Bubble Menu – Floating Button Menu with Sticky Navigation / trunk
Bubble Menu – Floating Button Menu with Sticky Navigation vtrunk
trunk 1.3 2.0 2.2 2.2.1 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.1 4.1.1
bubble-menu / classes / Maker / Content.php

Content.php in Bubble Menu – Floating Button Menu with Sticky Navigation trunk, at classes/Maker/Content.php

544 lines 20.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BubbleMenu\Maker;
4
5 defined( 'ABSPATH' ) || exit;
6
7 class Content {
8 /**
9 * @var mixed
10 */
11 private $id;
12 /**
13 * @var mixed
14 */
15 private $param;
16 /**
17 * @var mixed
18 */
19 private $title;
20
21 public function __construct( $id, $param ) {
22 $this->id = $id;
23 $this->param = $param;
24 }
25
26 public function init(): string {
27 return $this->create();
28 }
29
30 private function create(): string {
31 $id = $this->id;
32 $param = $this->param;
33
34 $count = ! empty( $param['item']['type'] ) ? count( $param['item']['type'] ) : 0;
35
36 if ( $count === 0 ) {
37 return false;
38 }
39
40 $wrapper = $this->wrapper( $id, $param );
41
42 $menu = $wrapper;
43
44 $menu .= $this->button( $param );
45
46 $menu .= '<ul class="bm-list">';
47
48 $menu .= $this->elements( $count, $param );
49
50 $menu .= '</ul></div>'; // close menu tags
51
52 return $menu;
53 }
54
55 private function wrapper( $id, $param ): string {
56 $position = isset( $param['position'] ) ? ' ' . $param['position'] : ' -left';
57 $shape = isset( $param['shapes'] ) ? ' ' . $param['shapes'] : ' -circle';
58 $size = isset( $param['size'] ) ? ' ' . $param['size'] : ' -size-md';
59 $shadow = ! empty( $param['shadow'] ) ? ' -shadowless' : ' -shadow';
60 $animation = isset( $param['animation'] ) ? ' ' . $param['animation'] : '';
61 $open_menu = ! empty( $param['open_menu'] ) ? ' -active' : '';
62
63 $menu_add_classes = $position . $shape . $size . $shadow . $animation . $open_menu;
64
65 $action = '';
66
67 $action_type = ! empty( $param['action'] ) ? $param['action'] : '';
68
69 if ( $action_type === 'scroll_show' ) {
70 $action = ' data-behavior="showScroll:' . absint( $param['scroll'] ) . '"';
71 $menu_add_classes .= ' -hidden';
72 } elseif ( $action_type === 'scroll_hide' ) {
73 $action = ' data-behavior="hideScroll:' . absint( $param['scroll'] ) . '"';
74 } elseif ( $action_type === 'timer_show' ) {
75 $action = ' data-behavior="showDelay:' . absint( $param['timer'] ) * 1000 . '"';
76 $menu_add_classes .= ' -hidden';
77 } elseif ( $action_type === 'timer_hide' ) {
78 $action = ' data-behavior="hideDelay:' . absint( $param['timer'] ) * 1000 . '"';
79 }
80
81 if ( ! empty( $param['hide_menus'] ) ) {
82 $action .= ' data-bubbles-hide="true"';
83 }
84
85 if ( ! empty( $param['close_menus'] ) ) {
86 $action .= ' data-bubble-toggle="true"';
87 }
88
89 $style = '';
90
91 if ( ! empty( $param['zindex'] ) && $param['zindex'] !== '9' ) {
92 $style .= '--z-index:' . absint( $param['zindex'] ) . ';';
93 }
94
95 if ( ! empty( $param['margin_block'] ) ) {
96 $style .= '--margin-block:' . esc_attr( $param['margin_block'] ) . 'px;';
97 }
98
99 if ( ! empty( $param['margin_inline'] ) ) {
100 $style .= '--margin-inline:' . esc_attr( $param['margin_inline'] ) . 'px;';
101 }
102
103 if ( ! empty( $param['label_color'] ) ) {
104 $style .= '--label-color:' . esc_attr( $param['label_color'] ) . ';';
105 }
106
107 if ( ! empty( $param['label_background_color'] ) ) {
108 $style .= '--label-background:' . esc_attr( $param['label_background_color'] ) . ';';
109 }
110
111
112 $style = ! empty( $style ) ? ' style="' . esc_attr( $style ) . '"' : '';
113
114 $css = '';
115 if ( ! empty( $param['mobile_on'] ) ) {
116 $screen = ! empty( $param['mobile'] ) ? $param['mobile'] : 480;
117 $css .= '
118 @media only screen and (max-width: ' . absint( $screen ) . 'px){
119 #bubble-menu-' . absint( $id ) . ' {
120 display:none;
121 }
122 }';
123 }
124
125 if ( ! empty( $param['desktop_on'] ) ) {
126 $screen_more = ! empty( $param['desktop'] ) ? $param['desktop'] : 1200;
127 $css .= '
128 @media only screen and (min-width: ' . absint( $screen_more ) . 'px){
129 #bubble-menu-' . absint( $id ) . ' {
130 display:none;
131 }
132 }';
133 }
134 if ( ! empty( $css ) ) {
135 $css = '<style>' . trim( preg_replace( '~\s+~s', ' ', $css ) ) . '</style>';
136 }
137
138 return $css . '<div class="bubble-menu notranslate' . esc_attr( $menu_add_classes ) . '" id="bubble-menu-' . absint( $id ) . '"' . $action . $style . '>';
139 }
140
141 private function button( array $param ): string {
142 $label = ! empty( $param['label_on'] ) ? $param['label'] : '';
143
144 $style = '--color: ' . ( ! empty( $param['color'] ) ? esc_attr( $param['color'] ) : '#14102C' ) . ';';
145 $style .= '--background: ' . ( ! empty( $param['background_color'] ) ? esc_attr( $param['background_color'] ) : '#ffffff' ) . ';';
146 $style = ! empty( $style ) ? ' style="' . esc_attr( $style ) . '"' : '';
147
148 $keep_on = ! empty( $param['open'] ) ? ' -visible' : '';
149 $paused = ! empty( $param['icon_animation_paused'] ) ? ' -paused' : '';
150 $stop = ! empty( $param['icon_animation_open'] ) ? ' -stop-animation' : '';
151 $label_position = ! empty( $param['label_position'] ) ? ' ' . esc_attr( $param['label_position'] ) : '';
152
153 $out = '<button class="bm-toggle' . esc_attr( $keep_on . $paused . $stop . $label_position ) . '"';
154 if ( ! empty( $label ) ) {
155 $out .= ' data-label="' . esc_attr( $label ) . '"';
156 }
157 $out .= $style . '>';
158 $out .= $this->create_btn_icon( $param );
159 if ( ! empty( $label ) ) {
160 $out .= '<span class="bm-label">' . esc_attr( $label ) . '</span>';
161 }
162 $out .= '</button>';
163
164 return $out;
165 }
166
167 private function elements( $count, $param ): string {
168 $elements = '';
169
170 for ( $i = 0; $i < $count; $i ++ ) {
171
172 $item_type = $param['item']['type'][ $i ];
173
174 if ( $item_type === 'next_post' ) {
175 $next_post = get_next_post( true );
176 if ( empty( $next_post ) ) {
177 continue;
178 }
179 } elseif ( $item_type === 'previous_post' ) {
180 $previous_post = get_previous_post( true );
181 if ( empty( $previous_post ) ) {
182 continue;
183 }
184 }
185 $style = '--color:' . esc_attr( $param['item']['color'][ $i ] ) . ';';
186 $style .= '--background:' . esc_attr( $param['item']['background_color'][ $i ] ) . ';';
187
188 $elements .= '<li class="bm-item" style="' . esc_attr( $style ) . '">';
189 $elements .= $this->create_element( $param, $i, $item_type );
190 $elements .= '</li>';
191
192 }
193
194 return $elements;
195 }
196
197 private function create_element( $param, $i, $item_type ): string {
198 $icon = $this->create_icon( $param, $i );
199 $label = $this->create_label( $param, $i, $item_type );
200 $link = $this->create_link( $param, $i, $item_type, $icon, $label );
201
202 return $link;
203 }
204
205 private function create_btn_icon( $param ): string {
206 $icon = '';
207 $type = $param['icon_type'] ?? 'icon';
208 $animation = ! empty( $param['icon_animation'] ) ? ' ' . esc_attr( $param['icon_animation'] ) : '';
209 $flip = ! empty( $param['icon_flip'] ) ? ' ' . esc_attr( $param['icon_flip'] ) : '';
210
211 $style = '';
212
213 if ( ! empty( $param['icon_rotate'] ) ) {
214 $style .= '--icon-rotate: ' . esc_attr( $param['icon_rotate'] ) . 'deg;';
215 }
216
217 if ( ! empty( $param['icon_animation_delay'] ) ) {
218 $style .= '--icon-delay: ' . absint( $param['icon_animation_delay'] ) . 's;';
219 }
220
221 if ( ! empty( $param['icon_animation_duration'] ) ) {
222 $style .= '--icon-duration: ' . absint( $param['icon_animation_duration'] ) . 's;';
223 }
224
225 if ( ! empty( $param['icon_animation_count'] ) ) {
226 $style .= '--icon-count: ' . absint( $param['icon_animation_count'] ) . ';';
227 }
228
229 $style = ! empty( $style ) ? ' style="' . esc_attr( $style ) . '"' : '';
230
231 if ( $type === 'icon' ) {
232 $icon = '<span class="bm-icon ' . esc_attr( $param['icon'] ) . $animation . $flip . '"' . $style . '></span>';
233 }
234
235 if ( $type === 'image' ) {
236 $img_alt = ! empty( $param['image_alt'] ) ? $param['image_alt'] : '';
237 $img_link = $param['image'];
238 $icon = '<img class="bm-icon' . esc_attr( $animation . $flip ) . '" src="' . esc_url( $img_link ) . '" alt="' . esc_attr( $img_alt ) . '"' . $style . '>';
239 }
240
241 if ( $type === 'class' ) {
242 $icon = '<span class="bm-icon ' . esc_attr( $param['icon_class'] . $animation . $flip ) . '"' . $style . '></span>';
243 }
244
245 if ( $type === 'emoji' ) {
246 $icon = '<span class="bm-icon' . esc_attr( $animation . $flip ) . '"' . $style . '>' . wp_kses_post( $param['emoji'] ) . '</span>';
247 }
248
249 return $icon;
250 }
251
252 private function create_icon( $param, $i ): string {
253 $icon = '';
254 $icon_type = $param['item']['icon_type'][ $i ] ?? 'icon';
255
256 $animation = ! empty( $param['item']['icon_animation'][ $i ] ) ? ' ' . esc_attr( $param['item']['icon_animation'][ $i ] ) : '';
257 $flip = ! empty( $param['item']['icon_flip'][ $i ] ) ? ' ' . esc_attr( $param['item']['icon_flip'][ $i ] ) : '';
258
259 $style = '';
260
261 if ( ! empty( $param['item']['icon_rotate'][ $i ] ) ) {
262 $style .= '--icon-rotate: ' . esc_attr( $param['item']['icon_rotate'][ $i ] ) . 'deg;';
263 }
264
265 if ( ! empty( $param['item']['icon_animation_delay'][ $i ] ) ) {
266 $style .= '--icon-delay: ' . absint( $param['item']['icon_animation_delay'][ $i ] ) . 's;';
267 }
268
269 if ( ! empty( $param['item']['icon_animation_duration'][ $i ] ) ) {
270 $style .= '--icon-duration: ' . absint( $param['item']['icon_animation_duration'][ $i ] ) . 's;';
271 }
272
273 if ( ! empty( $param['item']['icon_animation_count'][ $i ] ) ) {
274 $style .= '--icon-count: ' . absint( $param['item']['icon_animation_count'][ $i ] ) . ';';
275 }
276
277 $style = ! empty( $style ) ? ' style="' . esc_attr( $style ) . '"' : '';
278
279 if ( $icon_type === 'icon' ) {
280 $icon = '<span class="bm-icon ' . esc_attr( $param['item']['icon'][ $i ] . $animation . $flip ) . '"' . $style . '></span>';
281 }
282
283 if ( $icon_type === 'image' ) {
284 $img_alt = ! empty( $param['item']['image_alt'][ $i ] ) ? $param['item']['image_alt'][ $i ] : '';
285 $img_link = $param['item']['image'][ $i ];
286 $icon = '<img class="bm-icon' . esc_attr( $animation . $flip ) . '" src="' . esc_url( $img_link ) . '" alt="' . esc_attr( $img_alt ) . '"' . $style . '>';
287 }
288
289 if ( $icon_type === 'class' ) {
290 $icon = '<span class="bm-icon ' . esc_attr( $param['item']['icon_class'][ $i ] . $animation . $flip ) . '"' . $style . '></span>';
291 }
292
293 if ( $icon_type === 'emoji' ) {
294 $icon = '<span class="bm-icon' . esc_attr( $animation . $flip ) . '"' . $style . '>' . wp_kses_post( $param['item']['emoji'][ $i ] ) . '</span>';
295 }
296
297 return $icon;
298 }
299
300 private function create_label( $param, $i, $item_type ): string {
301 $label = '';
302 $text = ! empty( $param['item']['label_on'][ $i ] ) ? $param['item']['label'][ $i ] : '';
303
304 if ( $item_type === 'email' ) {
305 $text = is_email( $text ) ? antispambot( $text ) : $text;
306 }
307
308 $label = ! empty( $text ) ? '<span class="bm-label">' . esc_html( $text ) . '</span>' : '';
309
310 return $label;
311 }
312
313 private function create_link( $param, $i, $item_type, $icon, $tooltip ): string {
314 $link_param = $this->link_param( $param, $i );
315 $menu = '';
316 $text = ! empty( $param['item']['label_on'][ $i ] ) ? $param['item']['label'][ $i ] : '';
317 if ( ! empty( $text ) ) {
318 $link_param .= ' data-label="' . esc_attr( $text ) . '"';
319 }
320
321 switch ( $item_type ) {
322 case 'link':
323 $target = ! empty( $param['item']['link_tab'][ $i ] ) ? '_blank' : '_self';
324 $link = ! empty( $param['item']['link'][ $i ] ) ? $param['item']['link'][ $i ] : '#';
325 $menu .= '<a href="' . esc_url( $link ) . '" target="' . esc_attr( $target ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
326 $menu .= $icon . $tooltip;
327 $menu .= '</a>';
328 break;
329 case 'download':
330 $link = ! empty( $param['item']['link'][ $i ] ) ? $param['item']['link'][ $i ] : '#';
331 $download = ! empty( $param['item']['download'][ $i ] ) ? ' download="' . esc_attr( $param['item']['download'][ $i ] ) . '"' : ' download';
332 $menu .= '<a href="' . esc_attr( $link ) . '"' . $download . wp_specialchars_decode( $link_param, 'double' ) . '>';
333 $menu .= $icon . $tooltip;
334 $menu .= '</a>';
335 break;
336 case 'share':
337 $share_service = mb_strtolower( $param['item']['share'][ $i ] );
338 $menu .= '<a href="#" data-action="share" data-target="' . esc_attr( $share_service ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
339 $menu .= $icon . $tooltip;
340 $menu .= '</a>';
341 break;
342 case 'translate':
343 $glang = $param['item']['translate'][ $i ];
344 $menu .= '<a href="#" data-action="translate" data-target="' . esc_attr( $glang ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
345 $menu .= $icon . $tooltip;
346 $menu .= '</a>';
347 break;
348 case 'print':
349 case 'totop':
350 case 'tobottom':
351 case 'goback':
352 case 'goforward':
353 case 'copyUrl':
354 case 'bookmark':
355 $menu .= '<a href="#" data-action="' . esc_attr( $item_type ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
356 $menu .= $icon . $tooltip;
357 $menu .= '</a>';
358 break;
359 case 'smoothscroll':
360 $link = ! empty( $param['item']['link'][ $i ] ) ? $param['item']['link'][ $i ] : '#';
361 $menu .= '<a href="' . esc_attr( $link ) . '" data-action="' . esc_attr( $item_type ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
362 $menu .= $icon . $tooltip;
363 $menu .= '</a>';
364 break;
365 case 'scrollSpy':
366 $link = ! empty( $param['item']['link'][ $i ] ) ? $param['item']['link'][ $i ] : '#';
367 $menu .= '<a href="' . esc_attr( $link ) . '" data-action="scrollSpy"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
368 $menu .= $icon . $tooltip;
369 $menu .= '</a>';
370 break;
371 case 'login':
372 case 'logout':
373 case 'lostpassword':
374 $link = call_user_func( 'wp_' . $item_type . '_url', $param['item']['link'][ $i ] );
375 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
376 $menu .= $icon . $tooltip;
377 $menu .= '</a>';
378 break;
379 case 'register':
380 $link = wp_registration_url();
381 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
382 $menu .= $icon . $tooltip;
383 $menu .= '</a>';
384 break;
385 case 'telephone':
386 $link = 'tel:' . $param['item']['link'][ $i ];
387 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
388 $menu .= $icon . $tooltip;
389 $menu .= '</a>';
390 break;
391 case 'email':
392 $email = $param['item']['link'][ $i ];
393 $link = is_email( $email ) ? 'mailto:' . antispambot( $email ) : $email;
394 $tooltip = is_email( $tooltip ) ? antispambot( $tooltip ) : $tooltip;
395 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
396 $menu .= $icon . $tooltip;
397 $menu .= '</a>';
398 break;
399 case 'next_post':
400 $target = ! empty( $param['item']['link_tab'][ $i ] ) ? '_blank' : '_self';
401 $next_post = get_next_post( true );
402 $link = get_permalink( $next_post );
403 $menu .= '<a href="' . esc_attr( $link ) . '" target="' . esc_attr( $target ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
404 $menu .= $icon . $tooltip;
405 $menu .= '</a>';
406 break;
407 case 'previous_post':
408 $target = ! empty( $param['item']['link_tab'][ $i ] ) ? '_blank' : '_self';
409 $previous_post = get_previous_post( true );
410 $link = get_permalink( $previous_post );
411 $menu .= '<a href="' . esc_attr( $link ) . '" target="' . esc_attr( $target ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
412 $menu .= $icon . $tooltip;
413 $menu .= '</a>';
414 break;
415 case 'font':
416 $action = ! empty( $param['item']['font'][ $i ] ) ? $param['item']['font'][ $i ] : 'increase';
417 $menu .= '<a href="#" data-action="' . esc_attr( $item_type ) . '" data-target="' . esc_attr( $action ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
418 $menu .= $icon . $tooltip;
419 $menu .= '</a>';
420 break;
421 case 'popover':
422 $link = 'bm-popover-' . $this->id . '-' . $i;
423 $menu .= '<a href="#' . esc_attr( $link ) . '" data-action="popover"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
424 $menu .= $icon . $tooltip;
425 $menu .= '</a>';
426
427 $style = '--popover-size:' . absint( $param['item']['popup_size'][ $i ] ) . 'px;';
428 $style .= '--popover-inline:' . absint( $param['item']['popup_width'][ $i ] ) . 'px;';
429 $style .= '--popover-block:' . absint( $param['item']['popup_height'][ $i ] ) . 'px;';
430 $style .= '--popover-padding:' . absint( $param['item']['popup_padding'][ $i ] ) . 'px;';
431 $style .= '--popover-border-color:' . esc_attr( $param['item']['popup_border_color'][ $i ] ) . ';';
432 $style .= '--popover-backdrop:' . esc_attr( $param['item']['popup_backdrop'][ $i ] ) . ';';
433 $menu .= '<div id="' . esc_attr( $link ) . '" popover style="' . esc_attr( $style ) . '">';
434 $menu .= wpautop( do_shortcode( wp_kses_post( $param['item']['popup'][ $i ] ) ) );
435 $menu .= '</div>';
436 break;
437 case 'skype_call':
438 $link = 'skype:' . $param['item']['link'][ $i ] . '?call';
439 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
440 $menu .= $icon . $tooltip;
441 $menu .= '</a>';
442 break;
443 case 'skype_chat':
444 $link = 'skype:' . $param['item']['link'][ $i ] . '?chat';
445 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
446 $menu .= $icon . $tooltip;
447 $menu .= '</a>';
448 break;
449 case 'whatsapp_call':
450 $link = 'whatsapp://call?number=' . $param['item']['link'][ $i ];
451 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
452 $menu .= $icon . $tooltip;
453 $menu .= '</a>';
454 break;
455 case 'whatsapp_chat':
456 $link = 'https://wa.me/' . $param['item']['link'][ $i ];
457 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
458 $menu .= $icon . $tooltip;
459 $menu .= '</a>';
460 break;
461 case 'viber_call':
462 $link = 'viber://call?number=' . $param['item']['link'][ $i ];
463 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
464 $menu .= $icon . $tooltip;
465 $menu .= '</a>';
466 break;
467 case 'viber_chat':
468 $link = 'viber://chat?number=' . $param['item']['link'][ $i ];
469 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
470 $menu .= $icon . $tooltip;
471 $menu .= '</a>';
472 break;
473 case 'imessage_chat':
474 $link = 'imessage:' . $param['item']['link'][ $i ];
475 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
476 $menu .= $icon . $tooltip;
477 $menu .= '</a>';
478 break;
479 case 'telegram_chat':
480 $link = 'https://t.me/' . $param['item']['link'][ $i ];
481 $menu .= '<a href="' . esc_attr( $link ) . '"' . wp_specialchars_decode( $link_param, 'double' ) . '>';
482 $menu .= $icon . $tooltip;
483 $menu .= '</a>';
484 break;
485
486 }
487
488 return $menu;
489 }
490
491 private function generate_link(
492 $url,
493 $target = '',
494 $icon = '',
495 $tooltip = '',
496 $link_param = '',
497 $data_attr = '',
498 $data_value = ''
499 ): string {
500 $link = '<a href="' . esc_url( $url ) . '" ' . wp_specialchars_decode( $link_param, 'double' );
501 $link .= ! empty( $target ) ? ' target="' . esc_attr( $target ) . '"' : '';
502 $link .= ! empty( $data_attr ) ? ' ' . esc_attr( $data_attr ) . '="' . esc_attr( $data_value ) . '"' : '';
503 $link .= '>';
504 $link .= $icon . $tooltip;
505 $link .= '</a>';
506
507 return $link;
508 }
509
510 private function link_param( $param, $i ): string {
511 $style = '';
512 if ( ! empty( $param['item']['label_color'][ $i ] ) ) {
513 $style .= '--label-color:' . esc_attr( $param['item']['label_color'][ $i ] ) . ';';
514 }
515
516 if ( ! empty( $param['item']['label_background_color'][ $i ] ) ) {
517 $style .= '--label-background:' . esc_attr( $param['item']['label_background_color'][ $i ] ) . ';';
518 }
519
520 $style = ! empty( $style ) ? ' style="' . esc_attr( $style ) . '"' : '';
521
522 $button_class = $param['item']['attribute_class'][ $i ];
523 $class_add = ' class="bm-link';
524 $class_add .= ! empty( $button_class ) ? ' ' . esc_attr( $button_class ) : '';
525 if ( ! empty( $param['item']['open'][ $i ] ) ) {
526 $class_add .= ' -visible';
527 }
528 if ( ! empty( $param['item']['icon_animation_paused'][ $i ] ) ) {
529 $class_add .= ' -paused';
530 }
531
532 if ( ! empty( $param['item']['label_position'][ $i ] ) ) {
533 $class_add .= ' ' . esc_attr( $param['item']['label_position'][ $i ] );
534 }
535
536 $class_add .= '"';
537 $button_id = $param['item']['attribute_id'][ $i ];
538 $id_add = ! empty( $button_id ) ? ' id="' . esc_attr( $button_id ) . '"' : '';
539 $link_rel = ! empty( $param['item']['attribute_rel'][ $i ] ) ? ' rel="' . esc_attr( $param['item']['attribute_rel'][ $i ] ) . '"' : '';
540
541 return $id_add . $class_add . $link_rel . $style;
542 }
543
544 }