PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
← All changes | includes/widgets/advanced-post-grid.php +95 -56 1.0.151.3.17 View file →
@@ -52,16 +52,16 @@
52 52 'advanced-post-grid',
53 53 'legacy-grid',
54 54 'post-meta',
55 55 'filters' => [
56 - 'condition' => [
57 - 'post_filtering' => 'yes',
58 - ],
59 - ],
56 + 'condition' => [
57 + 'post_filtering' => 'yes',
58 + ],
59 + ],
60 60 'animation', // hover animations
61 61 'entrance', // entrance basic style
62 62 ];
63 - if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){
63 + if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) {
64 64 $styles['e-animations'] = [ // entrance animations
65 65 'external' => true,
66 66 ];
67 67 }
@@ -66,8 +66,30 @@
66 66 ];
67 67 }
68 68 return $styles;
69 69 }
70 +
71 + /**
72 + * Adds `woocommerce` classname so rating can inherit woo styles and
73 + * also follow theme option styles instead of plain text.
74 + */
75 + protected function add_render_attributes()
76 + {
77 + parent::add_render_attributes();
78 +
79 + if (class_exists('WooCommerce') && \is_woocommerce()) {
80 + return;
81 + }
82 +
83 + $this->add_render_attribute(
84 + '_wrapper',
85 + 'class',
86 + [
87 + 'woocommerce',
88 + $this->get_html_wrapper_class(),
89 + ]
90 + );
91 + }
70 92 public function get_scripts()
71 93 {
72 94 return [
73 95 'masonry' => [
@@ -86,20 +108,25 @@
86 108 ]
87 109 ]
88 110 ];
89 111 }
112 + public function has_widget_inner_wrapper(): bool
113 + {
114 + // TODO: remove after Optmized Markup experiment is merged to the core
115 + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
116 + }
90 117
91 118 private function filter_missing_taxonomies($settings)
92 119 {
93 120 // Check if is an "Advanced Product.." widget, since this widget is extended by other(s)
94 121 $slug = strpos($this->get_name(), 'product') !== false ?
95 - 'product-filter_post_type' :
96 - 'posts-filter_post_type';
122 + 'product-filter_post_type' :
123 + 'posts-filter_post_type';
97 124
98 125 $taxonomy_filter_args = [
99 126 'show_in_nav_menus' => true,
100 127 ];
101 - if ( !empty($settings[$slug]) ) {
128 + if (!empty($settings[$slug])) {
102 129 $taxonomy_filter_args['object_type'] = [$settings[$slug]];
103 130 }
104 131
105 132 $taxonomies = get_taxonomies($taxonomy_filter_args, 'objects');
@@ -105,10 +132,10 @@
105 132 $taxonomies = get_taxonomies($taxonomy_filter_args, 'objects');
106 133
107 134 foreach ($taxonomies as $taxonomy => $object) {
108 135 $controll_id = 'posts-filter_' . $taxonomy . '_ids';
109 - \error_log($controll_id);
110 - \error_log(print_r($settings[$controll_id], true));
136 + //error_log($controll_id);
137 + //error_log(print_r($settings[$controll_id], true));
111 138
112 139 if (!isset($settings[$controll_id]) || empty($settings[$controll_id])) {
113 140 continue;
114 141 }
@@ -148,9 +175,9 @@
148 175 [
149 176 'label' => esc_html__('Grid', 'uicore-elements'),
150 177 ]
151 178 );
152 - $this->TRAIT_register_grid_layout_controls();
179 + $this->TRAIT_register_grid_layout_controls();
153 180 $this->end_controls_section();
154 181
155 182 $this->TRAIT_register_post_item_controls();
156 183 $this->TRAIT_register_post_button_controls();
@@ -173,21 +200,21 @@
173 200 'label' => __('Animations', 'uicore-elements'),
174 201 'tab' => Controls_Manager::TAB_STYLE,
175 202 ]
176 203 );
177 - $this->TRAIT_register_entrance_animations_controls();
178 - $this->TRAIT_register_hover_animation_control(
179 - 'Item Hover Animation',
180 - [],
181 - ['underline'],
182 - 'anim_item'
183 - );
184 - $this->TRAIT_register_post_animation_controls();
204 + $this->TRAIT_register_entrance_animations_controls();
205 + $this->TRAIT_register_hover_animation_control(
206 + 'Item Hover Animation',
207 + [],
208 + ['underline'],
209 + 'anim_item'
210 + );
211 + $this->TRAIT_register_post_animation_controls();
185 212 $this->end_controls_section();
186 213
187 214 // Update masonry from component to a legacy version
188 215 $this->update_control('masonry', [
189 - 'label' => __( 'Masonry', 'uicore-elements' ),
216 + 'label' => __('Masonry', 'uicore-elements'),
190 217 'type' => Controls_Manager::SWITCHER,
191 218 'frontend_available' => true,
192 219 'default' => 'no',
193 220 'return_value' => 'ui-e-maso',
@@ -198,11 +225,9 @@
198 225 'selectors' => [],
199 226 ]);
200 227 }
201 228
202 - function content_template()
203 - {
204 - }
229 + function content_template() {}
205 230
206 231 /**
207 232 * Renders the widget content using AJAX.
208 233 *
@@ -209,28 +234,30 @@
209 234 * This method retrieves the widget settings; set up the query, and renders each post item.
210 235 * If no posts are found, it returns false. After rendering, it resets the query and returns the output.
211 236 *
212 237 * @param array|false $current_query The current query args, or false if the widget isn't set to use the current query.
238 + * @param int $pageID The ID of the page where the widget is located.
213 239 *
214 240 * @return string|false The rendered widget content or false if no posts are found.
215 - */
241 + */
216 242 public function render_ajax($current_query)
217 243 {
218 -
219 244 // Get settings and post type
220 245 $settings = $this->get_settings();
246 + $loop = 0;
221 247
222 - $this->TRAIT_query_posts( $settings, $current_query );
248 + $this->TRAIT_query_posts($settings, $current_query);
223 249 $wp_query = $this->get_query();
224 250
225 - if (!$wp_query->have_posts()) {
226 - return false;
251 + if (!$wp_query || !$wp_query->have_posts()) {
252 + $markup = '';
227 253 }
228 254
229 255 \ob_start();
230 256 while ($wp_query->have_posts()) {
231 257 $wp_query->the_post();
232 - $this->TRAIT_render_item(false, true);
258 + $this->TRAIT_render_item($loop, false, true);
259 + $loop++;
233 260 }
234 261 $markup = \ob_get_clean();
235 262
236 263 return [
@@ -239,8 +266,11 @@
239 266 }
240 267
241 268 protected function render()
242 269 {
270 + // Get current post ID
271 + $post_id = get_the_ID();
272 +
243 273 // Get query args, settings and post type slug
244 274 global $wp_query;
245 275 $default_query = $wp_query;
246 276 $settings = $this->get_settings();
@@ -245,13 +275,11 @@
245 275 $default_query = $wp_query;
246 276 $settings = $this->get_settings();
247 277
248 278 // Build query
249 - $this->TRAIT_query_posts( $settings, $wp_query->query );
279 + $this->TRAIT_query_posts($settings, $wp_query->query);
250 280 $wp_query = $this->get_query();
251 281
252 - $this->TRAIT_set_meta_font_size_to_svg($settings); // SVG icon experiment font-size adjustment
253 -
254 282 // Store widget settings in a transient
255 283 $ID = strval($this->get_ID());
256 284 set_transient('ui_elements_widgetdata_' . $ID, $settings, \MONTH_IN_SECONDS);
257 285
@@ -259,45 +287,56 @@
259 287 $items = $settings['item_limit']['size'];
260 288 $loops = 0;
261 289
262 290 // Set masonry class
263 - $masonry = $settings['masonry'] === 'yes' ? 'ui-e-maso' : '';
291 + $masonry = $this->is_option('masonry', 'yes')
292 + ? 'ui-e-maso'
293 + : '';
264 294
265 295 $this->TRAIT_render_filters($settings);
266 296
267 297 // No posts found
268 298 if (!$wp_query->have_posts()) {
269 - echo '<p style="text-align:center">' . __('No posts found.', 'uicore-elements') . '</p>';
299 + echo '<p style="text-align:center">' . esc_html__('No posts found.', 'uicore-elements') . '</p>';
270 300 } else {
271 301
272 - ?>
273 - <div class="ui-e-adv-grid <?php echo esc_attr($masonry);?>">
274 - <?php
275 - while ($wp_query->have_posts()) {
302 +?>
303 + <div class="ui-e-adv-grid <?php echo esc_attr($masonry); ?>">
304 + <?php
305 + while ($wp_query->have_posts()) {
276 306
277 - // sticky posts disregards posts per page, so ending the loop if $items == $loop forces the query respects the users item limit
278 - if ($settings['sticky'] && $items == $loops) {
279 - break;
280 - }
307 + // sticky posts disregards posts per page, so ending the loop if $items == $loop forces the query respects the users item limit
308 + if ($settings['sticky'] && $items == $loops) {
309 + break;
310 + }
281 311
282 - $wp_query->the_post();
283 - $this->TRAIT_render_item(false, true);
312 + $wp_query->the_post();
313 + $this->TRAIT_render_item($loops, false, true);
284 314
285 - $loops++;
286 - }
287 - ?>
288 - </div>
289 - <?php
315 + $loops++;
316 + }
317 + ?>
318 + </div>
319 +<?php
290 320
291 - $this->TRAIT_render_pagination($settings);
321 + $this->TRAIT_render_pagination($settings, $post_id);
292 322
293 - if( $settings['pagination'] == 'yes' && $settings['pagination_type'] == 'load_more' && $settings['posts-filter_post_type'] == 'current' ) {
323 + if (
324 + $this->is_option('pagination', 'yes') &&
325 + $this->is_option('pagination_type', 'load_more') &&
326 + $this->is_option('posts-filter_post_type', 'current')
327 + ) {
294 328
295 - echo '<script>';
296 - echo 'window.ui_total_pages_' . esc_html($ID) . ' = "none";'; // add none to avoid ajax errors for lack of value, but posts don't need it
297 - echo 'window.ui_query_' . esc_html($ID) . ' = ' . \json_encode($wp_query) . ';';
298 - echo '</script>';
299 - }
329 + // Build the public query args the ajax request script passes to rest api
330 + $public_query = array();
331 + $public_query['query']['post_type'] = get_post_type();
332 + $public_query['query_vars'] = $wp_query->query_vars;
333 +
334 + echo '<script>';
335 + echo 'window.ui_total_pages_' . esc_html($ID) . ' = "none";'; // add none to avoid ajax errors for lack of value, but posts don't need it
336 + echo 'window.ui_query_' . esc_html($ID) . ' = ' . \json_encode($public_query) . ';';
337 + echo '</script>';
338 + }
300 339 }
301 340
302 341 //reset query
303 342 wp_reset_query();