| 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 'eicon-meta-data'; |
| 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->add_control( |
| 69 |
'text_align', |
| 70 |
[ |
| 71 |
'label' => __( 'Alignment', 'propertyhive' ), |
| 72 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 73 |
'options' => [ |
| 74 |
'left' => [ |
| 75 |
'title' => __( 'Left', 'propertyhive' ), |
| 76 |
'icon' => 'eicon-text-align-left', |
| 77 |
], |
| 78 |
'center' => [ |
| 79 |
'title' => __( 'Center', 'propertyhive' ), |
| 80 |
'icon' => 'eicon-text-align-center', |
| 81 |
], |
| 82 |
'right' => [ |
| 83 |
'title' => __( 'Right', 'propertyhive' ), |
| 84 |
'icon' => 'eicon-text-align-right', |
| 85 |
], |
| 86 |
], |
| 87 |
'default' => 'left', |
| 88 |
'toggle' => true, |
| 89 |
'selectors' => [ |
| 90 |
'{{WRAPPER}} .elementor-widget-bedrooms' => 'text-align: {{VALUE}}', |
| 91 |
], |
| 92 |
] |
| 93 |
); |
| 94 |
|
| 95 |
$this->end_controls_section(); |
| 96 |
|
| 97 |
$this->start_controls_section( |
| 98 |
'style_section', |
| 99 |
[ |
| 100 |
'label' => __( 'Bedrooms', 'propertyhive' ), |
| 101 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 102 |
] |
| 103 |
); |
| 104 |
|
| 105 |
$this->add_group_control( |
| 106 |
\Elementor\Group_Control_Typography::get_type(), |
| 107 |
[ |
| 108 |
'name' => 'typography', |
| 109 |
'label' => __( 'Typography', 'propertyhive' ), |
| 110 |
'global' => [ |
| 111 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_PRIMARY, |
| 112 |
], |
| 113 |
'selector' => '{{WRAPPER}} .elementor-widget-bedrooms', |
| 114 |
] |
| 115 |
); |
| 116 |
|
| 117 |
$this->add_control( |
| 118 |
'color', |
| 119 |
[ |
| 120 |
'label' => __( 'Colour', 'propertyhive' ), |
| 121 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 122 |
'global' => [ |
| 123 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY, |
| 124 |
], |
| 125 |
'selectors' => [ |
| 126 |
'{{WRAPPER}} .elementor-widget-bedrooms' => 'color: {{VALUE}}', |
| 127 |
], |
| 128 |
] |
| 129 |
); |
| 130 |
|
| 131 |
$this->add_control( |
| 132 |
'icon_color', |
| 133 |
[ |
| 134 |
'label' => __( 'Icon Colour', 'propertyhive' ), |
| 135 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 136 |
'global' => [ |
| 137 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY, |
| 138 |
], |
| 139 |
'selectors' => [ |
| 140 |
'{{WRAPPER}} .elementor-widget-bedrooms i' => 'color: {{VALUE}}', |
| 141 |
], |
| 142 |
] |
| 143 |
); |
| 144 |
|
| 145 |
$this->end_controls_section(); |
| 146 |
|
| 147 |
} |
| 148 |
|
| 149 |
protected function render() { |
| 150 |
|
| 151 |
global $property; |
| 152 |
|
| 153 |
$settings = $this->get_settings_for_display(); |
| 154 |
|
| 155 |
if ( !isset($property->id) ) { |
| 156 |
return; |
| 157 |
} |
| 158 |
|
| 159 |
if ( $property->bedrooms != '' && $property->bedrooms != 0 ) |
| 160 |
{ |
| 161 |
echo '<div class="elementor-widget-bedrooms">'; |
| 162 |
if ( isset($settings['icon']) && !empty($settings['icon']) ) |
| 163 |
{ |
| 164 |
\Elementor\Icons_Manager::render_icon( $settings['icon'], [ 'aria-hidden' => 'true' ] ); |
| 165 |
echo ' '; |
| 166 |
} |
| 167 |
if ( isset($settings['before']) && !empty($settings['before']) ) |
| 168 |
{ |
| 169 |
echo $settings['before'] . ' '; |
| 170 |
} |
| 171 |
echo esc_html($property->bedrooms); |
| 172 |
if ( isset($settings['after']) && !empty($settings['after']) ) |
| 173 |
{ |
| 174 |
echo ' ' . $settings['after']; |
| 175 |
} |
| 176 |
echo '</div>'; |
| 177 |
} |
| 178 |
|
| 179 |
} |
| 180 |
|
| 181 |
} |