PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.0
ShopBuilder – WooCommerce Builder For Elementor v2.1.0
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 / Abstracts / AdditionalQueryCustomLayout.php

AdditionalQueryCustomLayout.php in ShopBuilder – WooCommerce Builder For Elementor 2.1.0, at app/Abstracts/AdditionalQueryCustomLayout.php

225 lines 5.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ProductsGrid class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Abstracts;
9
10 use RadiusTheme\SB\Helpers\Fns;
11 use RadiusTheme\SB\Elementor\Render\Render;
12 use RadiusTheme\SB\Elementor\Widgets\Controls;
13 use RadiusTheme\SB\Controllers\Hooks\FilterHooks;
14 use RadiusTheme\SB\Traits\ActionBtnTraits;
15
16 // Do not allow directly accessing this file.
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit( 'This script cannot be accessed directly.' );
20 }
21
22 /**
23 * ProductsGrid class.
24 */
25 abstract class AdditionalQueryCustomLayout extends ElementorWidgetBase {
26 /**
27 * Action Button Traits.
28 */
29 use ActionBtnTraits;
30
31 /**
32 * Construct function
33 *
34 * @param array $data default array.
35 * @param mixed $args default arg.
36 */
37 public function __construct( $data = [], $args = null ) {
38 $this->rtsb_base = $this->get_the_base();
39 parent::__construct( $data, $args );
40 $this->pro_tab = 'layout';
41 }
42 /**
43 * @return string
44 */
45 abstract protected function get_the_base();
46
47 /**
48 * Output the related products.
49 *
50 * @param array $args Provided arguments.
51 */
52 abstract public function get_the_products( $args = [] );
53
54 /**
55 * Widget Field
56 *
57 * @return array
58 */
59 public function widget_fields() {
60 return array_merge(
61 $this->layout_tab(),
62 $this->settings_tab(),
63 $this->style_tab()
64 );
65 }
66
67 /**
68 * Controls for layout tab
69 *
70 * @return array
71 */
72 protected function layout_tab() {
73 $fields = apply_filters(
74 'rtsb/elements/elementor/grid_layout_tab/' . $this->rtsb_base,
75 array_merge(
76 $this->widget_layout(),
77 $this->widget_query()
78 )
79 );
80
81 unset( $fields['grid_style'] );
82
83 return $fields;
84 }
85
86 /**
87 * Controls for settings tab
88 *
89 * @return array
90 */
91 protected function settings_tab() {
92 $content_visibility = Controls\SettingsFields::content_visibility( $this );
93
94 $extra_controls['show_section_title'] = [
95 'type' => 'switch',
96 'label' => esc_html__( 'Show Section Title?', 'shopbuilder' ),
97 'description' => esc_html__( 'Switch on to show product title.', 'shopbuilder' ),
98 'label_on' => esc_html__( 'On', 'shopbuilder' ),
99 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
100 'separator' => 'default',
101 ];
102
103 $content_visibility = Fns::insert_controls( 'show_title', $content_visibility, $extra_controls );
104
105 unset( $content_visibility['show_title']['separator'] );
106
107 $sections = array_merge(
108 $content_visibility,
109 Controls\SettingsFields::image( $this ),
110 Controls\SettingsFields::action_buttons( $this ),
111 Controls\SettingsFields::section_title( $this ),
112 Controls\SettingsFields::product_title( $this ),
113 Controls\SettingsFields::product_excerpt( $this ),
114 Controls\SettingsFields::badges( $this ),
115 $this->variation_swatch_conditionaly(),
116 Controls\SettingsFields::links( $this )
117 );
118 return apply_filters( 'rtsb/elements/elementor/product_custom_settings_tab', $sections, $this );
119 }
120 /**
121 * Controls for layout tab
122 *
123 * @return array
124 */
125 protected function widget_layout() {
126 return Controls\LayoutFields::grid_layout( $this );
127 }
128 public function variation_swatch_conditionaly() {
129 if ( ! function_exists( 'rtwpvsp' ) ) {
130 return [];
131 }
132 $swatches_controls = Controls\SettingsFields::variation_swatch( $this );
133 $swatches_controls['swatch_position']['condition'] = [
134 'layout' => [ 'grid-layout1' ],
135 ];
136 return $swatches_controls;
137 }
138 /**
139 * Controls for layout tab
140 *
141 * @return array
142 */
143 protected function widget_query() {
144 $additional_query = Controls\LayoutFields::additional_query( $this );
145 $additional_query['posts_limit']['separator'] = 'default';
146 return $additional_query;
147 }
148
149 protected function pagination_navigation() {
150 return Controls\StyleFields::pagination( $this );
151 }
152
153 /**
154 * Controls for style tab
155 *
156 * @return array
157 */
158 protected function style_tab() {
159 return apply_filters(
160 'rtsb/elementor/grid_style_tab',
161 array_merge(
162 Controls\StyleFields::color_scheme( $this ),
163 Controls\StyleFields::layout_design( $this ),
164 Controls\StyleFields::product_image( $this ),
165 Controls\StyleFields::section_title( $this ),
166 Controls\StyleFields::product_title( $this ),
167 Controls\StyleFields::short_description( $this ),
168 Controls\StyleFields::product_price( $this ),
169 Controls\StyleFields::product_categories( $this ),
170 Controls\StyleFields::product_rating( $this ),
171 Controls\StyleFields::product_add_to_cart( $this ),
172 Controls\StyleFields::product_wishlist( $this ),
173 Controls\StyleFields::product_quick_view( $this ),
174 Controls\StyleFields::product_compare( $this ),
175 Controls\StyleFields::product_badges( $this ),
176 $this->pagination_navigation(),
177 Controls\StyleFields::hover_icon_button( $this )
178 ),
179 $this
180 );
181 }
182
183 /**
184 * Widget Field
185 *
186 * @return void|array
187 */
188 protected function render_template_file() {
189 return 'elementor/general/grid/';
190 }
191 /**
192 * Render Function
193 *
194 * @return void
195 */
196 protected function render() {
197 $settings = $this->get_settings_for_display();
198
199 $this->action_button_icon_modify();
200
201 $this->render_start();
202 $args = [
203 'posts_per_page' => $settings['posts_limit'],
204 'columns' => $settings['posts_limit'],
205 'orderby' => $settings['posts_order_by'],
206 'order' => $settings['posts_order'],
207 ];
208
209 $settings['query_products'] = $this->get_the_products( $args );
210
211 if ( empty( $settings['query_products'] ) ) {
212 return;
213 }
214
215 if ( $this->is_builder_mode() ) {
216 add_filter( 'wp_kses_allowed_html', [ FilterHooks::class, 'custom_wpkses_post_tags' ], 10, 2 );
217 }
218
219 Fns::print_html( Render::instance()->setup_loop_for_product_view( $this->render_template_file(), $settings, $this ), true );
220
221 $this->action_button_icon_set_default();
222 $this->render_end();
223 }
224 }
225