| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Property Let Date Available From Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
class Elementor_Property_Let_Available_Date_Widget extends \Elementor\Widget_Base { |
| 8 |
|
| 9 |
public function get_name() { |
| 10 |
return 'property-let-available-date'; |
| 11 |
} |
| 12 |
|
| 13 |
public function get_title() { |
| 14 |
return __( 'Let Available From', 'propertyhive' ); |
| 15 |
} |
| 16 |
|
| 17 |
public function get_icon() { |
| 18 |
return 'eicon-calendar'; |
| 19 |
} |
| 20 |
|
| 21 |
public function get_categories() { |
| 22 |
return [ 'property-hive' ]; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_keywords() { |
| 26 |
return [ 'property hive', 'propertyhive', 'property', 'available from', 'available date', 'let date' ]; |
| 27 |
} |
| 28 |
|
| 29 |
protected function register_controls() { |
| 30 |
|
| 31 |
$this->start_controls_section( |
| 32 |
'content_section', |
| 33 |
[ |
| 34 |
'label' => __( 'Available Date', 'propertyhive' ), |
| 35 |
'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 36 |
] |
| 37 |
); |
| 38 |
|
| 39 |
$this->add_control( |
| 40 |
'icon', |
| 41 |
[ |
| 42 |
'label' => __( 'Icon', 'propertyhive' ), |
| 43 |
'type' => \Elementor\Controls_Manager::ICONS, |
| 44 |
'default' => [ |
| 45 |
'value' => 'fas fa-calendar', |
| 46 |
'library' => 'solid', |
| 47 |
], |
| 48 |
] |
| 49 |
); |
| 50 |
|
| 51 |
$this->add_control( |
| 52 |
'before', |
| 53 |
[ |
| 54 |
'label' => __( 'Before', 'propertyhive' ), |
| 55 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 56 |
'default' => __( 'Available From', 'propertyhive' ), |
| 57 |
] |
| 58 |
); |
| 59 |
|
| 60 |
$this->add_control( |
| 61 |
'after', |
| 62 |
[ |
| 63 |
'label' => __( 'After', 'propertyhive' ), |
| 64 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 65 |
] |
| 66 |
); |
| 67 |
|
| 68 |
$this->end_controls_section(); |
| 69 |
|
| 70 |
$this->start_controls_section( |
| 71 |
'style_section', |
| 72 |
[ |
| 73 |
'label' => __( 'Available Date', 'propertyhive' ), |
| 74 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 75 |
] |
| 76 |
); |
| 77 |
|
| 78 |
$this->add_group_control( |
| 79 |
\Elementor\Group_Control_Typography::get_type(), |
| 80 |
[ |
| 81 |
'name' => 'typography', |
| 82 |
'label' => __( 'Typography', 'propertyhive' ), |
| 83 |
'global' => [ |
| 84 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_PRIMARY, |
| 85 |
], |
| 86 |
'selector' => '{{WRAPPER}} .elementor-widget-let-available-date', |
| 87 |
] |
| 88 |
); |
| 89 |
|
| 90 |
$this->add_control( |
| 91 |
'color', |
| 92 |
[ |
| 93 |
'label' => __( 'Colour', 'propertyhive' ), |
| 94 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 95 |
'global' => [ |
| 96 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY, |
| 97 |
], |
| 98 |
'selectors' => [ |
| 99 |
'{{WRAPPER}} .elementor-widget-let-available-date' => 'color: {{VALUE}}', |
| 100 |
], |
| 101 |
] |
| 102 |
); |
| 103 |
|
| 104 |
$this->add_control( |
| 105 |
'text_align', |
| 106 |
[ |
| 107 |
'label' => __( 'Alignment', 'propertyhive' ), |
| 108 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 109 |
'options' => [ |
| 110 |
'left' => [ |
| 111 |
'title' => __( 'Left', 'propertyhive' ), |
| 112 |
'icon' => 'fa fa-align-left', |
| 113 |
], |
| 114 |
'center' => [ |
| 115 |
'title' => __( 'Center', 'propertyhive' ), |
| 116 |
'icon' => 'fa fa-align-center', |
| 117 |
], |
| 118 |
'right' => [ |
| 119 |
'title' => __( 'Right', 'propertyhive' ), |
| 120 |
'icon' => 'fa fa-align-right', |
| 121 |
], |
| 122 |
], |
| 123 |
'default' => 'left', |
| 124 |
'toggle' => true, |
| 125 |
'selectors' => [ |
| 126 |
'{{WRAPPER}} .elementor-widget-let-available-date' => 'text-align: {{VALUE}}', |
| 127 |
], |
| 128 |
] |
| 129 |
); |
| 130 |
|
| 131 |
$this->end_controls_section(); |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
protected function render() { |
| 136 |
|
| 137 |
global $property; |
| 138 |
|
| 139 |
$settings = $this->get_settings_for_display(); |
| 140 |
|
| 141 |
if ( !isset($property->id) ) { |
| 142 |
return; |
| 143 |
} |
| 144 |
|
| 145 |
if ( $property->department != 'residential-lettings' && ph_get_custom_department_based_on( $property->department ) != 'residential-lettings' && $property->department != 'rooms' ) |
| 146 |
{ |
| 147 |
return; |
| 148 |
} |
| 149 |
|
| 150 |
if ( $property->available_date == '' ) |
| 151 |
{ |
| 152 |
return; |
| 153 |
} |
| 154 |
|
| 155 |
echo '<div class="elementor-widget-let-available-date">'; |
| 156 |
if ( isset($settings['icon']) && !empty($settings['icon']) ) |
| 157 |
{ |
| 158 |
\Elementor\Icons_Manager::render_icon( $settings['icon'], [ 'aria-hidden' => 'true' ] ); |
| 159 |
echo ' '; |
| 160 |
} |
| 161 |
if ( isset($settings['before']) && !empty($settings['before']) ) |
| 162 |
{ |
| 163 |
echo $settings['before'] . ' '; |
| 164 |
} |
| 165 |
echo $property->get_available_date(); |
| 166 |
if ( isset($settings['after']) && !empty($settings['after']) ) |
| 167 |
{ |
| 168 |
echo ' ' . $settings['after']; |
| 169 |
} |
| 170 |
echo '</div>'; |
| 171 |
|
| 172 |
} |
| 173 |
|
| 174 |
} |