PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0
Elementor Website Builder – more than just a page builder v4.0.0
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / floating-buttons / classes / render / floating-bars-core-render.php

floating-bars-core-render.php in Elementor Website Builder – more than just a page builder 4.0.0, at modules/floating-buttons/classes/render/floating-bars-core-render.php

148 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\FloatingButtons\Classes\Render;
4
5 use Elementor\Icons_Manager;
6
7 /**
8 * Class Floating_Bars_Core_Render.
9 *
10 * This class handles the rendering of the Floating Bars widget for the core version.
11 *
12 * @since 3.23.0
13 */
14 class Floating_Bars_Core_Render extends Floating_Bars_Render_Base {
15
16 protected function render_announcement_icon(): void {
17 $icon = $this->settings['announcement_icon'] ?? '';
18
19 if ( '' !== $icon['value'] ) : ?>
20 <span class="e-floating-bars__announcement-icon"><?php Icons_Manager::render_icon( $icon, [ 'aria-hidden' => 'true' ] ); ?></span>
21 <?php endif;
22 }
23
24 protected function render_announcement_text(): void {
25 $text = $this->settings['announcement_text'] ?? '';
26
27 $this->widget->add_render_attribute( 'announcement_text', [
28 'class' => 'e-floating-bars__announcement-text',
29 ] );
30
31 if ( '' !== $text ) : ?>
32 <p <?php $this->widget->print_render_attribute_string( 'announcement_text' ); ?>>
33 <?php echo esc_html( $text ); ?>
34 </p>
35 <?php endif;
36 }
37
38 protected function render_cta_icon(): void {
39 $icon = $this->settings['cta_icon'] ?? '';
40 $icon_classnames = 'e-floating-bars__cta-icon';
41
42 $this->widget->add_render_attribute( 'cta-icon', [
43 'class' => $icon_classnames,
44 ] );
45
46 if ( '' !== $icon['value'] ) : ?>
47 <span <?php echo $this->widget->get_render_attribute_string( 'cta-icon' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>><?php Icons_Manager::render_icon( $icon, [ 'aria-hidden' => 'true' ] ); ?></span>
48 <?php endif;
49 }
50
51 protected function render_cta_button(): void {
52 $link = $this->settings['cta_link'] ?? '';
53 $text = $this->settings['cta_text'] ?? '';
54
55 $hover_animation = $this->settings['style_cta_button_hover_animation'];
56 $corners = $this->settings['style_cta_button_corners'];
57 $link_type = $this->settings['style_cta_type'];
58 $entrance_animation = $this->settings['style_cta_button_animation'];
59 $has_border = $this->settings['style_cta_button_show_border'];
60
61 $cta_classnames = 'e-floating-bars__cta-button';
62
63 if ( ! empty( $hover_animation ) ) {
64 $cta_classnames .= ' elementor-animation-' . $hover_animation;
65 }
66
67 if ( ! empty( $corners ) ) {
68 $cta_classnames .= ' has-corners-' . $corners;
69 }
70
71 if ( ! empty( $link_type ) ) {
72 $cta_classnames .= ' is-type-' . $link_type;
73 }
74
75 if ( ! empty( $entrance_animation ) && 'none' != $entrance_animation ) {
76 $cta_classnames .= ' has-entrance-animation';
77 }
78
79 if ( 'yes' == $has_border ) {
80 $cta_classnames .= ' has-border';
81 }
82
83 $this->widget->add_render_attribute( 'cta-button', [
84 'class' => $cta_classnames,
85 ] );
86
87 $this->widget->add_render_attribute( 'cta_text', [
88 'class' => 'e-floating-bars__cta-text',
89 ] );
90
91 if ( ! empty( $text ) ) {
92 $this->widget->add_link_attributes( 'cta-button', $link );
93 ?>
94 <div class="e-floating-bars__cta-button-container">
95 <a <?php echo $this->widget->get_render_attribute_string( 'cta-button' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
96 <?php $this->render_cta_icon(); ?>
97 <span <?php $this->widget->print_render_attribute_string( 'cta_text' ); ?>><?php echo esc_html( $text ); ?></span>
98 </a>
99 </div>
100 <?php
101 }
102 }
103
104 protected function render_close_button(): void {
105 $accessible_name = $this->settings['accessible_name'];
106 $close_button_classnames = 'e-floating-bars__close-button';
107
108 $this->widget->add_render_attribute( 'close-button', [
109 'class' => $close_button_classnames,
110 'aria-label' => sprintf(
111 /* translators: %s: Accessible name. */
112 esc_html__( 'Close %s', 'elementor' ),
113 $accessible_name,
114 ),
115 'type' => 'button',
116 'aria-controls' => 'e-floating-bars',
117 ] );
118
119 ?>
120 <button <?php echo $this->widget->get_render_attribute_string( 'close-button' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
121 <i class="eicon-close"></i>
122 </button>
123 <?php
124 }
125
126 public function render(): void {
127 $this->build_layout_render_attribute();
128 $has_close_button = $this->settings['floating_bar_close_switch'];
129
130 ?>
131 <div <?php echo $this->widget->get_render_attribute_string( 'layout' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
132 <?php
133 $this->render_announcement_text();
134
135 $this->render_announcement_icon();
136
137 $this->render_cta_button();
138
139 if ( 'yes' === $has_close_button ) {
140 $this->render_close_button();
141 }
142 ?>
143 <div class="e-floating-bars__overlay"></div>
144 </div>
145 <?php
146 }
147 }
148