| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Property Price Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
class Elementor_Property_Price_Widget extends \Elementor\Widget_Base { |
| 8 |
|
| 9 |
public function get_name() { |
| 10 |
return 'property-price'; |
| 11 |
} |
| 12 |
|
| 13 |
public function get_title() { |
| 14 |
return __( 'Price', 'propertyhive' ); |
| 15 |
} |
| 16 |
|
| 17 |
public function get_icon() { |
| 18 |
return 'eicon-number-field'; |
| 19 |
} |
| 20 |
|
| 21 |
public function get_categories() { |
| 22 |
return [ 'property-hive' ]; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_keywords() { |
| 26 |
return [ 'property hive', 'propertyhive', 'property', 'price' ]; |
| 27 |
} |
| 28 |
|
| 29 |
protected function register_controls() { |
| 30 |
|
| 31 |
$this->start_controls_section( |
| 32 |
'style_section', |
| 33 |
[ |
| 34 |
'label' => __( 'Price', 'propertyhive' ), |
| 35 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 36 |
] |
| 37 |
); |
| 38 |
|
| 39 |
$this->add_group_control( |
| 40 |
\Elementor\Group_Control_Typography::get_type(), |
| 41 |
[ |
| 42 |
'name' => 'price_typography', |
| 43 |
'label' => __( 'Typography', 'propertyhive' ), |
| 44 |
'global' => [ |
| 45 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_PRIMARY, |
| 46 |
], |
| 47 |
'selector' => '{{WRAPPER}} .price', |
| 48 |
] |
| 49 |
); |
| 50 |
|
| 51 |
$this->add_control( |
| 52 |
'price_color', |
| 53 |
[ |
| 54 |
'label' => __( 'Colour', 'propertyhive' ), |
| 55 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 56 |
'global' => [ |
| 57 |
'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY, |
| 58 |
], |
| 59 |
'selectors' => [ |
| 60 |
'{{WRAPPER}} .price' => 'color: {{VALUE}}', |
| 61 |
], |
| 62 |
] |
| 63 |
); |
| 64 |
|
| 65 |
$this->add_control( |
| 66 |
'text_align', |
| 67 |
[ |
| 68 |
'label' => __( 'Alignment', 'propertyhive' ), |
| 69 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 70 |
'options' => [ |
| 71 |
'left' => [ |
| 72 |
'title' => __( 'Left', 'propertyhive' ), |
| 73 |
'icon' => 'eicon-text-align-left', |
| 74 |
], |
| 75 |
'center' => [ |
| 76 |
'title' => __( 'Center', 'propertyhive' ), |
| 77 |
'icon' => 'eicon-text-align-center', |
| 78 |
], |
| 79 |
'right' => [ |
| 80 |
'title' => __( 'Right', 'propertyhive' ), |
| 81 |
'icon' => 'eicon-text-align-right', |
| 82 |
], |
| 83 |
], |
| 84 |
'default' => 'left', |
| 85 |
'toggle' => true, |
| 86 |
'selectors' => [ |
| 87 |
'{{WRAPPER}} .price' => 'text-align: {{VALUE}}', |
| 88 |
], |
| 89 |
] |
| 90 |
); |
| 91 |
|
| 92 |
$this->add_control( |
| 93 |
'show_price_qualifier', |
| 94 |
[ |
| 95 |
'label' => __( 'Show Price Qualifier', 'propertyhive' ), |
| 96 |
'type' => \Elementor\Controls_Manager::SWITCHER, |
| 97 |
'label_on' => __( 'Show', 'propertyhive' ), |
| 98 |
'label_off' => __( 'Hide', 'propertyhive' ), |
| 99 |
'return_value' => 'yes', |
| 100 |
'default' => 'yes', |
| 101 |
] |
| 102 |
); |
| 103 |
|
| 104 |
$this->end_controls_section(); |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
protected function render() { |
| 109 |
|
| 110 |
global $property; |
| 111 |
|
| 112 |
$settings = $this->get_settings_for_display(); |
| 113 |
|
| 114 |
if ( !isset($property->id) ) { |
| 115 |
return; |
| 116 |
} |
| 117 |
|
| 118 |
if ( isset($settings['show_price_qualifier']) && $settings['show_price_qualifier'] != 'yes' ) |
| 119 |
{ |
| 120 |
?> |
| 121 |
<style type="text/css"> |
| 122 |
.price .price-qualifier { display:none; } |
| 123 |
</style> |
| 124 |
<?php |
| 125 |
} |
| 126 |
|
| 127 |
propertyhive_template_single_price(); |
| 128 |
|
| 129 |
} |
| 130 |
|
| 131 |
} |