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