PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 1.1.2
ShopBuilder – WooCommerce Builder For Elementor v1.1.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
← All changes | app/Abstracts/AdditionalQueryCustomLayout.php +229 -226 2.1.71.1.2 View file →
@@ -1,226 +1,229 @@
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::content_ordering( $this ),
110 - Controls\SettingsFields::image( $this ),
111 - Controls\SettingsFields::action_buttons( $this ),
112 - Controls\SettingsFields::section_title( $this ),
113 - Controls\SettingsFields::product_title( $this ),
114 - Controls\SettingsFields::product_excerpt( $this ),
115 - Controls\SettingsFields::badges( $this ),
116 - $this->variation_swatch_conditionaly(),
117 - Controls\SettingsFields::links( $this )
118 - );
119 - return apply_filters( 'rtsb/elements/elementor/product_custom_settings_tab', $sections, $this );
120 - }
121 - /**
122 - * Controls for layout tab
123 - *
124 - * @return array
125 - */
126 - protected function widget_layout() {
127 - return Controls\LayoutFields::grid_layout( $this );
128 - }
129 - public function variation_swatch_conditionaly() {
130 - if ( ! function_exists( 'rtwpvsp' ) ) {
131 - return [];
132 - }
133 - $swatches_controls = Controls\SettingsFields::variation_swatch( $this );
134 - $swatches_controls['swatch_position']['condition'] = [
135 - 'layout' => [ 'grid-layout1' ],
136 - ];
137 - return $swatches_controls;
138 - }
139 - /**
140 - * Controls for layout tab
141 - *
142 - * @return array
143 - */
144 - protected function widget_query() {
145 - $additional_query = Controls\LayoutFields::additional_query( $this );
146 - $additional_query['posts_limit']['separator'] = 'default';
147 - return $additional_query;
148 - }
149 -
150 - protected function pagination_navigation() {
151 - return Controls\StyleFields::pagination( $this );
152 - }
153 -
154 - /**
155 - * Controls for style tab
156 - *
157 - * @return array
158 - */
159 - protected function style_tab() {
160 - return apply_filters(
161 - 'rtsb/elementor/grid_style_tab',
162 - array_merge(
163 - Controls\StyleFields::color_scheme( $this ),
164 - Controls\StyleFields::layout_design( $this ),
165 - Controls\StyleFields::product_image( $this ),
166 - Controls\StyleFields::section_title( $this ),
167 - Controls\StyleFields::product_title( $this ),
168 - Controls\StyleFields::short_description( $this ),
169 - Controls\StyleFields::product_price( $this ),
170 - Controls\StyleFields::product_categories( $this ),
171 - Controls\StyleFields::product_rating( $this ),
172 - Controls\StyleFields::product_add_to_cart( $this ),
173 - Controls\StyleFields::product_wishlist( $this ),
174 - Controls\StyleFields::product_quick_view( $this ),
175 - Controls\StyleFields::product_compare( $this ),
176 - Controls\StyleFields::product_badges( $this ),
177 - $this->pagination_navigation(),
178 - Controls\StyleFields::hover_icon_button( $this )
179 - ),
180 - $this
181 - );
182 - }
183 -
184 - /**
185 - * Widget Field
186 - *
187 - * @return void|array
188 - */
189 - protected function render_template_file() {
190 - return 'elementor/general/grid/';
191 - }
192 - /**
193 - * Render Function
194 - *
195 - * @return void
196 - */
197 - protected function render() {
198 - $settings = $this->get_settings_for_display();
199 -
200 - $this->action_button_icon_modify();
201 -
202 - $this->render_start();
203 - $args = [
204 - 'posts_per_page' => $settings['posts_limit'],
205 - 'columns' => $settings['posts_limit'],
206 - 'orderby' => $settings['posts_order_by'],
207 - 'order' => $settings['posts_order'],
208 - ];
209 -
210 - $settings['query_products'] = $this->get_the_products( $args );
211 -
212 - if ( empty( $settings['query_products'] ) ) {
213 - return;
214 - }
215 -
216 - if ( $this->is_builder_mode() ) {
217 - add_filter( 'wp_kses_allowed_html', [ FilterHooks::class, 'custom_wpkses_post_tags' ], 10, 2 );
218 - }
219 -
220 - // Call the template rendering method.
221 - Fns::print_html( Render::instance()->setup_loop_for_product_view( $this->render_template_file(), $settings, $this ), true );
222 -
223 - $this->action_button_icon_set_default();
224 - $this->render_end();
225 - }
226 -}
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 + return apply_filters(
79 + 'rtsb/elements/elementor/grid_layout_tab/' . $this->rtsb_base,
80 + array_merge(
81 + $this->widget_layout(),
82 + $this->widget_columns(),
83 + $this->widget_query(),
84 + $this->image(),
85 + )
86 + );
87 + }
88 +
89 + /**
90 + * Controls for settings tab
91 + *
92 + * @return array
93 + */
94 + protected function settings_tab() {
95 + $content_visibility = Controls\SettingsFields::content_visibility( $this );
96 +
97 + $extra_controls['show_section_title'] = [
98 + 'type' => 'switch',
99 + 'label' => esc_html__( 'Show Section Title?', 'shopbuilder' ),
100 + 'description' => esc_html__( 'Switch on to show product title.', 'shopbuilder' ),
101 + 'label_on' => esc_html__( 'On', 'shopbuilder' ),
102 + 'label_off' => esc_html__( 'Off', 'shopbuilder' ),
103 + 'separator' => 'default',
104 + ];
105 +
106 + $content_visibility = Fns::insert_controls( 'show_title', $content_visibility, $extra_controls );
107 +
108 + unset( $content_visibility['show_title']['separator'] );
109 +
110 + return apply_filters(
111 + 'rtsb/elements/elementor/grid_settings_tab/' . $this->rtsb_base,
112 + array_merge(
113 + $content_visibility,
114 + Controls\SettingsFields::section_title( $this ),
115 + Controls\SettingsFields::product_title( $this ),
116 + Controls\SettingsFields::product_excerpt( $this ),
117 + Controls\SettingsFields::action_buttons( $this ),
118 + Controls\SettingsFields::add_to_cart( $this ),
119 + Controls\SettingsFields::quick_view( $this ),
120 + Controls\SettingsFields::compare( $this ),
121 + Controls\SettingsFields::wishlist( $this ),
122 + Controls\SettingsFields::badges( $this ),
123 + Controls\SettingsFields::links( $this )
124 + )
125 + );
126 + }
127 + /**
128 + * Controls for layout tab
129 + *
130 + * @return array
131 + */
132 + protected function widget_layout() {
133 + return Controls\LayoutFields::grid_layout( $this );
134 + }
135 + /**
136 + * Controls for layout tab
137 + *
138 + * @return array
139 + */
140 + protected function widget_query() {
141 + $additional_query = Controls\LayoutFields::additional_query( $this );
142 + $additional_query['posts_limit']['separator'] = 'default';
143 + return $additional_query;
144 + }
145 + protected function widget_columns() {
146 + $columns = Controls\LayoutFields::columns( $this );
147 + unset( $columns['grid_style'] );
148 + return $columns;
149 + }
150 + protected function image() {
151 + return Controls\LayoutFields::image( $this );
152 + }
153 +
154 + protected function pagination_navigation() {
155 + return Controls\StyleFields::pagination( $this );
156 + }
157 +
158 + /**
159 + * Controls for style tab
160 + *
161 + * @return $this
162 + */
163 + protected function style_tab() {
164 + return apply_filters(
165 + 'rtsb/elements/elementor/grid_style_tab/' . $this->rtsb_base,
166 + array_merge(
167 + Controls\StyleFields::color_scheme( $this ),
168 + Controls\StyleFields::section_title( $this ),
169 + Controls\StyleFields::product_title( $this ),
170 + Controls\StyleFields::short_description( $this ),
171 + Controls\StyleFields::product_price( $this ),
172 + Controls\StyleFields::product_rating( $this ),
173 + Controls\StyleFields::product_badges( $this ),
174 + Controls\StyleFields::product_categories( $this ),
175 + Controls\StyleFields::product_image( $this ),
176 + Controls\StyleFields::product_add_to_cart( $this ),
177 + $this->pagination_navigation(),
178 + Controls\StyleFields::product_compare( $this ),
179 + Controls\StyleFields::product_quick_view( $this ),
180 + Controls\StyleFields::product_wishlist( $this ),
181 + Controls\StyleFields::hover_icon_button( $this ),
182 + Controls\StyleFields::advanced( $this ),
183 + )
184 + );
185 + }
186 +
187 + /**
188 + * Widget Field
189 + *
190 + * @return void|array
191 + */
192 + protected function render_template_file() {
193 + return 'elementor/general/grid/';
194 + }
195 + /**
196 + * Render Function
197 + *
198 + * @return void
199 + */
200 + protected function render() {
201 + $settings = $this->get_settings_for_display();
202 +
203 + $this->action_button_icon_modify();
204 +
205 + $this->theme_support();
206 + $args = [
207 + 'posts_per_page' => $settings['posts_limit'],
208 + 'columns' => $settings['posts_limit'],
209 + 'orderby' => $settings['posts_order_by'], // @codingStandardsIgnoreLine.
210 + 'order' => $settings['posts_order'],
211 + ];
212 +
213 + $settings['query_products'] = $this->get_the_products( $args );
214 +
215 + if ( empty( $settings['query_products'] ) ) {
216 + return;
217 + }
218 +
219 + if ( $this->is_builder_mode() ) {
220 + add_filter( 'wp_kses_allowed_html', [ FilterHooks::class, 'custom_wpkses_post_tags' ], 10, 2 );
221 + }
222 +
223 + Fns::print_html( Render::instance()->setup_loop_for_product_view( $this->render_template_file(), $settings ), true );
224 + $this->edit_mode_script();
225 + $this->action_button_icon_set_default();
226 + $this->theme_support( 'render_reset' );
227 + }
228 +
229 +}