PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Elementor / Widgets / General / FlipBox / Render.php

Render.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.6, at app/Elementor/Widgets/General/FlipBox/Render.php

172 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Render class for Advanced Heading widget.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Elementor\Widgets\General\FlipBox;
9
10 use RadiusTheme\SB\Elementor\Helper\RenderHelpers;
11 use RadiusTheme\SB\Helpers\Fns;
12 use RadiusTheme\SB\Elementor\Render\GeneralAddons;
13
14 // Do not allow directly accessing this file.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit( 'This script cannot be accessed directly.' );
17 }
18
19 /**
20 * Render class.
21 *
22 * @package RadiusTheme\SB
23 */
24 class Render extends GeneralAddons {
25 /**
26 * Main render function for displaying content.
27 *
28 * @param array $data Data to be passed to the template.
29 * @param array $settings Widget settings.
30 *
31 * @return string
32 */
33 public function display_content( $data, $settings ) {
34 $this->settings = $settings;
35 $data = wp_parse_args( $this->get_template_args( $data['id'] ), $data );
36 $data = apply_filters( 'rtsb/general/flip_box/args/' . $data['unique_name'], $data );
37 $data['content'] = Fns::load_template( $data['template'], $data, true );
38
39 return $this->addon_view( $data, $settings );
40 }
41
42 /**
43 * Retrieves template arguments based on widget settings.
44 *
45 * @return array
46 */
47 private function get_template_args( $id ) {
48 return [
49 'flip_behavior' => $this->settings['flip_behavior'] ?? 'hover',
50 'flip_direction' => $this->settings['flip_direction'] ?? 'flip-left',
51 'flip_selected_side' => $this->settings['flip_selected_side'] ?? 'front',
52 'flip_box_front_title_html_tag' => $this->settings['flip_box_front_title_html_tag'] ?? 'h2',
53 'flip_box_back_title_html_tag' => $this->settings['flip_box_back_title_html_tag'] ?? 'h2',
54 'flip_box_front_title' => $this->settings['flip_box_front_title'],
55 'flip_box_back_title' => $this->settings['flip_box_back_title'],
56 'has_front_description' => ! empty( $this->settings['display_front_content'] ) && ! empty( $this->settings['flip_box_front_content'] ),
57 'has_back_description' => ! empty( $this->settings['display_back_content'] ) && ! empty( $this->settings['flip_box_back_content'] ),
58 'front_description' => $this->settings['flip_box_front_content'] ?? '',
59 'back_description' => $this->settings['flip_box_back_content'] ?? '',
60 'has_front_button' => ! empty( $this->settings['display_front_button'] ),
61 'sb_front_button_content' => $this->settings['sb_front_button_content'],
62 'sb_front_button_icon' => $this->settings['sb_front_button_icon'] ?? '',
63 'sb_front_button_icon_position' => $this->settings['sb_front_button_icon_position'] ?? 'right',
64 'front_button_attributes' => $this->render_button_attributes( 'rtsb_front_button_' . $id, 'sb_front_button_link', 'front-primary-btn' ) ?? '',
65 'has_back_button' => ! empty( $this->settings['display_back_button'] ),
66 'sb_back_button_content' => $this->settings['sb_back_button_content'],
67 'sb_back_button_icon' => $this->settings['sb_back_button_icon'] ?? '',
68 'sb_back_button_icon_position' => $this->settings['sb_back_button_icon_position'] ?? 'right',
69 'back_button_attributes' => $this->render_button_attributes( 'rtsb_back_button_' . $id, 'sb_back_button_link', 'back-primary-btn' ) ?? '',
70 'front_side_icon_html' => $this->render_icon_image( 'front' ),
71 'back_side_icon_html' => $this->render_icon_image( 'back' ),
72 'front_icon_type' => $this->settings['flip_box_front_icon_type'] ?? 'icon',
73 'back_icon_type' => $this->settings['flip_box_back_icon_type'] ?? 'icon',
74 'flip_animate_class' => $this->flip_animate_class(),
75 'icon_bg_type' => ! empty( $this->settings['flip_box_icon_style_gradient_bg_background'] ) ? $this->settings['flip_box_icon_style_gradient_bg_background'] : 'classic',
76 'icon_hover_bg_type' => ! empty( $this->settings['flip_box_icon_style_hover_gradient_bg_background'] ) ? $this->settings['flip_box_icon_style_hover_gradient_bg_background'] : 'classic',
77 ];
78 }
79 /**
80 * Function to render button attributes.
81 *
82 * @param string $id Element ID.
83 *
84 * @return string
85 */
86 public function render_button_attributes( $id, $control_name, $class, $type = 'rtsb-btn' ) {
87 if ( ! empty( $this->settings['hover_animation'] ) ) {
88 $class .= ' ' . 'hover-' . $this->settings['hover_animation'];
89 }
90 $this->add_attribute( $id, 'class', $type . ' ' . $class );
91
92 if ( ! empty( $this->settings[ $control_name ]['url'] ) ) {
93 $this->add_link_attributes( $id, $this->settings[ $control_name ] );
94 } else {
95 $this->add_attribute( $id, 'role', 'button' );
96 }
97
98 return $this->get_attribute_string( $id );
99 }
100 /**
101 * Function to add flip animate class.
102 *
103 * @return string
104 */
105 public function flip_animate_class() {
106
107 $animate_class = '';
108 $flip_directions = [ 'sb-flip-3d-left', 'sb-flip-3d-right', 'sb-flip-3d-up', 'sb-flip-3d-bottom' ];
109 $animate_class .= $this->settings['flip_direction'] ?? 'sb-flip-left';
110
111 if ( in_array( $this->settings['flip_direction'], $flip_directions ) ) {
112 $animate_class .= ' sb-3d-flip';
113 }
114 if ( 'back' === $this->settings['flip_selected_side'] ) {
115 $animate_class .= ' flip-back-selected';
116 }
117 if ( 'click' === $this->settings['flip_behavior'] ) {
118 $animate_class .= ' click';
119 }
120 return $animate_class;
121 }
122 /**
123 * Function to render icon.
124 *
125 * @param string $position icon position ('left' or 'right').
126 * @param array $icon Position of the separator in settings.
127 *
128 * @return string
129 */
130 public static function render_icon( $position, $icon, $icon_position ) {
131 $html = '';
132
133 // Render the left icon.
134 if ( $position === $icon_position ) {
135 $html .= '<span class="icon">' . Fns::icons_manager( $icon ) . '</span>';
136 }
137
138 return $html;
139 }
140
141 /**
142 * Function to render icon image.
143 *
144 * @return string
145 */
146 public function render_icon_image( $prefix ) {
147 $icon_img_html = '';
148
149 $icon = $this->settings[ 'flip_box_' . $prefix . '_icon' ] ?? '';
150
151 if ( 'icon' === $this->settings[ 'flip_box_' . $prefix . '_icon_type' ] ) {
152 $icon_img_html .= '<span class="icon">' . Fns::icons_manager( $icon ) . '</span>';
153 } else {
154 if ( ! empty( $this->settings[ 'flip_box_' . $prefix . '_image' ] ) ) {
155 $c_image_size = RenderHelpers::get_data( $this->settings, 'flip_box_' . $prefix . '_img_dimension', [] );
156 $c_image_size['crop'] = RenderHelpers::get_data( $this->settings, 'flip_box_' . $prefix . '_img_crop', [] );
157 $c_image_size = ! empty( $c_image_size ) && is_array( $c_image_size ) ? $c_image_size : [];
158 $image_id = ! empty( $this->settings[ 'flip_box_' . $prefix . '_image' ]['id'] ) ? $this->settings[ 'flip_box_' . $prefix . '_image' ]['id'] : $this->settings[ 'flip_box_' . $prefix . '_image' ];
159 $icon_img_html .= Fns::get_product_image_html(
160 '',
161 null,
162 RenderHelpers::get_data( $this->settings, 'flip_box_' . $prefix . '_image_size', 'full' ),
163 $image_id,
164 $c_image_size
165 );
166 }
167 }
168
169 return $icon_img_html;
170 }
171 }
172