PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.13
ShopBuilder – WooCommerce Builder For Elementor v2.1.13
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/Elementor/Helper/RenderHelpers.php +380 -194 2.0.12.1.13 View file →
@@ -20,11 +20,27 @@
20 20 /**
21 21 * BuilderFns class
22 22 */
23 23 class RenderHelpers {
24 + /**
25 + * Get data.
26 + *
27 + * @param array|string $haystack The array or string to search for the value.
28 + * @param string $needle The key to look for in the array or the string itself.
29 + * @param mixed $default The default value to return if the key is not.
30 + *
31 + * @return mixed
32 + */
33 + public static function get_data( $haystack, $needle, $default = null ) {
34 + if ( is_array( $haystack ) && ! empty( $haystack[ $needle ] ) ) {
35 + return $haystack[ $needle ];
36 + } elseif ( is_string( $haystack ) && ! empty( $haystack ) ) {
37 + return $haystack;
38 + } else {
39 + return $default;
40 + }
41 + }
24 42
25 -
26 -
27 43 /**
28 44 * Builds an array with field values.
29 45 *
30 46 * @param array $meta Field values.
@@ -33,15 +49,15 @@
33 49 *
34 50 * @return array
35 51 */
36 52 public static function meta_dataset( array $meta, $template = '', $raw_settings = [] ) {
37 - $c_image_size = ! empty( $meta['image_custom_dimension'] ) ? $meta['image_custom_dimension'] : [];
38 - $c_image_size['crop'] = ! empty( $meta['image_crop'] ) ? $meta['image_crop'] : '';
53 + $c_image_size = self::get_data( $meta, 'image_custom_dimension', [] );
54 + $c_image_size['crop'] = self::get_data( $meta, 'image_crop', [] );
39 55
40 - if ( ( ! empty( $_GET['displayview'] ) && 'list' === $_GET['displayview'] ) || ( empty( $_GET['displayview'] ) && ( ! empty( $meta['view_mode'] ) && 'list' === $meta['view_mode'] ) ) ) {
41 - $meta['cols'] = ! empty( $meta['list_cols'] ) ? $meta['list_cols'] : 1;
42 - $meta['cols_tablet'] = ! empty( $meta['list_cols_tablet'] ) ? $meta['list_cols_tablet'] : $meta['cols'];
43 - $meta['cols_mobile'] = ! empty( $meta['list_cols_mobile'] ) ? $meta['list_cols_mobile'] : $meta['cols'];
56 + if ( ( ! empty( $_GET['displayview'] ) && 'list' === $_GET['displayview'] ) || ( empty( $_GET['displayview'] ) && ( ! empty( $meta['view_mode'] ) && 'list' === $meta['view_mode'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
57 + $meta['cols'] = self::get_data( $meta, 'list_cols', 1 );
58 + $meta['cols_tablet'] = self::get_data( $meta, 'list_cols_tablet', $meta['cols'] );
59 + $meta['cols_mobile'] = self::get_data( $meta, 'list_cols_mobile', $meta['cols'] );
44 60 }
45 61
46 62 $data = apply_filters(
47 63 'rtsb/elementor/render/meta_dataset',
@@ -47,51 +63,53 @@
47 63 'rtsb/elementor/render/meta_dataset',
48 64 [
49 65 // Layout.
50 66 'widget' => 'custom',
51 - 'template' => ! empty( $template ) ? $template : '',
52 - 'raw_settings' => ! empty( $raw_settings ) ? $raw_settings : [],
53 - 'layout' => ! empty( $meta['layout'] ) ? $meta['layout'] : 'layout1',
54 - 'd_cols' => ! empty( $meta['cols'] ) ? $meta['cols'] : 0,
55 - 't_cols' => ! empty( $meta['cols_tablet'] ) ? $meta['cols_tablet'] : 2,
56 - 'm_cols' => ! empty( $meta['cols_mobile'] ) ? $meta['cols_mobile'] : 1,
57 - 'grid_type' => ! empty( $meta['grid_style'] ) ? $meta['grid_style'] : 'even',
67 + 'template' => self::get_data( $template, '', '' ),
68 + 'raw_settings' => $raw_settings,
69 + 'layout' => self::get_data( $meta, 'layout', 'layout1' ),
70 + 'grid_layout' => self::get_data( $raw_settings, 'layout', 'grid-layout1' ),
71 + 'list_layout' => self::get_data( $raw_settings, 'list_layout', 'list-layout1' ),
72 + 'd_cols' => self::get_data( $meta, 'cols', 0 ),
73 + 't_cols' => self::get_data( $meta, 'cols_tablet', 2 ),
74 + 'm_cols' => self::get_data( $meta, 'cols_mobile', 1 ),
75 + 'grid_type' => self::get_data( $meta, 'grid_style', 'even' ),
58 76
59 77 // Query.
60 - 'post_in' => ! empty( $meta['include_posts'] ) && is_array( $meta['include_posts'] ) ? $meta['include_posts'] : [],
61 - 'post_not_in' => ! empty( $meta['exclude_posts'] ) && is_array( $meta['exclude_posts'] ) ? $meta['exclude_posts'] : [],
78 + 'post_in' => self::get_data( $meta, 'include_posts', [] ),
79 + 'post_not_in' => self::get_data( $meta, 'exclude_posts', [] ),
62 80 'limit' => ( empty( $meta['posts_limit'] ) || '-1' === $meta['posts_limit'] ) ? 10000000 : $meta['posts_limit'],
63 - 'offset' => ! empty( $meta['posts_offset'] ) ? $meta['posts_offset'] : 0,
64 - 'order_by' => ! empty( $meta['posts_order_by'] ) ? $meta['posts_order_by'] : 'date',
65 - 'order' => ! empty( $meta['posts_order'] ) ? $meta['posts_order'] : 'DESC',
66 - 'author_in' => ! empty( $meta['filter_author'] ) && is_array( $meta['filter_author'] ) ? $meta['filter_author'] : [],
67 - 'display_by' => ! empty( $meta['products_filter'] ) ? $meta['products_filter'] : 'date',
68 - 'categories' => ! empty( $meta['filter_categories'] ) && is_array( $meta['filter_categories'] ) ? $meta['filter_categories'] : [],
69 - 'tags' => ! empty( $meta['filter_tags'] ) && is_array( $meta['filter_tags'] ) ? $meta['filter_tags'] : [],
70 - 'attributes' => ! empty( $meta['filter_attributes'] ) && is_array( $meta['filter_attributes'] ) ? $meta['filter_attributes'] : [],
71 - 'relation' => ! empty( $meta['tax_relation'] ) ? $meta['tax_relation'] : 'OR',
72 - 'category_source' => ! empty( $meta['select_source'] ) ? $meta['select_source'] : 'product_cat',
73 - 'category_term' => ! empty( $meta['select_cat'] ) ? $meta['select_cat'] : null,
74 - 'display_cat_by' => ! empty( $meta['display_cat_by'] ) ? $meta['display_cat_by'] : null,
75 - 'include_cats' => ! empty( $meta['include_cats'] ) && is_array( $meta['include_cats'] ) ? $meta['include_cats'] : [],
76 - 'exclude_cats' => ! empty( $meta['exclude_cats'] ) && is_array( $meta['exclude_cats'] ) ? $meta['exclude_cats'] : [],
77 - 'select_parent_cat' => ! empty( $meta['select_parent_cat'] ) ? $meta['select_parent_cat'] : null,
78 - 'select_cats' => ! empty( $meta['select_cats'] ) && is_array( $meta['select_cats'] ) ? $meta['select_cats'] : [],
79 - 'select_cat_ids' => ! empty( $meta['include_cat_ids'] ) ? $meta['include_cat_ids'] : '',
81 + 'offset' => self::get_data( $meta, 'posts_offset', 0 ),
82 + 'order_by' => self::get_data( $meta, 'posts_order_by', 'date' ),
83 + 'order' => self::get_data( $meta, 'posts_order', 'DESC' ),
84 + 'author_in' => self::get_data( $meta, 'filter_author', [] ),
85 + 'display_by' => self::get_data( $meta, 'products_filter', 'date' ),
86 + 'categories' => self::get_data( $meta, 'filter_categories', [] ),
87 + 'tags' => self::get_data( $meta, 'filter_tags', [] ),
88 + 'attributes' => self::get_data( $meta, 'filter_attributes', [] ),
89 + 'relation' => self::get_data( $meta, 'tax_relation', 'OR' ),
90 + 'category_source' => self::get_data( $meta, 'select_source', 'product_cat' ),
91 + 'category_term' => self::get_data( $meta, 'select_cat' ),
92 + 'display_cat_by' => self::get_data( $meta, 'display_cat_by' ),
93 + 'include_cats' => self::get_data( $meta, 'include_cats', [] ),
94 + 'exclude_cats' => self::get_data( $meta, 'exclude_cats', [] ),
95 + 'select_parent_cat' => self::get_data( $meta, 'select_parent_cat' ),
96 + 'select_cats' => self::get_data( $meta, 'select_cats', [] ),
97 + 'select_cat_ids' => self::get_data( $meta, 'include_cat_ids', '' ),
80 98 'cats_limit' => ( empty( $meta['cats_limit'] ) || '-1' === $meta['cats_limit'] ) ? 10000000 : $meta['cats_limit'],
81 99 'show_empty' => ! empty( $meta['show_empty'] ),
82 100 'show_uncategorized' => ! empty( $meta['show_uncategorized'] ),
83 101 'show_subcats' => ! empty( $meta['show_subcats'] ),
84 102 'show_top_level_cats' => ! empty( $meta['show_top_level_cats'] ),
85 - 'cats_order_by' => ! empty( $meta['cats_order_by'] ) ? $meta['cats_order_by'] : 'name',
86 - 'cats_order' => ! empty( $meta['cats_order'] ) ? $meta['cats_order'] : 'DESC',
87 - 'rtsb_order' => ! empty( $meta['rtsb_order'] ) ? $meta['rtsb_order'] : 'ASC',
88 - 'rtsb_orderby' => ! empty( $meta['rtsb_orderby'] ) ? $meta['rtsb_orderby'] : 'menu_order',
103 + 'cats_order_by' => self::get_data( $meta, 'cats_order_by', 'name' ),
104 + 'cats_order' => self::get_data( $meta, 'cats_order', 'DESC' ),
105 + 'rtsb_order' => self::get_data( $meta, 'rtsb_order', 'ASC' ),
106 + 'rtsb_orderby' => self::get_data( $meta, 'rtsb_orderby', 'menu_order' ),
89 107
90 108 // Pagination.
91 109 'pagination' => ! empty( $meta['show_pagination'] ),
92 - 'posts_loading_type' => ! empty( $meta['pagination_type'] ) ? $meta['pagination_type'] : 'pagination',
93 - 'posts_per_page' => ! empty( $meta['pagination_per_page'] ) ? $meta['pagination_per_page'] : '',
110 + 'posts_loading_type' => self::get_data( $meta, 'pagination_type', 'pagination' ),
111 + 'posts_per_page' => self::get_data( $meta, 'pagination_per_page', '' ),
94 112
95 113 // Image.
96 114 'f_img' => ! empty( $meta['show_featured_image'] ),
97 115 'gallery_img' => ! empty( $meta['show_product_gallery'] ),
@@ -96,13 +114,13 @@
96 114 'f_img' => ! empty( $meta['show_featured_image'] ),
97 115 'gallery_img' => ! empty( $meta['show_product_gallery'] ),
98 116 'c_img' => ! empty( $meta['show_cat_image'] ),
99 117 'hover_img' => ! empty( $meta['show_hover_image'] ),
100 - 'f_img_size' => ! empty( $meta['image'] ) ? $meta['image'] : 'medium',
118 + 'f_img_size' => self::get_data( $meta, 'image', 'medium' ),
101 119 'custom_img_size' => ! empty( $c_image_size ) && is_array( $c_image_size ) ? $c_image_size : [],
102 120 'default_img_id' => ! empty( $meta['default_preview_image']['id'] ) ? $meta['default_preview_image']['id'] : null,
103 121 'show_overlay' => ! empty( $meta['show_overlay'] ),
104 - 'hover_animation' => ! empty( $meta['image_hover_animation'] ) ? $meta['image_hover_animation'] : 'none',
122 + 'hover_animation' => self::get_data( $meta, 'image_hover_animation', 'none' ),
105 123 'show_custom_image' => ! empty( $meta['show_custom_image'] ),
106 124 'custom_image' => ! empty( $meta['custom_image']['id'] ) ? $meta['custom_image']['id'] : null,
107 125
108 126 // Visibility.
@@ -108,90 +126,96 @@
108 126 // Visibility.
109 127 'visibility' => ! empty( self::content_visibility( $meta ) ) ? self::content_visibility( $meta ) : [],
110 128
111 129 // Action Buttons.
112 - 'btn_preset' => ! empty( $meta['action_btn_preset'] ) ? $meta['action_btn_preset'] : 'preset1',
113 - 'btn_position' => ! empty( $meta['action_btn_position'] ) ? $meta['action_btn_position'] : 'above',
114 - 'tooltip_position' => ! empty( $meta['action_btn_tooltip_position'] ) ? $meta['action_btn_tooltip_position'] : 'top',
130 + 'btn_preset' => self::get_data( $meta, 'action_btn_preset', 'preset1' ),
131 + 'btn_position' => self::get_data( $meta, 'action_btn_position', 'above' ),
132 + 'tooltip_position' => self::get_data( $meta, 'action_btn_tooltip_position', 'top' ),
115 133
116 134 // Product Title.
117 - 'title_tag' => ! empty( $meta['title_tag'] ) ? $meta['title_tag'] : 'h3',
135 + 'title_tag' => self::get_data( $meta, 'title_tag', 'h3' ),
118 136 'title_hover' => ! empty( $meta['title_hover'] ),
119 - 'title_limit' => ! empty( $meta['title_limit'] ) ? $meta['title_limit'] : 'default',
120 - 'title_limit_custom' => ! empty( $meta['title_limit_custom'] ) ? $meta['title_limit_custom'] : null,
137 + 'title_limit' => self::get_data( $meta, 'title_limit', 'default' ),
138 + 'title_limit_custom' => self::get_data( $meta, 'title_limit_custom' ),
121 139 'show_custom_title' => ! empty( $meta['show_custom_title'] ),
122 - 'cat_custom_title' => ! empty( $meta['custom_title'] ) ? $meta['custom_title'] : '',
140 + 'cat_custom_title' => self::get_data( $meta, 'custom_title', '' ),
123 141
124 142 // Variation Swatches.
125 - 'swatch_position' => ! empty( $meta['swatch_position'] ) ? $meta['swatch_position'] : 'top',
126 - 'swatch_type' => ! empty( $meta['swatch_type'] ) ? $meta['swatch_type'] : 'circle',
143 + 'swatch_position' => self::get_data( $meta, 'swatch_position', 'top' ),
144 + 'swatch_type' => self::get_data( $meta, 'swatch_type', 'circle' ),
127 145
128 146 // Short Description.
129 147 'show_custom_excerpt' => ! empty( $meta['show_custom_description'] ),
130 - 'cat_custom_excerpt' => ! empty( $meta['custom_description'] ) ? $meta['custom_description'] : '',
131 - 'cat_excerpt_position' => ! empty( $meta['excerpt_position'] ) ? $meta['excerpt_position'] : 'below',
132 - 'excerpt_limit' => ! empty( $meta['excerpt_limit'] ) ? $meta['excerpt_limit'] : 'default',
133 - 'excerpt_limit_custom' => ! empty( $meta['excerpt_limit_custom'] ) ? $meta['excerpt_limit_custom'] : 200,
148 + 'cat_custom_excerpt' => self::get_data( $meta, 'custom_description', '' ),
149 + 'cat_excerpt_position' => self::get_data( $meta, 'excerpt_position', 'below' ),
150 + 'excerpt_limit' => self::get_data( $meta, 'excerpt_limit', 'default' ),
151 + 'excerpt_limit_custom' => self::get_data( $meta, 'excerpt_limit_custom', 200 ),
134 152
135 153 // Count.
136 - 'count_position' => ! empty( $meta['count_display_type'] ) ? $meta['count_display_type'] : 'flex',
137 - 'before_count' => ! empty( $meta['before_count'] ) ? $meta['before_count'] : '',
138 - 'after_count' => ! empty( $meta['after_count'] ) ? $meta['after_count'] : '',
154 + 'count_position' => self::get_data( $meta, 'count_display_type', 'flex' ),
155 + 'before_count' => self::get_data( $meta, 'before_count', '' ),
156 + 'after_count' => self::get_data( $meta, 'after_count', '' ),
139 157
140 158 // Add to cart.
141 159 'show_cart_icon' => ! empty( $meta['show_cart_icon'] ),
142 160 'show_cart_text' => ! empty( $meta['show_cart_text'] ),
143 - 'add_to_cart_icon' => ! empty( $meta['add_to_cart_icon'] ) ? $meta['add_to_cart_icon'] : [],
144 - 'add_to_cart_success_icon' => ! empty( $meta['add_to_cart_success_icon'] ) ? $meta['add_to_cart_success_icon'] : [],
145 - 'add_to_cart_text' => ! empty( $meta['add_to_cart_text'] ) ? $meta['add_to_cart_text'] : esc_html__( 'Add to Cart', 'shopbuilder' ),
146 - 'add_to_cart_success_text' => ! empty( $meta['add_to_cart_success_text'] ) ? $meta['add_to_cart_success_text'] : '',
147 - 'add_to_cart_alignment' => ! empty( $meta['cart_icon_alignment'] ) ? $meta['cart_icon_alignment'] : 'left',
161 + 'add_to_cart_icon' => self::get_data( $meta, 'add_to_cart_icon', [] ),
162 + 'add_to_cart_success_icon' => self::get_data( $meta, 'add_to_cart_success_icon', [] ),
163 + 'add_to_cart_text' => self::get_data( $meta, 'add_to_cart_text', esc_html__( 'Add to Cart', 'shopbuilder' ) ),
164 + 'add_to_cart_success_text' => self::get_data( $meta, 'add_to_cart_success_text', '' ),
165 + 'add_to_cart_alignment' => self::get_data( $meta, 'cart_icon_alignment', 'left' ),
148 166
149 167 // Action Button Icons.
150 - 'quick_view_icon' => ! empty( $meta['quick_view_icon'] ) ? $meta['quick_view_icon'] : [],
151 - 'comparison_icon' => ! empty( $meta['comparison_icon'] ) ? $meta['comparison_icon'] : [],
152 - 'comparison_icon_added' => ! empty( $meta['comparison_icon_added'] ) ? $meta['comparison_icon_added'] : [],
153 - 'wishlist_icon' => ! empty( $meta['wishlist_icon'] ) ? $meta['wishlist_icon'] : [],
154 - 'wishlist_icon_added' => ! empty( $meta['wishlist_icon_added'] ) ? $meta['wishlist_icon_added'] : [],
168 + 'quick_view_icon' => self::get_data( $meta, 'quick_view_icon', [] ),
169 + 'comparison_icon' => self::get_data( $meta, 'comparison_icon', [] ),
170 + 'comparison_icon_added' => self::get_data( $meta, 'comparison_icon_added', [] ),
171 + 'wishlist_icon' => self::get_data( $meta, 'wishlist_icon', [] ),
172 + 'wishlist_icon_added' => self::get_data( $meta, 'wishlist_icon_added', [] ),
155 173
156 174 // Badges.
157 - 'sale_badge_type' => ! empty( $meta['sale_badges_type'] ) ? $meta['sale_badges_type'] : 'percentage',
158 - 'sale_badge_text' => ! empty( $meta['sale_badges_text'] ) ? $meta['sale_badges_text'] : esc_html__( 'Sale', 'shopbuilder' ),
159 - 'custom_badge_text' => ! empty( $meta['custom_badge_text'] ) ? $meta['custom_badge_text'] : esc_html__( 'Sale', 'shopbuilder' ),
160 - 'out_of_stock_badge_text' => ! empty( $meta['stock_badges_text'] ) ? $meta['stock_badges_text'] : esc_html__( 'Out of Stock', 'shopbuilder' ),
161 - 'badge_position' => ! empty( $meta['badges_position'] ) ? $meta['badges_position'] : 'top',
162 - 'badge_alignment' => ! empty( $meta['badges_alignment'] ) ? $meta['badges_alignment'] : 'left',
163 - 'badge_preset' => ! empty( $meta['custom_badge_preset'] ) ? $meta['custom_badge_preset'] : 'preset-1',
175 + 'sale_badge_type' => self::get_data( $meta, 'sale_badges_type', 'percentage' ),
176 + 'sale_badge_text' => self::get_data( $meta, 'sale_badges_text', esc_html__( 'Sale', 'shopbuilder' ) ),
177 + 'custom_badge_text' => self::get_data( $meta, 'custom_badge_text', esc_html__( 'Sale', 'shopbuilder' ) ),
178 + 'out_of_stock_badge_text' => self::get_data( $meta, 'stock_badges_text', esc_html__( 'Out of Stock', 'shopbuilder' ) ),
179 + 'badge_position' => self::get_data( $meta, 'badges_position', 'top' ),
180 + 'badge_alignment' => self::get_data( $meta, 'badges_alignment', 'left' ),
181 + 'badge_preset' => self::get_data( $meta, 'custom_badge_preset', 'preset-1' ),
182 + 'enable_badges_module' => self::get_data( $meta, 'enable_badges_module', '' ),
164 183
165 184 // Link.
166 185 'image_link' => ! empty( $meta['image_link'] ),
167 186 'title_link' => ! empty( $meta['title_link'] ),
168 - 'hover_btn_text' => ! empty( $meta['hover_btn_text'] ) ? $meta['hover_btn_text'] : esc_html__( 'See Details', 'shopbuilder' ),
187 + 'hover_btn_text' => self::get_data( $meta, 'hover_btn_text', esc_html__( 'See Details', 'shopbuilder' ) ),
169 188 'show_hover_btn_icon' => ! empty( $meta['show_hover_btn_icon'] ),
170 - 'hover_btn_icon' => ! empty( $meta['hover_btn_icon'] ) ? $meta['hover_btn_icon'] : [],
171 - 'custom_link' => ! empty( $meta['custom_link'] ) ? $meta['custom_link'] : null,
189 + 'hover_btn_icon' => self::get_data( $meta, 'hover_btn_icon', [] ),
190 + 'custom_link' => self::get_data( $meta, 'custom_link' ),
172 191
173 192 // Slider.
174 - 'd_group' => ! empty( $meta['cols_group'] ) ? $meta['cols_group'] : 1,
175 - 't_group' => ! empty( $meta['cols_group_tablet'] ) ? $meta['cols_group_tablet'] : 1,
176 - 'm_group' => ! empty( $meta['cols_group_mobile'] ) ? $meta['cols_group_mobile'] : 1,
193 + 'd_group' => self::get_data( $meta, 'cols_group', 1 ),
194 + 't_group' => self::get_data( $meta, 'cols_group_tablet', 1 ),
195 + 'm_group' => self::get_data( $meta, 'cols_group_mobile', 1 ),
177 196 'auto_play' => ! empty( $meta['slide_autoplay'] ),
178 197 'stop_on_hover' => ! empty( $meta['pause_hover'] ),
179 198 'slider_nav' => ! empty( $meta['slider_nav'] ),
180 199 'slider_dot' => ! empty( $meta['slider_pagi'] ),
200 + 'slider_dynamic_dot' => ! empty( $meta['slider_dynamic_pagi'] ),
181 201 'loop' => ! empty( $meta['slider_loop'] ),
182 202 'lazy_load' => ! empty( $meta['slider_lazy_load'] ),
183 203 'auto_height' => ! empty( $meta['slider_auto_height'] ),
184 - 'speed' => ! empty( $meta['slide_speed'] ) ? $meta['slide_speed'] : 2000,
204 + 'speed' => self::get_data( $meta, 'slide_speed', 2000 ),
185 205 'space_between' => isset( $meta['grid_gap']['size'] ) && strlen( $meta['grid_gap']['size'] ) ? $meta['grid_gap']['size'] : 30,
186 - 'auto_play_timeout' => ! empty( $meta['autoplay_timeout'] ) ? $meta['autoplay_timeout'] : 5000,
187 - 'nav_position' => ! empty( $meta['slider_nav_position'] ) ? $meta['slider_nav_position'] : 'top',
188 - 'left_arrow_icon' => ! empty( $meta['slider_left_arrow_icon'] ) ? $meta['slider_left_arrow_icon'] : [],
189 - 'right_arrow_icon' => ! empty( $meta['slider_right_arrow_icon'] ) ? $meta['slider_right_arrow_icon'] : [],
206 + 'auto_play_timeout' => self::get_data( $meta, 'autoplay_timeout', 5000 ),
207 + 'nav_position' => self::get_data( $meta, 'slider_nav_position', 'top' ),
208 + 'left_arrow_icon' => self::get_data( $meta, 'slider_left_arrow_icon', [] ),
209 + 'right_arrow_icon' => self::get_data( $meta, 'slider_right_arrow_icon', [] ),
190 210 ],
191 211 $meta
192 212 );
193 213
214 + if ( ! empty( $meta['active_cat_slider'] ) ) {
215 + $data['active_cat_slider'] = true;
216 + }
217 +
194 218 if ( ! empty( $meta['cols_widescreen'] ) ) {
195 219 $data['w_cols'] = $meta['cols_widescreen'];
196 220 }
197 221
@@ -209,11 +233,11 @@
209 233
210 234 $queried_obj = get_queried_object();
211 235
212 236 if ( is_shop() || is_product_taxonomy() ) {
213 - $data['posts_per_page'] = wc_get_default_products_per_row() * wc_get_default_product_rows_per_page();
214 - $data['order_by'] = ! empty( $data['rtsb_orderby'] ) ? esc_html( $data['rtsb_orderby'] ) : $data['orderby'];
215 - $data['order'] = ! empty( $data['rtsb_order'] ) ? esc_html( $data['rtsb_order'] ) : $data['order'];
237 + $data['posts_per_page'] = self::get_products_per_page();
238 + $data['order_by'] = self::get_data( $data, 'rtsb_orderby', $data['order_by'] );
239 + $data['order'] = self::get_data( $data, 'rtsb_order', $data['order'] );
216 240 }
217 241
218 242 if ( ! is_shop() && is_product_taxonomy() ) {
219 243 if ( ! empty( $queried_obj->taxonomy ) ) {
@@ -224,9 +248,9 @@
224 248 $data['queried_term'] = esc_html( $queried_obj->term_id );
225 249 }
226 250 }
227 251
228 - return apply_filters( 'rtsb/elementor/render/meta_dataset_final', $data, $meta );
252 + return apply_filters( 'rtsb/elementor/render/meta_dataset_final', $data, $meta, $raw_settings );
229 253 }
230 254
231 255 /**
232 256 * Builds an array with field values.
@@ -236,19 +260,15 @@
236 260 *
237 261 * @return array
238 262 */
239 263 public static function archive_meta_dataset( array $meta, $template = '' ) {
240 - $products_row = absint( get_option( 'woocommerce_catalog_rows', 4 ) );
241 - $products_col = absint( get_option( 'woocommerce_catalog_columns', 4 ) );
242 - $products_per_page = apply_filters( 'rtsb/elementor/archive/products_per_page', $products_row * $products_col );
243 -
244 264 $data = apply_filters(
245 265 'rtsb/elementor/render/archive_meta_dataset',
246 266 [
247 267 // Layout.
248 268 'widget' => 'default',
249 - 'template' => ! empty( $template ) ? $template : '',
250 - 'view_mode' => ! empty( $meta['view_mode'] ) ? $meta['view_mode'] : 'grid',
269 + 'template' => self::get_data( $template, '', '' ),
270 + 'view_mode' => self::get_data( $meta, 'view_mode', 'grid' ),
251 271 'show_flash_sale' => ! empty( $meta['show_flash_sale'] ),
252 272 'wishlist_button' => ! empty( $meta['wishlist_button'] ),
253 273 'comparison_button' => ! empty( $meta['comparison_button'] ),
254 274 'quick_view_button' => ! empty( $meta['quick_view_button'] ),
@@ -253,20 +273,20 @@
253 273 'comparison_button' => ! empty( $meta['comparison_button'] ),
254 274 'quick_view_button' => ! empty( $meta['quick_view_button'] ),
255 275 'show_rating' => ! empty( $meta['show_rating'] ),
256 276 'show_pagination' => ! empty( $meta['show_pagination'] ),
257 - 'cart_icon' => ! empty( $meta['cart_icon'] ) ? $meta['cart_icon'] : [],
258 - 'wishlist_icon' => ! empty( $meta['wishlist_icon'] ) ? $meta['wishlist_icon'] : [],
259 - 'wishlist_icon_added' => ! empty( $meta['wishlist_icon_added'] ) ? $meta['wishlist_icon_added'] : [],
260 - 'comparison_icon' => ! empty( $meta['comparison_icon'] ) ? $meta['comparison_icon'] : [],
261 - 'comparison_icon_added' => ! empty( $meta['comparison_icon_added'] ) ? $meta['comparison_icon_added'] : [],
262 - 'quick_view_icon' => ! empty( $meta['quick_view_icon'] ) ? $meta['quick_view_icon'] : [],
263 - 'prev_icon' => ! empty( $meta['prev_icon'] ) ? $meta['prev_icon'] : [],
264 - 'next_icon' => ! empty( $meta['next_icon'] ) ? $meta['next_icon'] : [],
265 - 'posts_per_page' => ! empty( $products_per_page ) ? $products_per_page : 12,
266 - 'rtsb_order' => ! empty( $meta['rtsb_order'] ) ? $meta['rtsb_order'] : 'ASC',
267 - 'rtsb_orderby' => ! empty( $meta['rtsb_orderby'] ) ? $meta['rtsb_orderby'] : 'menu_order',
268 - 'tooltip_position' => ! empty( $meta['action_btn_tooltip_position'] ) ? $meta['action_btn_tooltip_position'] : 'top',
277 + 'cart_icon' => self::get_data( $meta, 'cart_icon', [] ),
278 + 'wishlist_icon' => self::get_data( $meta, 'wishlist_icon', [] ),
279 + 'wishlist_icon_added' => self::get_data( $meta, 'wishlist_icon_added', [] ),
280 + 'comparison_icon' => self::get_data( $meta, 'comparison_icon', [] ),
281 + 'comparison_icon_added' => self::get_data( $meta, 'comparison_icon_added', [] ),
282 + 'quick_view_icon' => self::get_data( $meta, 'quick_view_icon', [] ),
283 + 'prev_icon' => self::get_data( $meta, 'prev_icon', [] ),
284 + 'next_icon' => self::get_data( $meta, 'next_icon', [] ),
285 + 'posts_per_page' => self::get_products_per_page(),
286 + 'rtsb_order' => self::get_data( $meta, 'rtsb_order', 'ASC' ),
287 + 'rtsb_orderby' => self::get_data( $meta, 'rtsb_orderby', 'menu_order' ),
288 + 'tooltip_position' => self::get_data( $meta, 'action_btn_tooltip_position', 'top' ),
269 289 ],
270 290 $meta
271 291 );
272 292
@@ -397,11 +417,24 @@
397 417
398 418 case 'list-layout1':
399 419 case 'list-layout2':
400 420 case 'list-layout3':
421 + case 'list-layout7':
422 + case 'list-layout5':
401 423 $columns = 1;
402 424 break;
403 425
426 + case 'list-layout4':
427 + case 'list-layout6':
428 + case 'slider-layout5':
429 + case 'slider-layout8':
430 + $columns = 2;
431 + break;
432 +
433 + case 'grid-layout6':
434 + $columns = 5;
435 + break;
436 +
404 437 case 'category-layout1':
405 438 $columns = 6;
406 439 break;
407 440
@@ -409,9 +442,9 @@
409 442 $columns = 4;
410 443 break;
411 444 }
412 445
413 - return $columns;
446 + return apply_filters( 'rtsb/element/general/default_columns', $columns, $layout );
414 447 }
415 448
416 449 /**
417 450 * Pagination JSON data.
@@ -423,12 +456,200 @@
423 456 */
424 457 public static function pagination_data( $metas, $template ) {
425 458 $el_data = self::meta_dataset( $metas, $template );
426 459
427 - return ' data-rtsb-ajax=\'' . esc_js( wp_json_encode( $el_data ) ) . '\'';
460 + return esc_js( wp_json_encode( $el_data, JSON_UNESCAPED_UNICODE ) );
428 461 }
429 462
430 463 /**
464 + * Container classes
465 + *
466 + * @param array $metas Meta data.
467 + * @param array $settings Settings array.
468 + * @param string $custom_class Custom class.
469 + *
470 + * @return mixed|null
471 + */
472 + public static function prepare_container_classes( $metas = [], $settings = [], $custom_class = '' ) {
473 + $classes = 'rtsb-elementor-container products rtsb-pos-r ';
474 + $classes .= $custom_class;
475 +
476 + $raw_layout = esc_html( $metas['layout'] );
477 + $layout = self::filter_layout( $raw_layout );
478 + $is_cat = preg_match( '/category/', $layout );
479 + $cart_txt_class = '';
480 +
481 + $animation = $metas['hover_animation'];
482 +
483 + if ( ! $is_cat ) {
484 + $cart_txt_class = $metas['show_cart_text'] ? ' has-cart-text' : ' no-cart-text';
485 + $animation .= ' gallery-hover-' . ( ! empty( $settings['gallery_hover_animation'] ) ? $settings['gallery_hover_animation'] : 'fade' );
486 + }
487 +
488 + $badge_class = [
489 + 'position' => $metas['badge_position'],
490 + 'alignment' => $metas['badge_alignment'],
491 + ];
492 +
493 + if ( ! in_array( 'clear-btn', $metas['visibility'], true ) ) {
494 + $classes .= ' no-clear-btn';
495 + }
496 +
497 + $classes .= ! empty( $metas['pagination'] ) ? ' rtsb-has-pagination' : ' rtsb-no-pagination';
498 + $classes .= ' badge-' . esc_attr( $badge_class['position'] ) . ' badge-' . esc_attr( $badge_class['alignment'] ) . esc_attr( $cart_txt_class ) . ' img-hover-' . esc_attr( $animation ) . ' excerpt-' . esc_attr( $metas['cat_excerpt_position'] );
499 +
500 + if ( $metas['show_overlay'] ) {
501 + $classes .= ' has-overlay';
502 + }
503 +
504 + if ( in_array( 'single-cat', $metas['visibility'], true ) ) {
505 + $classes .= ' show-single-cat';
506 + }
507 +
508 + if ( ! $is_cat ) {
509 + $action_btn_classes = [
510 + 'show_compare_text' => 'has-compare-text',
511 + 'show_quick_view_text' => 'has-quick-view-text',
512 + 'show_wishlist_text' => 'has-wishlist-text',
513 + 'show_compare_icon' => 'no-compare-icon',
514 + 'show_quick_view_icon' => 'no-quick-view-icon',
515 + 'show_wishlist_icon' => 'no-wishlist-icon',
516 + 'show_quick_checkout_icon' => 'no-quick_checkout-icon',
517 + ];
518 +
519 + foreach ( $action_btn_classes as $setting_key => $class ) {
520 + if ( strpos( $setting_key, 'icon' ) !== false ) {
521 + $classes .= empty( $settings[ $setting_key ] ) ? ' ' . $class : '';
522 + } else {
523 + $classes .= ! empty( $settings[ $setting_key ] ) ? ' ' . $class : '';
524 + }
525 + }
526 +
527 + if ( rtsb()->has_pro() && ! empty( $settings['custom_ordering'] ) ) {
528 + $classes .= ' has-custom-ordering';
529 + }
530 + }
531 + if ( rtsb()->has_pro() && ! empty( $settings['slider_slide_animation'] ) ) {
532 + $classes .= ' has-slide-animation';
533 + }
534 +
535 + return apply_filters( 'rtsb/product/container/class', $classes, $settings );
536 + }
537 +
538 + /**
539 + * Function to filter and validate the layout against allowed patterns.
540 + *
541 + * @param string $layout The layout string to be filtered.
542 + * @param string $template The template to be checked.
543 + *
544 + * @return string
545 + */
546 + public static function filter_layout( $layout, $template = '' ) {
547 + $allowed_patterns = [ 'grid', 'list', 'slider', 'category' ];
548 + $layout_part = explode( '-', $layout );
549 + $default = 'grid-layout1';
550 +
551 + if ( empty( $layout_part[0] ) ) {
552 + return $default;
553 + }
554 +
555 + if ( in_array( $layout_part[0], $allowed_patterns, true ) ) {
556 + return $layout;
557 + } else {
558 + if ( ! empty( $template ) ) {
559 + $grid = preg_match( '/grid/', $template );
560 + $list = preg_match( '/list/', $template );
561 + $slider = preg_match( '/slider/', $template );
562 + $category = preg_match( '/category/', $template );
563 +
564 + if ( $grid ) {
565 + return $default;
566 + } elseif ( $list ) {
567 + return 'list-layout1';
568 + } elseif ( $slider ) {
569 + return 'slider-layout1';
570 + } elseif ( $category ) {
571 + return 'category-layout1';
572 + } else {
573 + return $default;
574 + }
575 + } else {
576 + return $default;
577 + }
578 + }
579 + }
580 +
581 + /**
582 + * Row classes
583 + *
584 + * @param array $settings Settings array.
585 + *
586 + * @return mixed|null
587 + */
588 + public static function prepare_row_classes( $settings = [] ) {
589 + $masonry_class = null;
590 + $classes = 'rtsb-row rtsb-content-loader element-loading';
591 + $loader_class = ' rtsb-pre-loader';
592 +
593 + $raw_layout = esc_html( $settings['layout'] );
594 + $layout = self::filter_layout( $raw_layout );
595 + $grid_type = $settings['grid_type'];
596 + $is_carousel = preg_match( '/slider/', $layout );
597 +
598 + if ( preg_match( '/category/', $layout ) && ! empty( $settings['active_cat_slider'] ) ) {
599 + $classes .= ' rtsb-slider-layout';
600 + }
601 +
602 + if ( 'even' === $grid_type ) {
603 + $masonry_class = ' rtsb-even';
604 + } elseif ( 'masonry' === $grid_type ) {
605 + $masonry_class = ' rtsb-masonry';
606 + }
607 +
608 + if ( ! rtsb()->has_pro() || $is_carousel ) {
609 + $masonry_class = ' rtsb-even';
610 + }
611 + if ( $is_carousel && ! empty( $settings['raw_settings']['always_show_nav'] ) ) {
612 + $classes .= ' always-show-nav';
613 + }
614 + if ( ! empty( $settings['raw_settings']['inner_slider_always_show_nav'] ) ) {
615 + $classes .= ' inner-slider-always-show-nav';
616 + }
617 +
618 + $classes .= ' rtsb-' . $layout . $masonry_class . $loader_class;
619 +
620 + return apply_filters( 'rtsb/elementor/row/classes', $classes, $settings );
621 + }
622 +
623 + /**
624 + * Prepare pagination attributes.
625 + *
626 + * @param string $layout The layout type.
627 + * @param bool $has_filters Whether the widget has filters.
628 + * @param string $template The template name.
629 + * @param array $settings The widget settings.
630 + * @param bool $ajax Whether to enable AJAX pagination.
631 + *
632 + * @return string
633 + */
634 + public static function prepare_pagination_attr( $layout, $has_filters, $template, $settings, $ajax ) {
635 + $is_cat = preg_match( '/category/', $layout );
636 + $is_carousel = preg_match( '/slider/', $layout );
637 +
638 + if ( $is_carousel ) {
639 + return $has_filters ? self::pagination_data( $settings, $template ) : '';
640 + } elseif ( $is_cat ) {
641 + return '';
642 + } else {
643 + $ajax_pagination = ! empty( $settings['show_pagination'] ) && 'pagination' !== $settings['pagination_type'];
644 + $page = Fns::product_filters_has_ajax( apply_filters( 'rtsb/builder/set/current/page/type', '' ) );
645 + $condition = rtsb()->has_pro() && $ajax && ( $ajax_pagination || $has_filters || $page );
646 +
647 + return $condition ? self::pagination_data( $settings, $template ) : '';
648 + }
649 + }
650 +
651 + /**
431 652 * Archive JSON data.
432 653 *
433 654 * @param array $metas Data set.
434 655 * @param string $template Template name.
@@ -449,34 +670,35 @@
449 670 *
450 671 * @return array
451 672 */
452 673 public static function slider_data( array $meta, $settings = [] ) {
453 - $has_dots = $meta['slider_dot'] ? ' has-dot' : ' no-dot';
454 - $has_dots .= $meta['slider_nav'] ? ' has-nav' : ' no-nav';
455 - $d_col = 0 === $meta['d_cols'] ? self::default_columns( $meta['layout'] ) : $meta['d_cols'];
456 - $t_col = 0 === $meta['t_cols'] ? 2 : $meta['t_cols'];
457 - $m_col = 0 === $meta['m_cols'] ? 1 : $meta['m_cols'];
674 + $has_dots = $meta['slider_dot'] ? ' has-dot' : ' no-dot';
675 + $has_dots .= $meta['slider_nav'] ? ' has-nav' : ' no-nav';
676 + $has_dynamic_dots = $meta['slider_dynamic_dot'] ? true : false;
677 + $d_col = 0 === $meta['d_cols'] ? self::default_columns( $meta['layout'] ) : $meta['d_cols'];
678 + $t_col = 0 === $meta['t_cols'] ? 2 : $meta['t_cols'];
679 + $m_col = 0 === $meta['m_cols'] ? 1 : $meta['m_cols'];
458 680
459 681 if ( \Elementor\Plugin::$instance->breakpoints->has_custom_breakpoints() ) {
460 682 // Widescreen.
461 - $w_col = ! empty( $settings['cols_widescreen'] ) ? $settings['cols_widescreen'] : null;
683 + $w_col = self::get_data( $settings, 'cols_widescreen' );
462 684 $w_col = 0 === $w_col ? self::default_columns( $meta['layout'] ) : $w_col;
463 - $w_group = ! empty( $settings['cols_group_widescreen'] ) ? $settings['cols_group_widescreen'] : 1;
685 + $w_group = self::get_data( $settings, 'cols_group_widescreen', 1 );
464 686
465 687 // Laptop.
466 - $l_col = ! empty( $settings['cols_laptop'] ) ? $settings['cols_laptop'] : null;
688 + $l_col = self::get_data( $settings, 'cols_laptop' );
467 689 $l_col = 0 === $l_col ? self::default_columns( $meta['layout'] ) : $l_col;
468 - $l_group = ! empty( $settings['cols_group_laptop'] ) ? $settings['cols_group_laptop'] : 1;
690 + $l_group = self::get_data( $settings, 'cols_group_laptop', 1 );
469 691
470 692 // Tablet Landscape.
471 - $te_col = ! empty( $settings['cols_tablet_extra'] ) ? $settings['cols_tablet_extra'] : null;
693 + $te_col = self::get_data( $settings, 'cols_tablet_extra' );
472 694 $te_col = 0 === $te_col ? 3 : $te_col;
473 - $te_group = ! empty( $settings['cols_group_tablet_extra'] ) ? $settings['cols_group_tablet_extra'] : 1;
695 + $te_group = self::get_data( $settings, 'cols_group_tablet_extra', 1 );
474 696
475 697 // Mobile Landscape.
476 - $me_col = ! empty( $settings['cols_mobile_extra'] ) ? $settings['cols_mobile_extra'] : null;
698 + $me_col = self::get_data( $settings, 'cols_mobile_extra' );
477 699 $me_col = 0 === $me_col ? 2 : $me_col;
478 - $me_group = ! empty( $settings['cols_group_mobile_extra'] ) ? $settings['cols_group_mobile_extra'] : 1;
700 + $me_group = self::get_data( $settings, 'cols_group_mobile_extra', 1 );
479 701
480 702 $el_breakpoints = Fns::get_elementor_breakpoints();
481 703
482 704 foreach ( $el_breakpoints as $key => $value ) {
@@ -489,9 +711,9 @@
489 711 0 => [
490 712 'slidesPerView' => absint( $m_col ),
491 713 'slidesPerGroup' => absint( $meta['m_group'] ),
492 714 'pagination' => [
493 - 'dynamicBullets' => true,
715 + 'dynamicBullets' => $has_dynamic_dots,
494 716 ],
495 717 ],
496 718 ];
497 719
@@ -516,16 +738,16 @@
516 738 }
517 739
518 740 foreach ( $el_breakpoints as $el_breakpoint => $value ) {
519 741 $breakpoint_value = ! empty( $value['value'] ) ? $value['value'] : $value['default_value'];
520 - $dynamic_bullets = false;
742 + $dynamic_bullets = $has_dynamic_dots;
521 743 $slides_per_view = $d_col;
522 744 $slides_per_group = $meta['d_group'];
523 745
524 746 switch ( $el_breakpoint ) {
525 747 case 'widescreen':
526 - $slides_per_view = $w_col;
527 - $slides_per_group = $w_group;
748 + $slides_per_view = $w_col;
749 + $slides_per_group = $w_group;
528 750
529 751 break;
530 752
531 753 case 'laptop':
@@ -534,10 +756,10 @@
534 756
535 757 break;
536 758
537 759 case 'tablet_extra':
538 - $slides_per_view = $l_col;
539 - $slides_per_group = $l_group;
760 + $slides_per_view = $l_col;
761 + $slides_per_group = $l_group;
540 762
541 763 if ( empty( $el_breakpoints['laptop'] ) ) {
542 764 $slides_per_view = $d_col;
543 765 $slides_per_group = $meta['d_group'];
@@ -562,11 +784,11 @@
562 784
563 785 break;
564 786
565 787 case 'mobile_extra':
566 - $slides_per_view = $t_col;
567 - $slides_per_group = $meta['t_group'];
568 - $dynamic_bullets = true;
788 + $slides_per_view = $t_col;
789 + $slides_per_group = $meta['t_group'];
790 + $dynamic_bullets = $has_dynamic_dots;
569 791
570 792 break;
571 793
572 794 case 'mobile':
@@ -571,9 +793,9 @@
571 793
572 794 case 'mobile':
573 795 $slides_per_view = $t_col;
574 796 $slides_per_group = $meta['t_group'];
575 - $dynamic_bullets = true;
797 + $dynamic_bullets = $has_dynamic_dots;
576 798
577 799 if ( ! empty( $el_breakpoints['mobile_extra'] ) ) {
578 800 $slides_per_view = $me_col;
579 801 $slides_per_group = $me_group;
@@ -599,9 +821,9 @@
599 821 0 => [
600 822 'slidesPerView' => absint( $m_col ),
601 823 'slidesPerGroup' => absint( $meta['m_group'] ),
602 824 'pagination' => [
603 - 'dynamicBullets' => true,
825 + 'dynamicBullets' => $has_dynamic_dots,
604 826 ],
605 827 ],
606 828 768 => [
607 829 'slidesPerView' => absint( $t_col ),
@@ -606,9 +828,9 @@
606 828 768 => [
607 829 'slidesPerView' => absint( $t_col ),
608 830 'slidesPerGroup' => absint( $meta['t_group'] ),
609 831 'pagination' => [
610 - 'dynamicBullets' => false,
832 + 'dynamicBullets' => $has_dynamic_dots,
611 833 ],
612 834 ],
613 835 1025 => [
614 836 'slidesPerView' => absint( $d_col ),
@@ -613,9 +835,9 @@
613 835 1025 => [
614 836 'slidesPerView' => absint( $d_col ),
615 837 'slidesPerGroup' => absint( $meta['d_group'] ),
616 838 'pagination' => [
617 - 'dynamicBullets' => false,
839 + 'dynamicBullets' => $has_dynamic_dots,
618 840 ],
619 841 ],
620 842 ];
621 843 }
@@ -630,8 +852,11 @@
630 852 'lazy' => $meta['lazy_load'],
631 853 'breakpoints' => $breakpoints,
632 854 ];
633 855
856 + if ( ! empty( $meta['raw_settings']['slider_slide_animation'] ) ) {
857 + $slider_options['watchSlidesProgress'] = true;
858 + }
634 859 if ( $meta['auto_play'] ) {
635 860 $slider_options['autoplay'] = [
636 861 'delay' => absint( $meta['auto_play_timeout'] ),
637 862 'pauseOnMouseEnter' => $meta['stop_on_hover'],
@@ -638,72 +863,18 @@
638 863 'disableOnInteraction' => false,
639 864 ];
640 865 }
641 866
642 - $carouselClass = 'rtsb-carousel-slider slider-loading rtsb-pos-s ' . $meta['nav_position'] . '-nav' . $has_dots;
867 + $slider_options = apply_filters( 'rtsb/elementor/render/slider_dataset', $slider_options, $meta );
868 + $carouselClass = 'rtsb-carousel-slider slider-loading rtsb-pos-s ' . $meta['nav_position'] . '-nav' . $has_dots;
643 869
644 870 return [
645 - 'data' => ' data-options=\'' . esc_js( wp_json_encode( $slider_options ) ) . '\'',
871 + 'data' => esc_js( wp_json_encode( $slider_options ) ),
646 872 'class' => $carouselClass,
647 873 ];
648 874 }
649 875
650 876 /**
651 - * Renders pagination
652 - *
653 - * @param object $wp_query WP_Query object.
654 - * @param array $meta Meta values.
655 - * @param int $limit Post limit.
656 - * @param int $per_page Posts per page.
657 - *
658 - * @return string
659 - */
660 - public static function render_pagination( $wp_query, $meta, $limit, $per_page ) {
661 - $html_utility = null;
662 - $html = null;
663 - $ajax = false;
664 - $is_grid = preg_match( '/grid-layout/', $meta['layout'] ) || preg_match( '/list-layout/', $meta['layout'] );
665 - $posts_per_page = $wp_query->query_vars['posts_per_page'];
666 - $total_page = $wp_query->max_num_pages;
667 -
668 - if ( $limit && ( empty( $wp_query->query['tax_query'] ) ) ) {
669 - $found_post = $wp_query->found_posts;
670 -
671 - if ( $per_page && $found_post > $per_page ) {
672 - $found_post = $limit;
673 - $total_page = ceil( $found_post / $per_page );
674 - }
675 - }
676 -
677 - $total_page = absint( $total_page );
678 -
679 - $args = [
680 - 'total_page' => $total_page,
681 - 'posts_per_page' => $posts_per_page,
682 - 'ajax' => $ajax,
683 - ];
684 -
685 - if ( 'pagination' === $meta['posts_loading_type'] ) {
686 - if ( $is_grid ) {
687 - $html_utility .= Fns::custom_pagination(
688 - $total_page,
689 - $posts_per_page
690 - );
691 - }
692 - } else {
693 - ob_start();
694 - do_action( 'rtsb/elementor/render/pagination', $meta, $wp_query, $args );
695 - $html_utility .= ob_get_clean();
696 - }
697 -
698 - if ( $html_utility ) {
699 - $html .= '<div class="rtsb-pagination-wrap element-loading" data-total-pages="' . absint( $total_page ) . '" data-posts-per-page="' . absint( $posts_per_page ) . '" data-type="' . esc_attr( $meta['posts_loading_type'] ) . '">' . $html_utility . '</div>';
700 - }
701 -
702 - return $html;
703 - }
704 -
705 - /**
706 877 * Preloader.
707 878 *
708 879 * @param string $layout Layout.
709 880 *
@@ -783,9 +954,11 @@
783 954
784 955 $script[] = 'rtsb-imagesloaded';
785 956 $script[] = 'rtsb-public';
786 957
787 - wp_enqueue_script( $script );
958 + foreach ( $script as $sc ) {
959 + wp_enqueue_script( $sc );
960 + }
788 961 }
789 962 }
790 963
791 964 /**
@@ -811,6 +984,19 @@
811 984 return true;
812 985 }
813 986
814 987 return false;
988 + }
989 +
990 + /**
991 + * Get the number of products per page based on WooCommerce settings.
992 + *
993 + * @return int
994 + */
995 + public static function get_products_per_page() {
996 + $products_row = absint( get_option( 'woocommerce_catalog_rows', 4 ) );
997 + $products_col = absint( get_option( 'woocommerce_catalog_columns', 4 ) );
998 + $products_per_page = apply_filters( 'rtsb/elementor/archive/products_per_page', $products_row * $products_col );
999 +
1000 + return ! empty( $products_per_page ) ? $products_per_page : 12;
815 1001 }
816 1002 }