AmeliaBookingElementorWidget.php
6 months ago
AmeliaCatalogBookingElementorWidget.php
2 weeks ago
AmeliaCatalogElementorWidget.php
6 months ago
AmeliaEventsCalendarBookingElementorWidget.php
2 weeks ago
AmeliaEventsElementorWidget.php
2 weeks ago
AmeliaEventsListBookingButtonElementorWidget.php
2 weeks ago
AmeliaEventsListBookingElementorWidget.php
2 weeks ago
AmeliaStepBookingButtonElementorWidget.php
1 month ago
AmeliaStepBookingElementorWidget.php
2 weeks ago
ElementorBlock.php
2 weeks ago
ElementorSharedShortcodeWidget.php
2 weeks ago
ElementorSharedShortcodeWidget.php
107 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @copyright © Melograno Ventures. All rights reserved. |
| 5 | * @licence See LICENCE.md for license details. |
| 6 | */ |
| 7 | |
| 8 | namespace Elementor; |
| 9 | |
| 10 | use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings; |
| 11 | |
| 12 | /** |
| 13 | * Class ElementorSharedShortcodeWidget |
| 14 | * |
| 15 | * @package AmeliaBooking\Infrastructure\WP\Elementor |
| 16 | */ |
| 17 | abstract class ElementorSharedShortcodeWidget extends Widget_Base |
| 18 | { |
| 19 | protected function setSharedShortcodeElements($controls_data) |
| 20 | { |
| 21 | $this->add_control( |
| 22 | 'load_manually', |
| 23 | [ |
| 24 | 'label' => BackendStrings::get('manually_loading'), |
| 25 | 'label_block' => true, |
| 26 | 'type' => Controls_Manager::TEXT, |
| 27 | 'placeholder' => '', |
| 28 | 'description' => BackendStrings::get('manually_loading_description'), |
| 29 | ] |
| 30 | ); |
| 31 | |
| 32 | $this->add_control( |
| 33 | 'trigger_type', |
| 34 | [ |
| 35 | 'label' => BackendStrings::get('trigger_type'), |
| 36 | 'type' => Controls_Manager::SELECT, |
| 37 | 'description' => BackendStrings::get('trigger_type_tooltip'), |
| 38 | 'options' => [ |
| 39 | 'id' => BackendStrings::get('trigger_type_id'), |
| 40 | 'class' => BackendStrings::get('trigger_type_class') |
| 41 | ], |
| 42 | 'condition' => [ |
| 43 | 'load_manually!' => '', |
| 44 | ], |
| 45 | 'default' => 'id' |
| 46 | ] |
| 47 | ); |
| 48 | |
| 49 | $this->add_control( |
| 50 | 'in_dialog', |
| 51 | [ |
| 52 | 'label' => BackendStrings::get('in_dialog'), |
| 53 | 'type' => Controls_Manager::SWITCHER, |
| 54 | 'default' => false, |
| 55 | 'label_on' => BackendStrings::get('yes'), |
| 56 | 'label_off' => BackendStrings::get('no'), |
| 57 | 'condition' => [ |
| 58 | 'load_manually!' => '', |
| 59 | ], |
| 60 | ] |
| 61 | ); |
| 62 | |
| 63 | if (!empty($controls_data['ivy'])) { |
| 64 | $this->add_control( |
| 65 | 'ivy', |
| 66 | [ |
| 67 | 'label' => BackendStrings::get('ivy'), |
| 68 | 'type' => Controls_Manager::SELECT, |
| 69 | 'description' => BackendStrings::get('ivy_tooltip'), |
| 70 | 'options' => $controls_data['ivy'], |
| 71 | 'default' => '', |
| 72 | 'condition' => [ |
| 73 | 'load_manually' => '', |
| 74 | ], |
| 75 | ] |
| 76 | ); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | protected function getSharedShortcodeString($settings) |
| 81 | { |
| 82 | $shortCode = ''; |
| 83 | |
| 84 | $trigger = $settings['load_manually'] !== '' ? ' trigger="' . esc_attr($settings['load_manually']) . '"' : ''; |
| 85 | $trigger_type = $settings['load_manually'] && $settings['trigger_type'] !== '' ? ' trigger_type="' . esc_attr($settings['trigger_type']) . '"' : ''; |
| 86 | $in_dialog = $settings['load_manually'] && $settings['in_dialog'] === 'yes' ? ' in_dialog=1' : ''; |
| 87 | $ivy = !$settings['load_manually'] && !empty($settings['ivy']) && $settings['ivy'] !== '0' ? ' ivy="' . esc_attr($settings['ivy']) . '"' : ''; |
| 88 | |
| 89 | $shortCode .= $trigger . $trigger_type . $in_dialog . $ivy; |
| 90 | |
| 91 | return $shortCode; |
| 92 | } |
| 93 | |
| 94 | public static function setSharedShortcodeData($data, &$elementorData) |
| 95 | { |
| 96 | $elementorData['ivy'] = []; |
| 97 | |
| 98 | if (empty($data['ivy'])) { |
| 99 | return; |
| 100 | } |
| 101 | |
| 102 | foreach ($data['ivy'] as $form) { |
| 103 | $elementorData['ivy'][$form['value']] = $form['label']; |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 |