| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Property Features Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
class Elementor_Property_Features_Widget extends \Elementor\Widget_Base { |
| 8 |
|
| 9 |
public function get_name() { |
| 10 |
return 'property-features'; |
| 11 |
} |
| 12 |
|
| 13 |
public function get_title() { |
| 14 |
return __( 'Features', 'propertyhive' ); |
| 15 |
} |
| 16 |
|
| 17 |
public function get_icon() { |
| 18 |
return 'eicon-bullet-list'; |
| 19 |
} |
| 20 |
|
| 21 |
public function get_categories() { |
| 22 |
return [ 'property-hive' ]; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_keywords() { |
| 26 |
return [ 'property hive', 'propertyhive', 'property', 'features', 'key', 'bullet' ]; |
| 27 |
} |
| 28 |
|
| 29 |
protected function register_controls() { |
| 30 |
|
| 31 |
$this->start_controls_section( |
| 32 |
'style_section', |
| 33 |
[ |
| 34 |
'label' => __( 'Features', 'propertyhive' ), |
| 35 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 36 |
] |
| 37 |
); |
| 38 |
|
| 39 |
$this->add_control( |
| 40 |
'show_title', |
| 41 |
[ |
| 42 |
'label' => __( 'Show Title', 'propertyhive' ), |
| 43 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 44 |
'label_on' => __( 'Show', 'propertyhive' ), |
| 45 |
'label_off' => __( 'Hide', 'propertyhive' ), |
| 46 |
'return_value' => 'yes', |
| 47 |
'default' => 'yes', |
| 48 |
] |
| 49 |
); |
| 50 |
|
| 51 |
$this->add_group_control( |
| 52 |
\Elementor\Group_Control_Typography::get_type(), |
| 53 |
[ |
| 54 |
'name' => 'title_typography', |
| 55 |
'label' => __( 'Title Typography', 'propertyhive' ), |
| 56 |
'global' => [ |
| 57 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_PRIMARY, |
| 58 |
], |
| 59 |
'selector' => '{{WRAPPER}} .features h4', |
| 60 |
'condition' => [ |
| 61 |
'show_title' => 'yes' |
| 62 |
], |
| 63 |
] |
| 64 |
); |
| 65 |
|
| 66 |
$this->add_control( |
| 67 |
'title_color', |
| 68 |
[ |
| 69 |
'label' => __( 'Title Colour', 'propertyhive' ), |
| 70 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 71 |
'global' => [ |
| 72 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY, |
| 73 |
], |
| 74 |
'selectors' => [ |
| 75 |
'{{WRAPPER}} .features h4' => 'color: {{VALUE}}', |
| 76 |
], |
| 77 |
'condition' => [ |
| 78 |
'show_title' => 'yes' |
| 79 |
], |
| 80 |
] |
| 81 |
); |
| 82 |
|
| 83 |
$this->add_group_control( |
| 84 |
\Elementor\Group_Control_Typography::get_type(), |
| 85 |
[ |
| 86 |
'name' => 'features_typography', |
| 87 |
'label' => __( 'List Typography', 'propertyhive' ), |
| 88 |
'global' => [ |
| 89 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_PRIMARY, |
| 90 |
], |
| 91 |
'selector' => '{{WRAPPER}} .features li', |
| 92 |
] |
| 93 |
); |
| 94 |
|
| 95 |
$this->add_control( |
| 96 |
'list_color', |
| 97 |
[ |
| 98 |
'label' => __( 'List Colour', 'propertyhive' ), |
| 99 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 100 |
'global' => [ |
| 101 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY, |
| 102 |
], |
| 103 |
'selectors' => [ |
| 104 |
'{{WRAPPER}} .features li' => 'color: {{VALUE}}', |
| 105 |
], |
| 106 |
] |
| 107 |
); |
| 108 |
|
| 109 |
$this->add_control( |
| 110 |
'bullet_type', |
| 111 |
[ |
| 112 |
'label' => __( 'Bullet Type', 'propertyhive' ), |
| 113 |
'type' => \Elementor\Controls_Manager::SELECT, |
| 114 |
'default' => 'disc', |
| 115 |
'options' => [ |
| 116 |
'disc' => __( 'Circle', 'propertyhive' ), |
| 117 |
'square' => __( 'Square', 'propertyhive' ), |
| 118 |
'icon' => __( 'Icon', 'propertyhive' ), |
| 119 |
], |
| 120 |
'selectors' => [ |
| 121 |
'{{WRAPPER}} .features ul' => 'list-style-type: {{VALUE}};', |
| 122 |
], |
| 123 |
] |
| 124 |
); |
| 125 |
|
| 126 |
$this->add_control( |
| 127 |
'bullet_icon', |
| 128 |
[ |
| 129 |
'label' => __( 'Icon', 'propertyhive' ), |
| 130 |
'type' => \Elementor\Controls_Manager::ICONS, |
| 131 |
'fa4compatibility' => 'bullet_icon_old', |
| 132 |
'condition' => [ |
| 133 |
'bullet_type' => 'icon', |
| 134 |
], |
| 135 |
] |
| 136 |
); |
| 137 |
|
| 138 |
$this->add_control( |
| 139 |
'bullet_color', |
| 140 |
[ |
| 141 |
'label' => __( 'Bullet Colour', 'propertyhive' ), |
| 142 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 143 |
'selectors' => [ |
| 144 |
'{{WRAPPER}} .features ul li::marker' => 'color: {{VALUE}};', |
| 145 |
'{{WRAPPER}} .features .ph-feature-icon' => 'color: {{VALUE}};', |
| 146 |
'{{WRAPPER}} .features .ph-feature-icon svg' => 'fill: {{VALUE}};', |
| 147 |
], |
| 148 |
] |
| 149 |
); |
| 150 |
|
| 151 |
$this->add_responsive_control( |
| 152 |
'columns', |
| 153 |
[ |
| 154 |
'label' => __( 'Columns', 'propertyhive' ), |
| 155 |
'type' => \Elementor\Controls_Manager::NUMBER, |
| 156 |
'min' => 1, |
| 157 |
'max' => 3, |
| 158 |
'step' => 1, |
| 159 |
'default' => 1, |
| 160 |
'selectors' => [ |
| 161 |
'{{WRAPPER}} .features ul' => 'column-count: {{VALUE}};', |
| 162 |
], |
| 163 |
] |
| 164 |
); |
| 165 |
|
| 166 |
$this->end_controls_section(); |
| 167 |
|
| 168 |
} |
| 169 |
|
| 170 |
protected function render() { |
| 171 |
|
| 172 |
global $property; |
| 173 |
|
| 174 |
$settings = $this->get_settings_for_display(); |
| 175 |
|
| 176 |
if ( !isset($property->id) ) { |
| 177 |
return; |
| 178 |
} |
| 179 |
|
| 180 |
if ( isset($settings['show_title']) && $settings['show_title'] != 'yes' ) |
| 181 |
{ |
| 182 |
?> |
| 183 |
<style type="text/css"> |
| 184 |
.features h4 { display:none; } |
| 185 |
</style> |
| 186 |
<?php |
| 187 |
} |
| 188 |
|
| 189 |
$bullet_type = isset( $settings['bullet_type'] ) ? $settings['bullet_type'] : 'disc'; |
| 190 |
|
| 191 |
ob_start(); |
| 192 |
propertyhive_template_single_features(); |
| 193 |
$output = ob_get_clean(); |
| 194 |
|
| 195 |
if ( $bullet_type === 'icon' && ! empty( $settings['bullet_icon']['value'] ) ) { |
| 196 |
|
| 197 |
$icon_html = '<span class="ph-feature-icon" aria-hidden="true">'; |
| 198 |
ob_start(); |
| 199 |
\Elementor\Icons_Manager::render_icon( |
| 200 |
$settings['bullet_icon'], |
| 201 |
[ |
| 202 |
'aria-hidden' => 'true', |
| 203 |
] |
| 204 |
); |
| 205 |
$icon_html .= ob_get_clean(); |
| 206 |
$icon_html .= '</span>'; |
| 207 |
|
| 208 |
$output = preg_replace( |
| 209 |
'/<li([^>]*)>/i', |
| 210 |
'<li$1>' . $icon_html, |
| 211 |
$output |
| 212 |
); |
| 213 |
|
| 214 |
?> |
| 215 |
<style type="text/css"> |
| 216 |
.elementor-widget-property-features .features ul { |
| 217 |
list-style: none !important; |
| 218 |
padding-left: 0; |
| 219 |
} |
| 220 |
.elementor-widget-property-features .features ul li { |
| 221 |
display: flex; |
| 222 |
align-items: flex-start; |
| 223 |
gap: 8px; |
| 224 |
} |
| 225 |
.elementor-widget-property-features .features .ph-feature-icon { |
| 226 |
display: inline-flex; |
| 227 |
flex: 0 0 auto; |
| 228 |
line-height: 1; |
| 229 |
margin-top: 0.15em; |
| 230 |
} |
| 231 |
.elementor-widget-property-features .features .ph-feature-icon i, |
| 232 |
.elementor-widget-property-features .features .ph-feature-icon svg { |
| 233 |
width: 1em; |
| 234 |
height: 1em; |
| 235 |
} |
| 236 |
</style> |
| 237 |
<?php |
| 238 |
} |
| 239 |
|
| 240 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Feature text is escaped during assembly; selected icons are generated by Elementor Icons_Manager. |
| 241 |
echo $output; |
| 242 |
} |
| 243 |
|
| 244 |
} |