| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Property Bedrooms Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
class Elementor_Property_Bedrooms_Widget extends \Elementor\Widget_Base { |
| 8 |
|
| 9 |
public function get_name() { |
| 10 |
return 'property-bedrooms'; |
| 11 |
} |
| 12 |
|
| 13 |
public function get_title() { |
| 14 |
return __( 'Bedrooms', 'propertyhive' ); |
| 15 |
} |
| 16 |
|
| 17 |
public function get_icon() { |
| 18 |
return 'fa fa-bed'; |
| 19 |
} |
| 20 |
|
| 21 |
public function get_categories() { |
| 22 |
return [ 'property-hive' ]; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_keywords() { |
| 26 |
return [ 'property hive', 'propertyhive', 'property', 'bedroom', 'room' ]; |
| 27 |
} |
| 28 |
|
| 29 |
protected function _register_controls() { |
| 30 |
|
| 31 |
$this->start_controls_section( |
| 32 |
'content_section', |
| 33 |
[ |
| 34 |
'label' => __( 'Bedrooms', '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-bed', |
| 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 |
] |
| 57 |
); |
| 58 |
|
| 59 |
$this->add_control( |
| 60 |
'after', |
| 61 |
[ |
| 62 |
'label' => __( 'After', 'propertyhive' ), |
| 63 |
'type' => \Elementor\Controls_Manager::TEXT, |
| 64 |
'default' => __( 'Bedrooms', 'propertyhive' ), |
| 65 |
] |
| 66 |
); |
| 67 |
|
| 68 |
$this->end_controls_section(); |
| 69 |
|
| 70 |
$this->start_controls_section( |
| 71 |
'style_section', |
| 72 |
[ |
| 73 |
'label' => __( 'Bedrooms', '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 |
'scheme' => \Elementor\Scheme_Typography::TYPOGRAPHY_1, |
| 84 |
'selector' => '{{WRAPPER}} .elementor-widget-bedrooms', |
| 85 |
] |
| 86 |
); |
| 87 |
|
| 88 |
$this->add_control( |
| 89 |
'color', |
| 90 |
[ |
| 91 |
'label' => __( 'Colour', 'propertyhive' ), |
| 92 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 93 |
'scheme' => [ |
| 94 |
'type' => \Elementor\Scheme_Color::get_type(), |
| 95 |
'value' => \Elementor\Scheme_Color::COLOR_1, |
| 96 |
], |
| 97 |
'selectors' => [ |
| 98 |
'{{WRAPPER}} .elementor-widget-bedrooms' => 'color: {{VALUE}}', |
| 99 |
], |
| 100 |
] |
| 101 |
); |
| 102 |
|
| 103 |
$this->end_controls_section(); |
| 104 |
|
| 105 |
} |
| 106 |
|
| 107 |
protected function render() { |
| 108 |
|
| 109 |
global $property; |
| 110 |
|
| 111 |
$settings = $this->get_settings_for_display(); |
| 112 |
|
| 113 |
if ( !isset($property->id) ) { |
| 114 |
return; |
| 115 |
} |
| 116 |
|
| 117 |
if ( $property->bedrooms != '' && $property->bedrooms != 0 ) |
| 118 |
{ |
| 119 |
echo '<div class="elementor-widget-bedrooms">'; |
| 120 |
if ( isset($settings['icon']) && !empty($settings['icon']) ) |
| 121 |
{ |
| 122 |
\Elementor\Icons_Manager::render_icon( $settings['icon'], [ 'aria-hidden' => 'true' ] ); |
| 123 |
echo ' '; |
| 124 |
} |
| 125 |
if ( isset($settings['before']) && !empty($settings['before']) ) |
| 126 |
{ |
| 127 |
echo $settings['before'] . ' '; |
| 128 |
} |
| 129 |
echo $property->bedrooms; |
| 130 |
if ( isset($settings['after']) && !empty($settings['after']) ) |
| 131 |
{ |
| 132 |
echo ' ' . $settings['after']; |
| 133 |
} |
| 134 |
echo '</div>'; |
| 135 |
} |
| 136 |
|
| 137 |
} |
| 138 |
|
| 139 |
} |