| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor Property Actions Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
class Elementor_Property_Actions_Widget extends \Elementor\Widget_Base { |
| 8 |
|
| 9 |
public function get_name() { |
| 10 |
return 'property-actions'; |
| 11 |
} |
| 12 |
|
| 13 |
public function get_title() { |
| 14 |
return __( 'Actions', 'propertyhive' ); |
| 15 |
} |
| 16 |
|
| 17 |
public function get_icon() { |
| 18 |
return 'fa fa-hand-pointer'; |
| 19 |
} |
| 20 |
|
| 21 |
public function get_categories() { |
| 22 |
return [ 'property-hive' ]; |
| 23 |
} |
| 24 |
|
| 25 |
public function get_keywords() { |
| 26 |
return [ 'property hive', 'propertyhive', 'property', 'actions', 'buttons', 'enquiry' ]; |
| 27 |
} |
| 28 |
|
| 29 |
protected function _register_controls() { |
| 30 |
|
| 31 |
$this->start_controls_section( |
| 32 |
'style_section', |
| 33 |
[ |
| 34 |
'label' => __( 'Actions', 'propertyhive' ), |
| 35 |
'tab' => \Elementor\Controls_Manager::TAB_STYLE, |
| 36 |
] |
| 37 |
); |
| 38 |
|
| 39 |
$this->add_control( |
| 40 |
'display', |
| 41 |
[ |
| 42 |
'label' => __( 'Display As', 'plugin-domain' ), |
| 43 |
'type' => \Elementor\Controls_Manager::CHOOSE, |
| 44 |
'options' => [ |
| 45 |
'list' => [ |
| 46 |
'title' => __( 'List', 'plugin-domain' ), |
| 47 |
'icon' => 'fa fa-list', |
| 48 |
], |
| 49 |
'buttons' => [ |
| 50 |
'title' => __( 'Buttons', 'plugin-domain' ), |
| 51 |
'icon' => 'fa fa-ellipsis-h', |
| 52 |
], |
| 53 |
], |
| 54 |
'default' => 'list', |
| 55 |
'toggle' => false, |
| 56 |
] |
| 57 |
); |
| 58 |
|
| 59 |
$this->add_control( |
| 60 |
'button_background_color', |
| 61 |
[ |
| 62 |
'label' => __( 'Button Background Colour', 'propertyhive' ), |
| 63 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 64 |
'scheme' => [ |
| 65 |
'type' => \Elementor\Scheme_Color::get_type(), |
| 66 |
'value' => \Elementor\Scheme_Color::COLOR_1, |
| 67 |
], |
| 68 |
'selectors' => [ |
| 69 |
'{{WRAPPER}} .property_actions ul li a' => 'background: {{VALUE}}', |
| 70 |
], |
| 71 |
'condition' => [ |
| 72 |
'display' => 'buttons' |
| 73 |
], |
| 74 |
] |
| 75 |
); |
| 76 |
|
| 77 |
$this->add_control( |
| 78 |
'button_text_color', |
| 79 |
[ |
| 80 |
'label' => __( 'Button Text Colour', 'propertyhive' ), |
| 81 |
'type' => \Elementor\Controls_Manager::COLOR, |
| 82 |
'scheme' => [ |
| 83 |
'type' => \Elementor\Scheme_Color::get_type(), |
| 84 |
'value' => \Elementor\Scheme_Color::COLOR_1, |
| 85 |
], |
| 86 |
'selectors' => [ |
| 87 |
'{{WRAPPER}} .property_actions ul li a' => 'color: {{VALUE}}', |
| 88 |
], |
| 89 |
'condition' => [ |
| 90 |
'display' => 'buttons' |
| 91 |
], |
| 92 |
] |
| 93 |
); |
| 94 |
|
| 95 |
$this->add_control( |
| 96 |
'button_padding', |
| 97 |
[ |
| 98 |
'label' => __( 'Button Padding', 'propertyhive' ), |
| 99 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 100 |
'size_units' => [ 'px' ], |
| 101 |
'selectors' => [ |
| 102 |
'{{WRAPPER}} .property_actions ul li a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 103 |
], |
| 104 |
'default' => [ |
| 105 |
'top' => 5, |
| 106 |
'right' => 5, |
| 107 |
'bottom' => 5, |
| 108 |
'left' => 5, |
| 109 |
'isLinked' => true, |
| 110 |
], |
| 111 |
'condition' => [ |
| 112 |
'display' => 'buttons' |
| 113 |
], |
| 114 |
] |
| 115 |
); |
| 116 |
|
| 117 |
$this->add_control( |
| 118 |
'button_margin', |
| 119 |
[ |
| 120 |
'label' => __( 'Button Margin', 'propertyhive' ), |
| 121 |
'type' => \Elementor\Controls_Manager::DIMENSIONS, |
| 122 |
'size_units' => [ 'px' ], |
| 123 |
'selectors' => [ |
| 124 |
'{{WRAPPER}} .property_actions ul li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 125 |
], |
| 126 |
'default' => [ |
| 127 |
'top' => 0, |
| 128 |
'right' => 0, |
| 129 |
'bottom' => 0, |
| 130 |
'left' => 0, |
| 131 |
'isLinked' => true, |
| 132 |
], |
| 133 |
'condition' => [ |
| 134 |
'display' => 'buttons' |
| 135 |
], |
| 136 |
] |
| 137 |
); |
| 138 |
|
| 139 |
$this->end_controls_section(); |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
protected function render() { |
| 144 |
|
| 145 |
global $property; |
| 146 |
|
| 147 |
$settings = $this->get_settings_for_display(); |
| 148 |
|
| 149 |
if ( !isset($property->id) ) { |
| 150 |
return; |
| 151 |
} |
| 152 |
|
| 153 |
if ( isset($settings['display']) && $settings['display'] == 'buttons' ) |
| 154 |
{ |
| 155 |
echo '<style type="text/css">'; |
| 156 |
echo '.property_actions ul { list-style-type:none; margin:0; padding:0; }'; |
| 157 |
echo '.property_actions ul li { display:inline-block; }'; |
| 158 |
echo '.property_actions ul li a { display:block; }'; |
| 159 |
echo '</style>'; |
| 160 |
} |
| 161 |
|
| 162 |
propertyhive_template_single_actions(); |
| 163 |
|
| 164 |
} |
| 165 |
} |