| @@ -45,12 +45,19 @@ | ||
| 45 | 45 | public function get_styles() |
| 46 | 46 | { |
| 47 | 47 | $styles = [ |
| 48 | 48 | 'advanced-post-carousel', |
| 49 | + 'carousel', | |
| 50 | + 'post-meta', | |
| 51 | + 'filters' => [ | |
| 52 | + 'condition' => [ | |
| 53 | + 'post_filtering' => 'yes', | |
| 54 | + ] | |
| 55 | + ], | |
| 49 | 56 | 'animation', // hover animations |
| 50 | 57 | 'entrance', // entrance basic style |
| 51 | 58 | ]; |
| 52 | - if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){ | |
| 59 | + if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) { | |
| 53 | 60 | $styles['e-animations'] = [ // entrance animations |
| 54 | 61 | 'external' => true, |
| 55 | 62 | ]; |
| 56 | 63 | } |
| @@ -57,10 +64,15 @@ | ||
| 57 | 64 | return $styles; |
| 58 | 65 | } |
| 59 | 66 | public function get_scripts() |
| 60 | 67 | { |
| 61 | - return $this->TRAIT_get_scripts(); | |
| 68 | + return $this->TRAIT_get_carousel_scripts(); | |
| 62 | 69 | } |
| 70 | + public function has_widget_inner_wrapper(): bool | |
| 71 | + { | |
| 72 | + // TODO: remove after Optmized Markup experiment is merged to the core | |
| 73 | + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup'); | |
| 74 | + } | |
| 63 | 75 | |
| 64 | 76 | private function filter_missing_taxonomies($settings) |
| 65 | 77 | { |
| 66 | 78 | $taxonomy_filter_args = [ |
| @@ -73,10 +85,10 @@ | ||
| 73 | 85 | $taxonomies = get_taxonomies($taxonomy_filter_args, 'objects'); |
| 74 | 86 | |
| 75 | 87 | foreach ($taxonomies as $taxonomy => $object) { |
| 76 | 88 | $controll_id = 'posts-filter_' . $taxonomy . '_ids'; |
| 77 | - \error_log($controll_id); | |
| 78 | - \error_log(print_r($settings[$controll_id], true)); | |
| 89 | + //error_log($controll_id); | |
| 90 | + //error_log(print_r($settings[$controll_id], true)); | |
| 79 | 91 | |
| 80 | 92 | if (!isset($settings[$controll_id]) || empty($settings[$controll_id])) { |
| 81 | 93 | continue; |
| 82 | 94 | } |
| @@ -112,18 +124,18 @@ | ||
| 112 | 124 | [ |
| 113 | 125 | 'label' => esc_html__('Carousel', 'uicore-elements'), |
| 114 | 126 | ] |
| 115 | 127 | ); |
| 116 | - $this->TRAIT_register_carousel_additional_controls(); // Grid Layouts with old masonry control | |
| 128 | + $this->TRAIT_register_carousel_additional_controls(); // Grid Layouts with old masonry control | |
| 117 | 129 | $this->end_controls_section(); |
| 118 | 130 | |
| 119 | 131 | $this->start_controls_section( |
| 120 | - 'section_carousel_settings', | |
| 121 | - [ | |
| 122 | - 'label' => __('Carousel Settings', 'uicore-elements'), | |
| 123 | - ] | |
| 124 | - ); | |
| 125 | - $this->TRAIT_register_carousel_settings_controls(); // Carousel settings | |
| 132 | + 'section_carousel_settings', | |
| 133 | + [ | |
| 134 | + 'label' => __('Carousel Settings', 'uicore-elements'), | |
| 135 | + ] | |
| 136 | + ); | |
| 137 | + $this->TRAIT_register_carousel_settings_controls(); // Carousel settings | |
| 126 | 138 | $this->end_controls_section(); |
| 127 | 139 | |
| 128 | 140 | $this->TRAIT_register_navigation_controls(); |
| 129 | 141 | $this->TRAIT_register_post_item_controls(); |
| @@ -146,19 +158,19 @@ | ||
| 146 | 158 | 'label' => __('Animations', 'uicore-elements'), |
| 147 | 159 | 'tab' => Controls_Manager::TAB_STYLE, |
| 148 | 160 | ] |
| 149 | 161 | ); |
| 150 | - $this->TRAIT_register_entrance_animations_controls(); | |
| 151 | - $this->TRAIT_register_hover_animation_control( | |
| 152 | - 'Item Hover Animation', | |
| 153 | - [], | |
| 154 | - ['underline'], | |
| 155 | - ); | |
| 156 | - $this->TRAIT_register_post_animation_controls(); | |
| 162 | + $this->TRAIT_register_entrance_animations_controls(); | |
| 163 | + $this->TRAIT_register_hover_animation_control( | |
| 164 | + 'Item Hover Animation', | |
| 165 | + [], | |
| 166 | + ['underline'], | |
| 167 | + ); | |
| 168 | + $this->TRAIT_register_post_animation_controls(); | |
| 157 | 169 | $this->end_controls_section(); |
| 158 | 170 | |
| 159 | 171 | // Update post component controls |
| 160 | - $this->update_control('image_size', [ | |
| 172 | + $this->update_responsive_control('image_size', [ | |
| 161 | 173 | 'condition' => [], |
| 162 | 174 | ]); |
| 163 | 175 | $this->update_control('content_padding', [ |
| 164 | 176 | 'default' => [ |
| @@ -170,55 +182,70 @@ | ||
| 170 | 182 | ], |
| 171 | 183 | ]); |
| 172 | 184 | $this->update_control('item_limit', [ |
| 173 | 185 | 'default' => [ |
| 174 | - 'size' => 5, | |
| 186 | + 'size' => 4, | |
| 175 | 187 | ], |
| 176 | 188 | ]); |
| 189 | + | |
| 190 | + // TODO: create new method to return animations list and use it throughout the plugin | |
| 191 | + // Update carousel animations | |
| 192 | + $this->update_control('animation_style', [ | |
| 193 | + 'options' => [ | |
| 194 | + 'circular' => esc_html__('Circular', 'uicore-elements'), | |
| 195 | + 'fade_blur' => esc_html__('Fade Blur', 'uicore-elements'), | |
| 196 | + 'default' => esc_html__('Default', 'uicore-elements'), | |
| 197 | + ], | |
| 198 | + ]); | |
| 177 | 199 | } |
| 178 | 200 | |
| 179 | - function content_template() | |
| 180 | - { | |
| 181 | - } | |
| 201 | + function content_template() {} | |
| 182 | 202 | |
| 183 | 203 | protected function render() |
| 184 | 204 | { |
| 185 | - | |
| 186 | - // Get query args and widget settings | |
| 205 | + // Get query args, settings and post type slug | |
| 187 | 206 | global $wp_query; |
| 188 | 207 | $default_query = $wp_query; |
| 189 | 208 | $settings = $this->get_settings(); |
| 190 | - $this->TRAIT_query_posts( $settings ); | |
| 191 | - $wp_query = $this->get_query(); | |
| 192 | 209 | |
| 193 | 210 | // Get the quantity of items and creates a loop control |
| 194 | 211 | $items = $settings['item_limit']['size']; |
| 195 | 212 | $loops = 0; |
| 196 | 213 | |
| 197 | - $this->TRAIT_render_filters(); | |
| 214 | + $this->TRAIT_render_center_loop_warning($items); | |
| 198 | 215 | |
| 216 | + // Build query | |
| 217 | + $this->TRAIT_query_posts($settings, $wp_query->query); | |
| 218 | + $wp_query = $this->get_query(); | |
| 219 | + | |
| 220 | + $this->TRAIT_render_filters($settings); | |
| 221 | + | |
| 199 | 222 | // No posts found |
| 200 | 223 | if (!$wp_query->have_posts()) { |
| 201 | - echo '<p style="text-align:center">' . __('No posts found.', 'uicore-elements') . '</p>'; | |
| 224 | + echo '<p style="text-align:center">' . esc_html__('No posts found.', 'uicore-elements') . '</p>'; | |
| 202 | 225 | } else { |
| 203 | 226 | |
| 204 | - ?> | |
| 227 | +?> | |
| 205 | 228 | <div class="ui-e-carousel swiper"> |
| 206 | 229 | <div class='swiper-wrapper'> |
| 207 | 230 | <?php |
| 208 | 231 | while ($wp_query->have_posts()) { |
| 209 | - if ($settings['sticky'] && $items == $loops) { | |
| 210 | - break; // sticky posts disregards posts per page, so ending the loop if $items == $loop forces the query respects the users item limit | |
| 211 | - } | |
| 232 | + | |
| 233 | + // sticky posts disregards posts per page, so ending the loop if $items == $loop forces the query respects the users item limit | |
| 234 | + // if ($settings['sticky'] && $items == $loops) { | |
| 235 | + // break; | |
| 236 | + // } | |
| 237 | + | |
| 212 | 238 | $wp_query->the_post(); |
| 213 | - $this->TRAIT_render_item(true); | |
| 239 | + $this->TRAIT_render_item($loops, true); | |
| 240 | + | |
| 214 | 241 | $loops++; |
| 215 | 242 | } |
| 216 | 243 | ?> |
| 217 | 244 | </div> |
| 218 | - <?php $this->TRAIT_render_carousel_navigations(); ?> | |
| 219 | 245 | </div> |
| 220 | - <?php | |
| 246 | + <?php $this->TRAIT_render_carousel_navigations($items); ?> | |
| 247 | +<?php | |
| 221 | 248 | } |
| 222 | 249 | |
| 223 | 250 | //reset query |
| 224 | 251 | wp_reset_query(); |