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 +88 -60 1.2.11.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,24 +108,25 @@
86 108 ]
87 109 ]
88 110 ];
89 111 }
90 - // TODO: remove or set as false, after 3.30, when the full deprecation of widget innet wrapper is ready
91 - public function has_widget_inner_wrapper(): bool {
92 - return true;
93 - }
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 + }
94 117
95 118 private function filter_missing_taxonomies($settings)
96 119 {
97 120 // Check if is an "Advanced Product.." widget, since this widget is extended by other(s)
98 121 $slug = strpos($this->get_name(), 'product') !== false ?
99 - 'product-filter_post_type' :
100 - 'posts-filter_post_type';
122 + 'product-filter_post_type' :
123 + 'posts-filter_post_type';
101 124
102 125 $taxonomy_filter_args = [
103 126 'show_in_nav_menus' => true,
104 127 ];
105 - if ( !empty($settings[$slug]) ) {
128 + if (!empty($settings[$slug])) {
106 129 $taxonomy_filter_args['object_type'] = [$settings[$slug]];
107 130 }
108 131
109 132 $taxonomies = get_taxonomies($taxonomy_filter_args, 'objects');
@@ -152,9 +175,9 @@
152 175 [
153 176 'label' => esc_html__('Grid', 'uicore-elements'),
154 177 ]
155 178 );
156 - $this->TRAIT_register_grid_layout_controls();
179 + $this->TRAIT_register_grid_layout_controls();
157 180 $this->end_controls_section();
158 181
159 182 $this->TRAIT_register_post_item_controls();
160 183 $this->TRAIT_register_post_button_controls();
@@ -177,21 +200,21 @@
177 200 'label' => __('Animations', 'uicore-elements'),
178 201 'tab' => Controls_Manager::TAB_STYLE,
179 202 ]
180 203 );
181 - $this->TRAIT_register_entrance_animations_controls();
182 - $this->TRAIT_register_hover_animation_control(
183 - 'Item Hover Animation',
184 - [],
185 - ['underline'],
186 - 'anim_item'
187 - );
188 - $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();
189 212 $this->end_controls_section();
190 213
191 214 // Update masonry from component to a legacy version
192 215 $this->update_control('masonry', [
193 - 'label' => __( 'Masonry', 'uicore-elements' ),
216 + 'label' => __('Masonry', 'uicore-elements'),
194 217 'type' => Controls_Manager::SWITCHER,
195 218 'frontend_available' => true,
196 219 'default' => 'no',
197 220 'return_value' => 'ui-e-maso',
@@ -202,11 +225,9 @@
202 225 'selectors' => [],
203 226 ]);
204 227 }
205 228
206 - function content_template()
207 - {
208 - }
229 + function content_template() {}
209 230
210 231 /**
211 232 * Renders the widget content using AJAX.
212 233 *
@@ -213,23 +234,23 @@
213 234 * This method retrieves the widget settings; set up the query, and renders each post item.
214 235 * If no posts are found, it returns false. After rendering, it resets the query and returns the output.
215 236 *
216 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.
217 239 *
218 240 * @return string|false The rendered widget content or false if no posts are found.
219 - */
241 + */
220 242 public function render_ajax($current_query)
221 243 {
222 -
223 244 // Get settings and post type
224 245 $settings = $this->get_settings();
225 246 $loop = 0;
226 247
227 - $this->TRAIT_query_posts( $settings, $current_query );
248 + $this->TRAIT_query_posts($settings, $current_query);
228 249 $wp_query = $this->get_query();
229 250
230 - if (!$wp_query->have_posts()) {
231 - return false;
251 + if (!$wp_query || !$wp_query->have_posts()) {
252 + $markup = '';
232 253 }
233 254
234 255 \ob_start();
235 256 while ($wp_query->have_posts()) {
@@ -245,8 +266,11 @@
245 266 }
246 267
247 268 protected function render()
248 269 {
270 + // Get current post ID
271 + $post_id = get_the_ID();
272 +
249 273 // Get query args, settings and post type slug
250 274 global $wp_query;
251 275 $default_query = $wp_query;
252 276 $settings = $this->get_settings();
@@ -251,13 +275,11 @@
251 275 $default_query = $wp_query;
252 276 $settings = $this->get_settings();
253 277
254 278 // Build query
255 - $this->TRAIT_query_posts( $settings, $wp_query->query );
279 + $this->TRAIT_query_posts($settings, $wp_query->query);
256 280 $wp_query = $this->get_query();
257 281
258 - $this->TRAIT_set_meta_font_size_to_svg($settings); // SVG icon experiment font-size adjustment
259 -
260 282 // Store widget settings in a transient
261 283 $ID = strval($this->get_ID());
262 284 set_transient('ui_elements_widgetdata_' . $ID, $settings, \MONTH_IN_SECONDS);
263 285
@@ -265,9 +287,11 @@
265 287 $items = $settings['item_limit']['size'];
266 288 $loops = 0;
267 289
268 290 // Set masonry class
269 - $masonry = $settings['masonry'] === 'yes' ? 'ui-e-maso' : '';
291 + $masonry = $this->is_option('masonry', 'yes')
292 + ? 'ui-e-maso'
293 + : '';
270 294
271 295 $this->TRAIT_render_filters($settings);
272 296
273 297 // No posts found
@@ -274,41 +298,45 @@
274 298 if (!$wp_query->have_posts()) {
275 299 echo '<p style="text-align:center">' . esc_html__('No posts found.', 'uicore-elements') . '</p>';
276 300 } else {
277 301
278 - ?>
279 - <div class="ui-e-adv-grid <?php echo esc_attr($masonry);?>">
280 - <?php
281 - 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()) {
282 306
283 - // sticky posts disregards posts per page, so ending the loop if $items == $loop forces the query respects the users item limit
284 - if ($settings['sticky'] && $items == $loops) {
285 - break;
286 - }
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 + }
287 311
288 - $wp_query->the_post();
289 - $this->TRAIT_render_item($loops, false, true);
312 + $wp_query->the_post();
313 + $this->TRAIT_render_item($loops, false, true);
290 314
291 - $loops++;
292 - }
293 - ?>
294 - </div>
295 - <?php
315 + $loops++;
316 + }
317 + ?>
318 + </div>
319 +<?php
296 320
297 - $this->TRAIT_render_pagination($settings);
321 + $this->TRAIT_render_pagination($settings, $post_id);
298 322
299 - 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 + ) {
300 328
301 - // Build the public query args the ajax request script passes to rest api
302 - $public_query = array();
303 - $public_query['query']['post_type'] = get_post_type();
304 - $public_query['query_vars'] = $wp_query->query_vars;
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;
305 333
306 - echo '<script>';
307 - 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
308 - echo 'window.ui_query_' . esc_html($ID) . ' = ' . \json_encode($public_query) . ';';
309 - echo '</script>';
310 - }
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 + }
311 339 }
312 340
313 341 //reset query
314 342 wp_reset_query();