| 1 |
<?php |
| 2 |
|
| 3 |
namespace UltimateStoreKit\Modules\GlossyCarousel\Widgets; |
| 4 |
|
| 5 |
use Elementor\Controls_Manager; |
| 6 |
|
| 7 |
use Elementor\Group_Control_Border; |
| 8 |
use Elementor\Group_Control_Box_Shadow; |
| 9 |
use UltimateStoreKit\Base\Module_Base; |
| 10 |
use UltimateStoreKit\traits\Global_Widget_Controls; |
| 11 |
use UltimateStoreKit\traits\Global_Widget_Template; |
| 12 |
// use UltimateStoreKit\traits\Global_Swiper_Template; |
| 13 |
use UltimateStoreKit\Includes\Controls\GroupQuery\Group_Control_Query; |
| 14 |
use UltimateStoreKit\Templates\USK_Glossy_Grid_Template; |
| 15 |
use WP_Query; |
| 16 |
|
| 17 |
if (!defined('ABSPATH')) { |
| 18 |
exit; |
| 19 |
} |
| 20 |
|
| 21 |
// Exit if accessed directly |
| 22 |
|
| 23 |
class Glossy_Carousel extends Module_Base { |
| 24 |
use Global_Widget_Controls; |
| 25 |
use Global_Widget_Template; |
| 26 |
// use Global_Swiper_Template; |
| 27 |
use Group_Control_Query; |
| 28 |
|
| 29 |
/** |
| 30 |
* @var \WP_Query |
| 31 |
*/ |
| 32 |
private $_query = null; |
| 33 |
public function get_name() { |
| 34 |
return 'usk-glossy-carousel'; |
| 35 |
} |
| 36 |
|
| 37 |
public function get_title() { |
| 38 |
return esc_html__('Glossy Carousel', 'ultimate-store-kit'); |
| 39 |
} |
| 40 |
|
| 41 |
public function get_icon() { |
| 42 |
return 'usk-widget-icon usk-icon-glossy-carousel'; |
| 43 |
} |
| 44 |
|
| 45 |
public function get_categories() { |
| 46 |
return ['ultimate-store-kit']; |
| 47 |
} |
| 48 |
|
| 49 |
public function get_keywords() { |
| 50 |
return ['product', 'product-grid', 'table', 'wc']; |
| 51 |
} |
| 52 |
|
| 53 |
public function get_script_depends() { |
| 54 |
if ($this->usk_is_edit_mode()) { |
| 55 |
return ['swiper', 'micromodal', 'usk-site']; |
| 56 |
} else { |
| 57 |
return ['swiper', 'micromodal', 'usk-glossy-carousel']; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
public function get_style_depends() { |
| 62 |
if ($this->usk_is_edit_mode()) { |
| 63 |
return ['swiper', 'usk-all-styles']; |
| 64 |
} else { |
| 65 |
return ['swiper', 'usk-font', 'usk-glossy-carousel']; |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
public function get_custom_help_url() { |
| 70 |
return 'https://youtu.be/P9proLYapgQ'; |
| 71 |
} |
| 72 |
|
| 73 |
public function get_query() { |
| 74 |
return $this->_query; |
| 75 |
} |
| 76 |
public function has_widget_inner_wrapper(): bool { |
| 77 |
return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup'); |
| 78 |
} |
| 79 |
protected function register_controls() { |
| 80 |
|
| 81 |
$this->start_controls_section( |
| 82 |
'section_woocommerce_layout', |
| 83 |
[ |
| 84 |
'label' => esc_html__('Layout', 'ultimate-store-kit'), |
| 85 |
] |
| 86 |
); |
| 87 |
|
| 88 |
$this->add_responsive_control( |
| 89 |
'columns', |
| 90 |
[ |
| 91 |
'label' => esc_html__('Columns', 'ultimate-store-kit'), |
| 92 |
'type' => Controls_Manager::SELECT, |
| 93 |
'default' => 3, |
| 94 |
'tablet_default' => 2, |
| 95 |
'mobile_default' => 1, |
| 96 |
'options' => [ |
| 97 |
1 => '1', |
| 98 |
2 => '2', |
| 99 |
3 => '3', |
| 100 |
4 => '4', |
| 101 |
5 => '5', |
| 102 |
6 => '6', |
| 103 |
], |
| 104 |
] |
| 105 |
); |
| 106 |
$this->add_responsive_control( |
| 107 |
'items_gap', |
| 108 |
[ |
| 109 |
'label' => esc_html__('Item Gap', 'ultimate-store-kit'), |
| 110 |
'type' => Controls_Manager::SLIDER, |
| 111 |
'default' => [ |
| 112 |
'size' => 30, |
| 113 |
], |
| 114 |
'range' => [ |
| 115 |
'px' => [ |
| 116 |
'min' => 0, |
| 117 |
'max' => 100, |
| 118 |
], |
| 119 |
], |
| 120 |
'tablet_default' => [ |
| 121 |
'size' => 20, |
| 122 |
], |
| 123 |
'mobile_default' => [ |
| 124 |
'size' => 20, |
| 125 |
], |
| 126 |
] |
| 127 |
); |
| 128 |
$this->register_global_controls_grid_layout(); |
| 129 |
|
| 130 |
$this->end_controls_section(); |
| 131 |
$this->start_controls_section( |
| 132 |
'section_post_query_builder', |
| 133 |
[ |
| 134 |
'label' => __('Query', 'ultimate-store-kit'), |
| 135 |
'tab' => Controls_Manager::TAB_CONTENT, |
| 136 |
] |
| 137 |
); |
| 138 |
$this->register_query_builder_controls(); |
| 139 |
$this->register_controls_wc_additional(); |
| 140 |
$this->end_controls_section(); |
| 141 |
|
| 142 |
|
| 143 |
$this->register_global_controls_additional(); |
| 144 |
$this->register_global_controls_carousel_navigation(); |
| 145 |
$this->register_global_controls_carousel_settings(); |
| 146 |
$this->start_controls_section( |
| 147 |
'section_style_item', |
| 148 |
[ |
| 149 |
'label' => esc_html__('Items', 'ultimate-store-kit'), |
| 150 |
'tab' => Controls_Manager::TAB_STYLE, |
| 151 |
] |
| 152 |
); |
| 153 |
|
| 154 |
$this->start_controls_tabs('item_tabs'); |
| 155 |
|
| 156 |
$this->start_controls_tab( |
| 157 |
'item_tab_normal', |
| 158 |
[ |
| 159 |
'label' => esc_html__('Normal', 'ultimate-store-kit'), |
| 160 |
] |
| 161 |
); |
| 162 |
|
| 163 |
$this->add_group_control( |
| 164 |
Group_Control_Border::get_type(), |
| 165 |
[ |
| 166 |
'name' => 'item_border', |
| 167 |
'selector' => '{{WRAPPER}} .usk-glossy-carousel .usk-item', |
| 168 |
] |
| 169 |
); |
| 170 |
|
| 171 |
$this->add_responsive_control( |
| 172 |
'item_border_radius', |
| 173 |
[ |
| 174 |
'label' => esc_html__('Border Radius', 'ultimate-store-kit'), |
| 175 |
'type' => Controls_Manager::DIMENSIONS, |
| 176 |
'size_units' => ['px', '%', 'em'], |
| 177 |
'selectors' => [ |
| 178 |
'{{WRAPPER}} .usk-glossy-carousel .usk-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 179 |
], |
| 180 |
] |
| 181 |
); |
| 182 |
|
| 183 |
$this->add_responsive_control( |
| 184 |
'item_padding', |
| 185 |
[ |
| 186 |
'label' => esc_html__('Padding', 'ultimate-store-kit'), |
| 187 |
'type' => Controls_Manager::DIMENSIONS, |
| 188 |
'size_units' => ['px', '%', 'em'], |
| 189 |
'selectors' => [ |
| 190 |
'{{WRAPPER}} .usk-glossy-carousel .usk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 191 |
], |
| 192 |
] |
| 193 |
); |
| 194 |
|
| 195 |
$this->end_controls_tab(); |
| 196 |
|
| 197 |
$this->start_controls_tab( |
| 198 |
'item_tab_hover', |
| 199 |
[ |
| 200 |
'label' => esc_html__('Hover', 'ultimate-store-kit'), |
| 201 |
] |
| 202 |
); |
| 203 |
|
| 204 |
$this->add_control( |
| 205 |
'item_hover_border_color', |
| 206 |
[ |
| 207 |
'label' => esc_html__('Border Color', 'ultimate-store-kit'), |
| 208 |
'type' => Controls_Manager::COLOR, |
| 209 |
'selectors' => [ |
| 210 |
'{{WRAPPER}} .usk-glossy-carousel .usk-item:hover' => 'border-color: {{VALUE}}', |
| 211 |
], |
| 212 |
'condition' => [ |
| 213 |
'item_border_border!' => '', |
| 214 |
], |
| 215 |
] |
| 216 |
); |
| 217 |
$this->add_control( |
| 218 |
'item_box_shadow_color', |
| 219 |
[ |
| 220 |
'label' => esc_html__('Shadow Color', 'ultimate-store-kit'), |
| 221 |
'type' => Controls_Manager::COLOR, |
| 222 |
'selectors' => [ |
| 223 |
'{{WRAPPER}} .usk-glossy-carousel .usk-product-hover:before' => 'box-shadow: 0 8px 55px {{VALUE}}', |
| 224 |
], |
| 225 |
] |
| 226 |
); |
| 227 |
|
| 228 |
$this->add_control( |
| 229 |
'item_shape_color', |
| 230 |
[ |
| 231 |
'label' => esc_html__('Shape Color', 'ultimate-store-kit'), |
| 232 |
'type' => Controls_Manager::COLOR, |
| 233 |
'selectors' => [ |
| 234 |
'{{WRAPPER}} .usk-glossy-carousel .usk-product-hover:before' => 'background-color: {{VALUE}}', |
| 235 |
], |
| 236 |
] |
| 237 |
); |
| 238 |
|
| 239 |
$this->end_controls_tab(); |
| 240 |
$this->end_controls_tabs(); |
| 241 |
$this->end_controls_section(); |
| 242 |
$this->register_global_controls_grid_image(); |
| 243 |
$this->register_global_controls_content(); |
| 244 |
$this->register_global_controls_title(); |
| 245 |
$this->register_global_controls_price(); |
| 246 |
$this->register_global_controls_rating(); |
| 247 |
$this->register_global_controls_badge(); |
| 248 |
$this->register_global_controls_action_btn(); |
| 249 |
|
| 250 |
//Navigation Style Global Controls |
| 251 |
$this->register_global_controls_navigation_style(); |
| 252 |
} |
| 253 |
|
| 254 |
public function render_loop_item() { |
| 255 |
$settings = $this->get_settings_for_display(); |
| 256 |
$this->query_product(); |
| 257 |
$wp_query = $this->get_query(); |
| 258 |
if ($wp_query->have_posts()) : |
| 259 |
while ($wp_query->have_posts()) : $wp_query->the_post(); |
| 260 |
global $product; |
| 261 |
$template = new USK_Glossy_Grid_Template($settings, 'glossy-carousel'); |
| 262 |
$template->render_glossy_grid_item($product, $settings); |
| 263 |
endwhile; |
| 264 |
wp_reset_postdata(); |
| 265 |
else : |
| 266 |
echo '<div class="usk-alert-warning" usk-alert>' . esc_html__('Ops! There no product to display.', 'ultimate-store-kit') . '</div>'; |
| 267 |
endif; |
| 268 |
} |
| 269 |
|
| 270 |
public function render() { |
| 271 |
$this->register_global_template_carousel_header(); |
| 272 |
$this->render_loop_item(); |
| 273 |
$this->usk_register_global_template_carousel_footer(); |
| 274 |
} |
| 275 |
public function query_product() { |
| 276 |
$default = $this->getGroupControlQueryArgs(); |
| 277 |
$this->_query = $this->build_query_from_args($default); |
| 278 |
} |
| 279 |
} |
| 280 |
|