PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.2.2
ShopBuilder – WooCommerce Builder For Elementor v2.2.2
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 / Single / ProductRating.php

ProductRating.php in ShopBuilder – WooCommerce Builder For Elementor 2.2.2, at app/Elementor/Widgets/Single/ProductRating.php

148 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main ProductDescription class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Elementor\Widgets\Single;
9
10 use Elementor\Controls_Manager;
11 use RadiusTheme\SB\Helpers\Fns;
12 use RadiusTheme\SB\Abstracts\ElementorWidgetBase;
13 use RadiusTheme\SB\Elementor\Helper\ControlHelper;
14 use RadiusTheme\SB\Elementor\Widgets\Controls\ReviewsStarSettings;
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 * Product Description class
23 */
24 class ProductRating extends ElementorWidgetBase {
25 /**
26 * Construct function
27 *
28 * @param array $data default array.
29 * @param mixed $args default arg.
30 */
31 public function __construct( $data = [], $args = null ) {
32 $this->rtsb_name = esc_html__( 'Product Rating', 'shopbuilder' );
33 $this->rtsb_base = 'rtsb-product-rating';
34 $this->pro_tab = 'style';
35 parent::__construct( $data, $args );
36 }
37 /**
38 * Widget Field
39 *
40 * @return array
41 */
42 public function widget_fields() {
43 $alignment = ControlHelper::alignment();
44 unset( $alignment['justify'] );
45 $fields = [
46 'sec_general' => [
47 'mode' => 'section_start',
48 'label' => esc_html__( 'General', 'shopbuilder' ),
49 'tab' => 'style',
50 ],
51 'rating_align' => [
52 'mode' => 'responsive',
53 'label' => esc_html__( 'Alignment', 'shopbuilder' ),
54 'type' => 'choose',
55 'options' => $alignment,
56 'separator' => 'default',
57 'selectors' => [
58 $this->selectors['rating_align'] => 'text-align: {{VALUE}};',
59 ],
60 ],
61 'rating_text_link_color' => [
62 'label' => esc_html__( 'Link Color', 'shopbuilder' ),
63 'type' => 'color',
64 'selectors' => [
65 $this->selectors['rating_text_link_color'] => 'color: {{VALUE}} !important;',
66 ],
67 ],
68 'rating_text_link_hover_color' => [
69 'label' => esc_html__( 'Link Hover Color', 'shopbuilder' ),
70 'type' => 'color',
71 'selectors' => [
72 $this->selectors['rating_text_link_hover_color'] => 'color: {{VALUE}} !important;',
73 ],
74 ],
75 'link_typography' => [
76 'mode' => 'group',
77 'type' => 'typography',
78 'label' => esc_html__( 'Link Typography', 'shopbuilder' ),
79 'selector' => $this->selectors['link_typography'],
80 ],
81 'rating_space_between' => [
82 'label' => esc_html__( 'Right Spacing (px)', 'shopbuilder' ),
83 'type' => 'slider',
84 'size_units' => [ 'px' ],
85 'range' => [
86 'px' => [
87 'min' => 0,
88 'max' => 100,
89 'step' => 1,
90 ],
91 ],
92 'default' => [
93 'unit' => 'px',
94 'size' => 5,
95 ],
96 'selectors' => [
97 $this->selectors['rating_space_between']['margin-right'] => 'margin-right: {{SIZE}}{{UNIT}} !important;',
98 $this->selectors['rating_space_between']['margin-left'] => 'margin-left: {{SIZE}}{{UNIT}} !important;',
99 ],
100 ],
101 'sec_general_end' => [
102 'mode' => 'section_end',
103 ],
104 ];
105 return array_merge( $fields, ReviewsStarSettings::widget_fields( $this ) );
106
107 }
108
109 /**
110 * Render Function
111 *
112 * @return void
113 */
114 protected function render() {
115 global $post, $product;
116 $_product = $product;
117 $_post = $post;
118 $controllers = $this->get_settings_for_display();
119 $this->theme_support();
120 $product = Fns::get_product();
121
122 if ( $this->is_builder_mode() ) {
123 // Overriding Global.
124 $post = get_post( Fns::get_prepared_product_id() ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
125 }
126
127 ob_start();
128 woocommerce_template_single_rating();
129 $rating_html = ob_get_clean();
130
131 if ( empty( $rating_html ) && $this->is_builder_mode() ) {
132 $rating_html = $this->rtsb_name;
133 }
134
135 $data = [
136 'template' => 'elementor/single-product/rating',
137 'controllers' => $controllers,
138 'content' => $rating_html,
139 ];
140
141 Fns::load_template( $data['template'], $data );
142 $this->theme_support( 'render_reset' );
143 $product = $_product; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
144 $post = $_post;
145 }
146
147 }
148