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 / CallToAction / Render.php

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

134 lines 4.7 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\CallToAction;
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/cta/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 'cta_title_html_tag' => $this->settings['cta_title_html_tag'] ?? 'h2',
50 'cta_title' => $this->settings['cta_title'],
51 'has_description' => ! empty( $this->settings['display_content'] ) && ! empty( $this->settings['cta_content'] ),
52 'description' => $this->settings['cta_content'] ?? '',
53 'has_button' => ! empty( $this->settings['display_button'] ),
54 'has_button2' => ! empty( $this->settings['display_button2'] ),
55 'sb_button_content' => $this->settings['sb_button_content'],
56 'sb_button2_content' => $this->settings['sb_button2_content'],
57 'sb_button_icon' => $this->settings['sb_button_icon'] ?? '',
58 'sb_button_icon_position' => $this->settings['sb_button_icon_position'] ?? 'right',
59 'button1_attributes' => $this->render_button_attributes( 'rtsb_button_' . $id, 'sb_button_link', 'primary-btn' ) ?? '',
60 'button2_attributes' => $this->render_button_attributes( 'rtsb_button2_' . $id, 'sb_button2_link', 'secondary-btn' ) ?? '',
61 'cta_img_link_attributes' => $this->render_button_attributes( 'rtsb_cta_image_' . $id, 'cta_img_link', 'cta-img-link', 'rtsb-link' ) ?? '',
62 'section_parallax' => ! empty( $this->settings['parallax_effect'] ) && 'yes' === $this->settings['parallax_effect'] ? 'has-rtsb-parallax' : '',
63 'parallax_speed' => $this->settings['parallax_speed'] ?? '0.5',
64 'img_html' => $this->render_image(),
65 'has_cta_img_linkable' => ! empty( $this->settings['cta_img_linkable'] ),
66 'has_cta_img_link' => $this->settings['cta_img_link'] ?? '',
67 ];
68 }
69 /**
70 * Function to render button attributes.
71 *
72 * @param string $id Element ID.
73 *
74 * @return string
75 */
76 public function render_button_attributes( $id, $control_name, $class, $type = 'rtsb-btn' ) {
77 if ( ! empty( $this->settings['hover_animation'] ) ) {
78 $class .= ' ' . 'hover-' . $this->settings['hover_animation'];
79 }
80 $this->add_attribute( $id, 'class', $type . ' ' . $class );
81
82 if ( ! empty( $this->settings[ $control_name ]['url'] ) ) {
83 $this->add_link_attributes( $id, $this->settings[ $control_name ] );
84 } else {
85 $this->add_attribute( $id, 'role', 'button' );
86 }
87
88 return $this->get_attribute_string( $id );
89 }
90
91 /**
92 * Function to render icon.
93 *
94 * @param string $position icon position ('left' or 'right').
95 * @param array $icon Position of the separator in settings.
96 *
97 * @return string
98 */
99 public static function render_icon( $position, $icon, $icon_position ) {
100 $html = '';
101
102 // Render the left icon.
103 if ( $position === $icon_position ) {
104 $html .= '<span class="icon">' . Fns::icons_manager( $icon ) . '</span>';
105 }
106
107 return $html;
108 }
109
110 /**
111 * Function to render image.
112 *
113 * @return string
114 */
115 public function render_image() {
116 $img_html = '';
117
118 if ( ! empty( $this->settings['cta_image'] ) ) {
119 $c_image_size = RenderHelpers::get_data( $this->settings, 'cta_img_dimension', [] );
120 $c_image_size['crop'] = RenderHelpers::get_data( $this->settings, 'cta_img_crop', [] );
121 $c_image_size = ! empty( $c_image_size ) && is_array( $c_image_size ) ? $c_image_size : [];
122 $image_id = ! empty( $this->settings['cta_image']['id'] ) ? $this->settings['cta_image']['id'] : $this->settings['cta_image'];
123 $img_html .= Fns::get_product_image_html(
124 '',
125 null,
126 RenderHelpers::get_data( $this->settings, 'cta_image_size', 'full' ),
127 $image_id,
128 $c_image_size
129 );
130 }
131 return $img_html;
132 }
133 }
134