PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.3
ShopBuilder – WooCommerce Builder For Elementor v2.0.3
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.0.3, at app/Abstracts/AdditionalQueryCustomLayout.php

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