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

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

119 lines 3.9 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\Testimonial;
9
10 use DateTime;
11 use DateTimeZone;
12 use RadiusTheme\SB\Elementor\Helper\RenderHelpers;
13 use RadiusTheme\SB\Helpers\Fns;
14 use RadiusTheme\SB\Elementor\Render\GeneralAddons;
15
16 // Do not allow directly accessing this file.
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit( 'This script cannot be accessed directly.' );
19 }
20
21 /**
22 * Render class.
23 *
24 * @package RadiusTheme\SB
25 */
26 class Render extends GeneralAddons {
27 /**
28 * Main render function for displaying content.
29 *
30 * @param array $data Data to be passed to the template.
31 * @param array $settings Widget settings.
32 *
33 * @return string
34 */
35 public function display_content( $data, $settings ) {
36 $data['content'] = '';
37 $this->settings = $settings;
38 $data = wp_parse_args( $this->get_template_args( $data ), $data );
39 $data = apply_filters( 'rtsb/general/testimonial/args/' . $data['unique_name'], $data );
40 if ( ! empty( $data['testimonial_items'] ) ) {
41 foreach ( $data['testimonial_items'] as $testimonial ) {
42 $data['testimonial'] = $testimonial;
43 $data['author_designation'] = $testimonial['author_designation'] ?? '';
44 $data['author_name'] = $testimonial['author_name'] ?? '';
45 $data['author_description'] = $testimonial['author_description'] ?? '';
46 $data['author_rating'] = $testimonial['author_rating'] ?? '';
47 $data['grid_classes'] = $this->content_classes;
48 $data['content'] .= Fns::load_template( $data['template'], $data, true );
49 }
50
51 return $this->addon_view( $data, $settings );
52 } else {
53 return '<p>' . esc_html__( 'Please add a testimonial.', 'shopbuilder' ) . '</p>';
54 }
55 }
56 /**
57 * Retrieves template arguments based on widget settings.
58 *
59 * @param array $data Data to be passed to the template.
60 *
61 * @return array
62 */
63 private function get_template_args( $data ) {
64 if ( ! empty( $data['content_class'] ) ) {
65 $this->content_classes[] = $data['content_class'];
66 }
67
68 if ( ! empty( $this->settings['activate_slider_item'] ) ) {
69 $this->content_classes = array_merge(
70 $this->content_classes,
71 [
72 'rtsb-testimonial',
73 'rtsb-slide-item',
74 'swiper-slide',
75 'animated',
76 'rtFadeIn',
77 ]
78 );
79 }
80
81 $this->content_classes = is_array( $this->content_classes ) ? implode( ' ', $this->content_classes ) : $this->content_classes;
82
83 return [
84 'testimonial_items' => $this->settings['testimonial_items'] ?? [],
85 'author_name_html_tag' => $this->settings['author_name_html_tag'] ?? 'h2',
86 'display_quote_icon' => ! empty( $this->settings['display_quote_icon'] ),
87 'has_designation' => ! empty( $this->settings['display_author_designation'] ),
88 'display_author_image' => ! empty( $this->settings['display_author_image'] ),
89 'has_rating' => ! empty( $this->settings['display_author_rating'] ),
90 'instance' => $this,
91 ];
92 }
93 /**
94 * Function to render author image.
95 *
96 * @param array $author_image_attr author image attributes.
97 *
98 * @return string
99 */
100 public function render_author_image( $author_image_attr ) {
101 $img_html = '';
102 if ( ! empty( $author_image_attr['author_image'] ) ) {
103 $c_image_size = RenderHelpers::get_data( $this->settings, 'author_img_dimension', [] );
104 $c_image_size['crop'] = RenderHelpers::get_data( $this->settings, 'author_img_crop', [] );
105 $c_image_size = ! empty( $c_image_size ) && is_array( $c_image_size ) ? $c_image_size : [];
106 $image_id = ! empty( $author_image_attr['author_image']['id'] ) ? $author_image_attr['author_image']['id'] : $author_image_attr['author_image'];
107 $img_html .= Fns::get_product_image_html(
108 '',
109 null,
110 RenderHelpers::get_data( $this->settings, 'author_image_size', 'full' ),
111 $image_id,
112 $c_image_size
113 );
114 }
115
116 return $img_html;
117 }
118 }
119