| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * Elementor Classes. |
|---|
| 4 | * |
|---|
| 5 | * @package CoWidgets |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | namespace COWIDGETS\WidgetsManager\Widgets; |
|---|
| 9 | |
|---|
| 10 | use Elementor\Controls_Manager; |
|---|
| 11 | use Elementor\Utils; |
|---|
| 12 | use Elementor\Group_Control_Typography; |
|---|
| 13 | use Elementor\Core\Schemes\Typography; |
|---|
| 14 | use Elementor\Core\Schemes\Color; |
|---|
| 15 | use Elementor\Widget_Base; |
|---|
| 16 | use Elementor\Group_Control_Image_Size; |
|---|
| 17 | |
|---|
| 18 | if ( ! defined( 'ABSPATH' ) ) { |
|---|
| 19 | exit; // Exit if accessed directly. |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | /** |
|---|
| 23 | * Elementor Staff Carousel |
|---|
| 24 | * |
|---|
| 25 | * Elementor widget for Staff Carousel. |
|---|
| 26 | * |
|---|
| 27 | * @since 1.0.0 |
|---|
| 28 | */ |
|---|
| 29 | class Staff_Carousel extends Widget_Base { |
|---|
| 30 | |
|---|
| 31 | /** |
|---|
| 32 | * Retrieve the widget name. |
|---|
| 33 | * |
|---|
| 34 | * @since 1.0.0 |
|---|
| 35 | * |
|---|
| 36 | * @access public |
|---|
| 37 | * |
|---|
| 38 | * @return string Widget name. |
|---|
| 39 | */ |
|---|
| 40 | public function get_name() { |
|---|
| 41 | return 'ce-staff-carousel'; |
|---|
| 42 | } |
|---|
| 43 | /** |
|---|
| 44 | * Retrieve the widget title. |
|---|
| 45 | * |
|---|
| 46 | * @since 1.0.0 |
|---|
| 47 | * |
|---|
| 48 | * @access public |
|---|
| 49 | * |
|---|
| 50 | * @return string Widget title. |
|---|
| 51 | */ |
|---|
| 52 | public function get_title() { |
|---|
| 53 | return __( 'Staff Carousel', 'cowidgets' ); |
|---|
| 54 | } |
|---|
| 55 | /** |
|---|
| 56 | * Retrieve the widget icon. |
|---|
| 57 | * |
|---|
| 58 | * @since 1.0.0 |
|---|
| 59 | * |
|---|
| 60 | * @access public |
|---|
| 61 | * |
|---|
| 62 | * @return string Widget icon. |
|---|
| 63 | */ |
|---|
| 64 | public function get_icon() { |
|---|
| 65 | return 'ce-icon-staff-carousel'; |
|---|
| 66 | } |
|---|
| 67 | /** |
|---|
| 68 | * Retrieve the list of categories the widget belongs to. |
|---|
| 69 | * |
|---|
| 70 | * Used to determine where to display the widget in the editor. |
|---|
| 71 | * |
|---|
| 72 | * Note that currently Elementor supports only one category. |
|---|
| 73 | * When multiple categories passed, Elementor uses the first one. |
|---|
| 74 | * |
|---|
| 75 | * @since 1.0.0 |
|---|
| 76 | * |
|---|
| 77 | * @access public |
|---|
| 78 | * |
|---|
| 79 | * @return array Widget categories. |
|---|
| 80 | */ |
|---|
| 81 | public function get_categories() { |
|---|
| 82 | return [ 'ce-content-widgets' ]; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | public function get_script_depends() { |
|---|
| 86 | return [ 'ce-staff-carousel', 'tiny-slider' ]; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | public function get_style_depends() { |
|---|
| 90 | return [ 'tiny-slider' ]; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | /** |
|---|
| 94 | * Register controls. |
|---|
| 95 | * |
|---|
| 96 | * @since 1.0.0 |
|---|
| 97 | * @access protected |
|---|
| 98 | */ |
|---|
| 99 | protected function register_controls() { |
|---|
| 100 | $this->register_staff_carousel_controls(); |
|---|
| 101 | } |
|---|
| 102 | /** |
|---|
| 103 | * Register General Controls. |
|---|
| 104 | * |
|---|
| 105 | * @since 1.0.0 |
|---|
| 106 | * @access protected |
|---|
| 107 | */ |
|---|
| 108 | protected function register_staff_carousel_controls() { |
|---|
| 109 | \COWIDGETS_Helpers::staffSelectionSection( $this ); |
|---|
| 110 | $this->start_controls_section( |
|---|
| 111 | 'section_content_style', |
|---|
| 112 | [ |
|---|
| 113 | 'label' => __( 'Item Layout/Style', 'cowidgets' ), |
|---|
| 114 | 'tab' => Controls_Manager::TAB_CONTENT, |
|---|
| 115 | ] |
|---|
| 116 | ); |
|---|
| 117 | |
|---|
| 118 | $this->add_control( |
|---|
| 119 | 'item_style', |
|---|
| 120 | [ |
|---|
| 121 | 'label' => __( 'Style', 'cowidgets' ), |
|---|
| 122 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 123 | 'default' => 'default', |
|---|
| 124 | 'options' => apply_filters( 'ce_load_element_styles', [ |
|---|
| 125 | 'default' => __( 'Default', 'cowidgets' ), |
|---|
| 126 | 'beas' => __( 'Beas', 'cowidgets' ), |
|---|
| 127 | 'modern' => __( 'modern', 'cowidgets' ), |
|---|
| 128 | ] ), |
|---|
| 129 | ] |
|---|
| 130 | ); |
|---|
| 131 | |
|---|
| 132 | $this->add_group_control( |
|---|
| 133 | Group_Control_Image_Size::get_type(), |
|---|
| 134 | [ |
|---|
| 135 | 'name' => 'image_size', |
|---|
| 136 | 'label' => __( 'Image Size', 'cowidgets' ), |
|---|
| 137 | 'default' => 'full', |
|---|
| 138 | ] |
|---|
| 139 | ); |
|---|
| 140 | |
|---|
| 141 | $this->add_control( |
|---|
| 142 | 'columns', |
|---|
| 143 | [ |
|---|
| 144 | 'label' => __( 'Columns', 'cowidgets' ), |
|---|
| 145 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 146 | 'default' => '2', |
|---|
| 147 | 'options' => [ |
|---|
| 148 | 1 => __( '1', 'cowidgets' ), |
|---|
| 149 | 2 => __( '2', 'cowidgets' ), |
|---|
| 150 | 3 => __( '3', 'cowidgets' ), |
|---|
| 151 | 4 => __( '4', 'cowidgets' ), |
|---|
| 152 | 5 => __( '5', 'cowidgets' ), |
|---|
| 153 | 6 => __( '6', 'cowidgets' ), |
|---|
| 154 | 7 => __( '7', 'cowidgets' ), |
|---|
| 155 | ], |
|---|
| 156 | 'render_type' => 'template' |
|---|
| 157 | ] |
|---|
| 158 | ); |
|---|
| 159 | |
|---|
| 160 | $this->end_controls_section(); |
|---|
| 161 | |
|---|
| 162 | $this->start_controls_section( |
|---|
| 163 | 'section_content_carousel', |
|---|
| 164 | [ |
|---|
| 165 | 'label' => __( 'Carousel Options', 'cowidgets' ), |
|---|
| 166 | 'tab' => Controls_Manager::TAB_CONTENT, |
|---|
| 167 | ] |
|---|
| 168 | ); |
|---|
| 169 | |
|---|
| 170 | $this->add_control( |
|---|
| 171 | 'slide_by', |
|---|
| 172 | [ |
|---|
| 173 | 'label' => __( 'Slide By', 'cowidgets' ), |
|---|
| 174 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 175 | 'default' => 1, |
|---|
| 176 | 'options' => [ |
|---|
| 177 | '1' => __( '1', 'cowidgets' ), |
|---|
| 178 | 'page' => __( 'Page', 'cowidgets' ), |
|---|
| 179 | ], |
|---|
| 180 | ] |
|---|
| 181 | ); |
|---|
| 182 | |
|---|
| 183 | $this->add_control( |
|---|
| 184 | 'mode', |
|---|
| 185 | [ |
|---|
| 186 | 'label' => __( 'Mode', 'cowidgets' ), |
|---|
| 187 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 188 | 'default' => 'carousel', |
|---|
| 189 | 'options' => [ |
|---|
| 190 | 'carousel' => __( 'Carousel', 'cowidgets' ), |
|---|
| 191 | 'gallery' => __( 'Gallery', 'cowidgets' ), |
|---|
| 192 | ], |
|---|
| 193 | ] |
|---|
| 194 | ); |
|---|
| 195 | |
|---|
| 196 | $this->add_control( |
|---|
| 197 | 'autoplay', |
|---|
| 198 | [ |
|---|
| 199 | 'label' => __( 'Autoplay', 'cowidgets' ), |
|---|
| 200 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 201 | 'default' => 0, |
|---|
| 202 | 'options' => [ |
|---|
| 203 | 0 => __( 'No', 'cowidgets' ), |
|---|
| 204 | 1 => __( 'Yes', 'cowidgets' ), |
|---|
| 205 | ], |
|---|
| 206 | ] |
|---|
| 207 | ); |
|---|
| 208 | |
|---|
| 209 | $this->add_control( |
|---|
| 210 | 'loop', |
|---|
| 211 | [ |
|---|
| 212 | 'label' => __( 'Loop', 'cowidgets' ), |
|---|
| 213 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 214 | 'default' => 0, |
|---|
| 215 | 'options' => [ |
|---|
| 216 | 0 => __( 'No', 'cowidgets' ), |
|---|
| 217 | 1 => __( 'Yes', 'cowidgets' ), |
|---|
| 218 | ], |
|---|
| 219 | ] |
|---|
| 220 | ); |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | |
|---|
| 224 | $this->add_control( |
|---|
| 225 | 'center', |
|---|
| 226 | [ |
|---|
| 227 | 'label' => __( 'Center', 'cowidgets' ), |
|---|
| 228 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 229 | 'default' => 0, |
|---|
| 230 | 'options' => [ |
|---|
| 231 | 0 => __( 'No', 'cowidgets' ), |
|---|
| 232 | 1 => __( 'Yes', 'cowidgets' ), |
|---|
| 233 | ], |
|---|
| 234 | ] |
|---|
| 235 | ); |
|---|
| 236 | |
|---|
| 237 | $this->add_control( |
|---|
| 238 | 'mouse_drag', |
|---|
| 239 | [ |
|---|
| 240 | 'label' => __( 'Mouse Drag', 'cowidgets' ), |
|---|
| 241 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 242 | 'default' => 1, |
|---|
| 243 | 'options' => [ |
|---|
| 244 | 0 => __( 'No', 'cowidgets' ), |
|---|
| 245 | 1 => __( 'Yes', 'cowidgets' ), |
|---|
| 246 | ], |
|---|
| 247 | ] |
|---|
| 248 | ); |
|---|
| 249 | |
|---|
| 250 | $this->add_control( |
|---|
| 251 | 'carousel_controls', |
|---|
| 252 | [ |
|---|
| 253 | 'label' => __( 'Prev/Next Buttons', 'cowidgets' ), |
|---|
| 254 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 255 | 'default' => 0, |
|---|
| 256 | 'options' => [ |
|---|
| 257 | 0 => __( 'No', 'cowidgets' ), |
|---|
| 258 | 1 => __( 'Yes', 'cowidgets' ), |
|---|
| 259 | ], |
|---|
| 260 | ] |
|---|
| 261 | ); |
|---|
| 262 | |
|---|
| 263 | $this->add_control( |
|---|
| 264 | 'vertical_align', |
|---|
| 265 | [ |
|---|
| 266 | 'label' => __( 'Items Vertical Align', 'cowidgets' ), |
|---|
| 267 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 268 | 'default' => 'top', |
|---|
| 269 | 'options' => [ |
|---|
| 270 | 'top' => __( 'Top', 'cowidgets' ), |
|---|
| 271 | 'middle' => __( 'Middle', 'cowidgets' ), |
|---|
| 272 | 'bottom' => __( 'Bottom', 'cowidgets' ), |
|---|
| 273 | ], |
|---|
| 274 | 'selectors' => [ |
|---|
| 275 | '{{WRAPPER}} .ce-staff-carousel .tns-item' => 'vertical-align: {{VALUE}}', |
|---|
| 276 | ], |
|---|
| 277 | |
|---|
| 278 | 'render_type' => 'template' |
|---|
| 279 | ] |
|---|
| 280 | ); |
|---|
| 281 | |
|---|
| 282 | $this->add_control( |
|---|
| 283 | 'start_index', |
|---|
| 284 | [ |
|---|
| 285 | 'label' => __( 'Start Index', 'cowidgets' ), |
|---|
| 286 | 'type' => \Elementor\Controls_Manager::TEXT, |
|---|
| 287 | 'default' => '0', |
|---|
| 288 | ] |
|---|
| 289 | ); |
|---|
| 290 | |
|---|
| 291 | $this->add_control( |
|---|
| 292 | 'gutter', |
|---|
| 293 | [ |
|---|
| 294 | 'label' => __( 'Space between items', 'cowidgets' ), |
|---|
| 295 | 'type' => Controls_Manager::SLIDER, |
|---|
| 296 | 'size_units' => ['px'], |
|---|
| 297 | 'range' => [ |
|---|
| 298 | 'px' => [ |
|---|
| 299 | 'max' => 500, |
|---|
| 300 | 'min' => 0, |
|---|
| 301 | ], |
|---|
| 302 | ], |
|---|
| 303 | 'default' => [ |
|---|
| 304 | 'size' => 15, |
|---|
| 305 | 'unit' => 'px', |
|---|
| 306 | ], |
|---|
| 307 | 'render_type' => 'template', |
|---|
| 308 | ] |
|---|
| 309 | ); |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | $this->add_control( |
|---|
| 314 | 'edge_padding', |
|---|
| 315 | [ |
|---|
| 316 | 'label' => __( 'Space on the outside', 'cowidgets' ), |
|---|
| 317 | 'type' => Controls_Manager::SLIDER, |
|---|
| 318 | 'size_units' => ['px'], |
|---|
| 319 | 'range' => [ |
|---|
| 320 | 'px' => [ |
|---|
| 321 | 'max' => 500, |
|---|
| 322 | 'min' => 0, |
|---|
| 323 | ], |
|---|
| 324 | ], |
|---|
| 325 | 'default' => [], |
|---|
| 326 | 'render_type' => 'template', |
|---|
| 327 | ] |
|---|
| 328 | ); |
|---|
| 329 | |
|---|
| 330 | $this->add_control( |
|---|
| 331 | 'edge_padding_side', |
|---|
| 332 | [ |
|---|
| 333 | 'label' => __( 'Space on the outside only one side', 'cowidgets' ), |
|---|
| 334 | 'type' => \Elementor\Controls_Manager::SELECT, |
|---|
| 335 | 'default' => 0, |
|---|
| 336 | 'options' => [ |
|---|
| 337 | 0 => __( 'No', 'cowidgets' ), |
|---|
| 338 | 1 => __( 'Yes', 'cowidgets' ), |
|---|
| 339 | ], |
|---|
| 340 | ] |
|---|
| 341 | ); |
|---|
| 342 | |
|---|
| 343 | $this->end_controls_section(); |
|---|
| 344 | |
|---|
| 345 | $this->start_controls_section( |
|---|
| 346 | 'section_style', |
|---|
| 347 | [ |
|---|
| 348 | 'label' => __( 'Global', 'cowidgets' ), |
|---|
| 349 | 'tab' => Controls_Manager::TAB_STYLE |
|---|
| 350 | ] |
|---|
| 351 | ); |
|---|
| 352 | |
|---|
| 353 | $this->add_control( |
|---|
| 354 | 'global_important_note', |
|---|
| 355 | [ |
|---|
| 356 | 'type' => \Elementor\Controls_Manager::RAW_HTML, |
|---|
| 357 | 'raw' => __( 'This section contains global styling options of this element. Some of this options should not work on specific selected styles. Please check the section below for style-specific options.', 'cowidgets' ), |
|---|
| 358 | 'content_classes' => 'important_note' |
|---|
| 359 | ] |
|---|
| 360 | ); |
|---|
| 361 | |
|---|
| 362 | $this->add_group_control( |
|---|
| 363 | \Elementor\Group_Control_Typography::get_type(), |
|---|
| 364 | [ |
|---|
| 365 | 'name' => 'staff_name_typography', |
|---|
| 366 | 'label' => __( 'Staff Name Typography', 'plugin-domain' ), |
|---|
| 367 | 'scheme' => Typography::TYPOGRAPHY_1, |
|---|
| 368 | 'selector' => '{{WRAPPER}} .ce-staff-item .team-name', |
|---|
| 369 | ] |
|---|
| 370 | ); |
|---|
| 371 | |
|---|
| 372 | $this->add_control( |
|---|
| 373 | 'item_title_color', |
|---|
| 374 | [ |
|---|
| 375 | 'label' => __( 'Staff Name Color', 'cowidgets' ), |
|---|
| 376 | 'type' => \Elementor\Controls_Manager::COLOR, |
|---|
| 377 | |
|---|
| 378 | 'selectors' => [ |
|---|
| 379 | '{{WRAPPER}} .ce-staff-item .team-name' => 'color: {{VALUE}}', |
|---|
| 380 | ], |
|---|
| 381 | ] |
|---|
| 382 | ); |
|---|
| 383 | |
|---|
| 384 | |
|---|
| 385 | $this->add_group_control( |
|---|
| 386 | \Elementor\Group_Control_Typography::get_type(), |
|---|
| 387 | [ |
|---|
| 388 | 'name' => 'staff_position_typography', |
|---|
| 389 | 'label' => __( 'Staff Work Position Typography', 'plugin-domain' ), |
|---|
| 390 | 'scheme' => Typography::TYPOGRAPHY_1, |
|---|
| 391 | 'selector' => '{{WRAPPER}} .ce-staff-item .team-position', |
|---|
| 392 | ] |
|---|
| 393 | ); |
|---|
| 394 | |
|---|
| 395 | $this->add_control( |
|---|
| 396 | 'staff_position_color', |
|---|
| 397 | [ |
|---|
| 398 | 'label' => __( 'Staff Work Position Color', 'cowidgets' ), |
|---|
| 399 | 'type' => \Elementor\Controls_Manager::COLOR, |
|---|
| 400 | |
|---|
| 401 | 'selectors' => [ |
|---|
| 402 | '{{WRAPPER}} .ce-staff-item .team-position' => 'color: {{VALUE}}', |
|---|
| 403 | ], |
|---|
| 404 | ] |
|---|
| 405 | ); |
|---|
| 406 | |
|---|
| 407 | $this->add_control( |
|---|
| 408 | 'staff_social_color', |
|---|
| 409 | [ |
|---|
| 410 | 'label' => __( 'Staff Socials Color', 'cowidgets' ), |
|---|
| 411 | 'type' => \Elementor\Controls_Manager::COLOR, |
|---|
| 412 | |
|---|
| 413 | 'selectors' => [ |
|---|
| 414 | '{{WRAPPER}} .ce-staff-item .team-socials a' => 'color: {{VALUE}}', |
|---|
| 415 | ], |
|---|
| 416 | ] |
|---|
| 417 | ); |
|---|
| 418 | |
|---|
| 419 | |
|---|
| 420 | $this->end_controls_section(); |
|---|
| 421 | |
|---|
| 422 | $this->start_controls_section( |
|---|
| 423 | 'section_specific_style', |
|---|
| 424 | [ |
|---|
| 425 | 'label' => __( 'Style-specific', 'cowidgets' ), |
|---|
| 426 | 'tab' => Controls_Manager::TAB_STYLE, |
|---|
| 427 | ] |
|---|
| 428 | ); |
|---|
| 429 | |
|---|
| 430 | $this->add_control( |
|---|
| 431 | 'specific_important_note', |
|---|
| 432 | [ |
|---|
| 433 | 'type' => \Elementor\Controls_Manager::RAW_HTML, |
|---|
| 434 | 'raw' => __( 'This section contains style-specific options, these options may disappear when you change selected item-style', 'cowidgets' ), |
|---|
| 435 | 'content_classes' => 'important_note' |
|---|
| 436 | ] |
|---|
| 437 | ); |
|---|
| 438 | |
|---|
| 439 | do_action( 'ce_load_style_specific_options', $this ); |
|---|
| 440 | |
|---|
| 441 | $this->add_control( |
|---|
| 442 | 'separator_color', |
|---|
| 443 | [ |
|---|
| 444 | 'label' => __( 'Separator Color', 'cowidgets' ), |
|---|
| 445 | 'type' => \Elementor\Controls_Manager::COLOR, |
|---|
| 446 | |
|---|
| 447 | 'selectors' => [ |
|---|
| 448 | '{{WRAPPER}} .ce-staff-item .data' => 'border-color: {{VALUE}}', |
|---|
| 449 | ], |
|---|
| 450 | 'condition' => [ |
|---|
| 451 | 'item_style' => 'beas' |
|---|
| 452 | ] |
|---|
| 453 | ] |
|---|
| 454 | ); |
|---|
| 455 | |
|---|
| 456 | $this->add_control( |
|---|
| 457 | 'quote_color', |
|---|
| 458 | [ |
|---|
| 459 | 'label' => __( 'Quote SVG Color', 'cowidgets' ), |
|---|
| 460 | 'type' => \Elementor\Controls_Manager::COLOR, |
|---|
| 461 | |
|---|
| 462 | 'selectors' => [ |
|---|
| 463 | '{{WRAPPER}} .ce-staff-item svg path' => 'fill: {{VALUE}}', |
|---|
| 464 | ], |
|---|
| 465 | 'condition' => [ |
|---|
| 466 | 'item_style' => 'beas' |
|---|
| 467 | ] |
|---|
| 468 | ] |
|---|
| 469 | ); |
|---|
| 470 | |
|---|
| 471 | $this->add_control( |
|---|
| 472 | 'nav_item_color', |
|---|
| 473 | [ |
|---|
| 474 | 'label' => __( 'Prev/Next Color', 'cowidgets' ), |
|---|
| 475 | 'type' => \Elementor\Controls_Manager::COLOR, |
|---|
| 476 | |
|---|
| 477 | 'selectors' => [ |
|---|
| 478 | '{{WRAPPER}} .ce-staff-item .ce-staff-carousel-controls a' => 'color: {{VALUE}}', |
|---|
| 479 | ], |
|---|
| 480 | 'condition' => [ |
|---|
| 481 | 'item_style' => 'beas' |
|---|
| 482 | ] |
|---|
| 483 | ] |
|---|
| 484 | ); |
|---|
| 485 | |
|---|
| 486 | |
|---|
| 487 | $this->end_controls_section(); |
|---|
| 488 | |
|---|
| 489 | \COWIDGETS_Helpers::animationSection( $this ); |
|---|
| 490 | } |
|---|
| 491 | |
|---|
| 492 | function set_source_type( $source ){ |
|---|
| 493 | $this->source_type = $source; |
|---|
| 494 | } |
|---|
| 495 | |
|---|
| 496 | function get_source_type(){ |
|---|
| 497 | return $this->source_type; |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | /** |
|---|
| 501 | * Render Copyright output on the frontend. |
|---|
| 502 | * |
|---|
| 503 | * Written in PHP and used to generate the final HTML. |
|---|
| 504 | * |
|---|
| 505 | * @since 1.0.0 |
|---|
| 506 | * @access protected |
|---|
| 507 | */ |
|---|
| 508 | protected function render() { |
|---|
| 509 | $settings = $this->get_settings_for_display(); |
|---|
| 510 | |
|---|
| 511 | $this->set_source_type( $settings['source_type'] ); |
|---|
| 512 | |
|---|
| 513 | $this->add_render_attribute( 'ce-staff-carousel', 'class', [ 'ce-staff-carousel', 'ce-staff-style-' . $settings['item_style'] ] ); |
|---|
| 514 | $this->add_render_attribute( 'ce-staff-carousel', 'data-columns', $settings['columns'] ); |
|---|
| 515 | $this->add_render_attribute( 'ce-staff-carousel', 'data-autoplay', $settings['autoplay'] ); |
|---|
| 516 | $this->add_render_attribute( 'ce-staff-carousel', 'data-slide-by', ( $settings['slide_by'] == 'page' ? $settings['columns'] : $settings['slide_by'] ) ); |
|---|
| 517 | $this->add_render_attribute( 'ce-staff-carousel', 'data-loop', $settings['loop'] ); |
|---|
| 518 | $this->add_render_attribute( 'ce-staff-carousel', 'data-gutter', $settings['gutter']['size'] ); |
|---|
| 519 | $this->add_render_attribute( 'ce-staff-carousel', 'data-center', $settings['center'] ); |
|---|
| 520 | $this->add_render_attribute( 'ce-staff-carousel', 'data-mode', $settings['mode'] ); |
|---|
| 521 | $this->add_render_attribute( 'ce-staff-carousel', 'data-mouse-drag', $settings['mouse_drag'] ); |
|---|
| 522 | $this->add_render_attribute( 'ce-staff-carousel', 'data-edge-padding-side', $settings['edge_padding_side'] ); |
|---|
| 523 | $this->add_render_attribute( 'ce-staff-carousel', 'data-carousel-controls', $settings['carousel_controls'] ); |
|---|
| 524 | |
|---|
| 525 | $this->add_render_attribute( 'ce-staff-item', 'class', ['ce-staff-item'] ); |
|---|
| 526 | |
|---|
| 527 | if( $settings['ce_animation'] != 'none' ){ |
|---|
| 528 | $this->add_render_attribute( 'ce-staff-item', 'class', ['ce-animation', 'ce-animation--'.$settings['ce_animation'], 'ce-animation-manual' ] ); |
|---|
| 529 | $this->add_render_attribute( 'ce-staff-item', 'data-speed', $settings['ce_animation_speed'] ); |
|---|
| 530 | |
|---|
| 531 | } |
|---|
| 532 | |
|---|
| 533 | if( isset( $settings['edge_padding'] ) && !empty( $settings['edge_padding'] ) ) |
|---|
| 534 | $this->add_render_attribute( 'ce-staff-carousel', 'data-edge-padding', $settings['edge_padding']['size'] ); |
|---|
| 535 | |
|---|
| 536 | if( isset( $settings['start_index'] ) && !empty( $settings['start_index'] ) ) |
|---|
| 537 | $this->add_render_attribute( 'ce-staff-carousel', 'data-start-index', $settings['start_index'] ); |
|---|
| 538 | |
|---|
| 539 | |
|---|
| 540 | ?> |
|---|
| 541 | <?php if( $settings['carousel_controls'] ){ ?> |
|---|
| 542 | <div class="ce-carousel-head"> |
|---|
| 543 | <div class="ce-staff-carousel-controls"> |
|---|
| 544 | <a href="#" class="ce-prev"><i class="feather feather-arrow-left"></i></a> |
|---|
| 545 | <a href="#" class="ce-next"><i class="feather feather-arrow-right"></i></a> |
|---|
| 546 | </div> |
|---|
| 547 | </div> |
|---|
| 548 | <?php } ?> |
|---|
| 549 | <div <?php echo wp_kses_post( $this->get_render_attribute_string( 'ce-staff-carousel' ) ); ?>> |
|---|
| 550 | |
|---|
| 551 | <?php |
|---|
| 552 | |
|---|
| 553 | if( $settings['source_type'] == 'staff' ){ |
|---|
| 554 | $new_query = array( |
|---|
| 555 | 'posts_per_page' => (int) $settings['items_per_page'], |
|---|
| 556 | 'post_type' => 'staff' |
|---|
| 557 | ); |
|---|
| 558 | |
|---|
| 559 | if( $settings['items_orderby'] != 'none' ){ |
|---|
| 560 | $new_query['orderby'] = $settings['items_orderby']; |
|---|
| 561 | $new_query['order'] = $settings['items_order']; |
|---|
| 562 | } |
|---|
| 563 | |
|---|
| 564 | if( is_array( $settings['items_categories'] ) && !empty( $settings['items_categories'] ) ) { |
|---|
| 565 | |
|---|
| 566 | $new_query['tax_query'] = array( |
|---|
| 567 | |
|---|
| 568 | array( |
|---|
| 569 | 'taxonomy' => 'staff_entries', |
|---|
| 570 | 'field' => 'slug', |
|---|
| 571 | 'terms' => $settings['items_categories'], |
|---|
| 572 | 'operator' => 'IN' |
|---|
| 573 | ) |
|---|
| 574 | ); |
|---|
| 575 | } |
|---|
| 576 | |
|---|
| 577 | if( !empty( $settings['items_staff'] ) ){ |
|---|
| 578 | $new_query['ignore_sticky_posts'] = 1; |
|---|
| 579 | $new_query['post__in'] = $settings['items_staff']; |
|---|
| 580 | $new_query['ignore_custom_sort'] = true; |
|---|
| 581 | } |
|---|
| 582 | |
|---|
| 583 | }else if( $settings['source_type'] == 'all_post_types' ) { |
|---|
| 584 | $new_query['post__in'] = $settings['items_posts']; |
|---|
| 585 | |
|---|
| 586 | } |
|---|
| 587 | |
|---|
| 588 | $the_query = new \WP_Query( $new_query ); |
|---|
| 589 | |
|---|
| 590 | if ( is_object( $the_query ) && $the_query->have_posts() ) : |
|---|
| 591 | $counter = 0; |
|---|
| 592 | // Start loop |
|---|
| 593 | while ( $the_query->have_posts() ) : $the_query->the_post(); ?> |
|---|
| 594 | <?php |
|---|
| 595 | $counter += 1; |
|---|
| 596 | $delay = ( $counter * (int) $settings['ce_animation_delay'] ); |
|---|
| 597 | if( $counter > $settings['columns'] ) |
|---|
| 598 | $delay = 0; |
|---|
| 599 | |
|---|
| 600 | |
|---|
| 601 | $this->add_render_attribute( 'ce-staff-item-'.get_the_ID(), 'data-delay', $delay ); |
|---|
| 602 | ?> |
|---|
| 603 | <?php |
|---|
| 604 | // Sanitize the item_style parameter |
|---|
| 605 | $sanitized_item_style = sanitize_file_name( $settings['item_style'] ); |
|---|
| 606 | |
|---|
| 607 | // Construct the file path |
|---|
| 608 | $file_path = COWIDGETS_DIR . '/inc/widgets-manager/widgets/content/partials/staff/' . $sanitized_item_style . '.php'; |
|---|
| 609 | |
|---|
| 610 | // Validate the file path to ensure it's within the expected directory |
|---|
| 611 | if ( realpath($file_path) && strpos( realpath($file_path), realpath(COWIDGETS_DIR . '/inc/widgets-manager/widgets/content/partials/staff/') ) === 0 ) { |
|---|
| 612 | // Include the file if it exists and is within the expected directory |
|---|
| 613 | include( $file_path ); |
|---|
| 614 | } else { |
|---|
| 615 | // Handle the error, e.g., show a default message or log the error |
|---|
| 616 | echo 'Invalid file path'; |
|---|
| 617 | } |
|---|
| 618 | ?> |
|---|
| 619 | |
|---|
| 620 | <?php endwhile; ?> |
|---|
| 621 | <?php wp_reset_postdata(); ?> |
|---|
| 622 | <?php endif; ?> |
|---|
| 623 | |
|---|
| 624 | </div> |
|---|
| 625 | <?php |
|---|
| 626 | } |
|---|
| 627 | |
|---|
| 628 | |
|---|
| 629 | /** |
|---|
| 630 | * Render shortcode widget output in the editor. |
|---|
| 631 | * |
|---|
| 632 | * Written as a Backbone JavaScript template and used to generate the live preview. |
|---|
| 633 | * |
|---|
| 634 | * @since 1.0.0 |
|---|
| 635 | * @access protected |
|---|
| 636 | */ |
|---|
| 637 | protected function content_template() {} |
|---|
| 638 | |
|---|
| 639 | /** |
|---|
| 640 | * Render shortcode output in the editor. |
|---|
| 641 | * |
|---|
| 642 | * Written as a Backbone JavaScript template and used to generate the live preview. |
|---|
| 643 | * |
|---|
| 644 | * Remove this after Elementor v3.3.0 |
|---|
| 645 | * |
|---|
| 646 | * @since 1.0.0 |
|---|
| 647 | * @access protected |
|---|
| 648 | */ |
|---|
| 649 | protected function _content_template() { |
|---|
| 650 | $this->content_template(); |
|---|
| 651 | } |
|---|
| 652 | } |
|---|