| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
class Divi_Property_Actions_Widget extends ET_Builder_Module |
| 7 |
{ |
| 8 |
public $slug = 'et_pb_property_actions_widget'; |
| 9 |
public $vb_support = 'partial'; |
| 10 |
public $icon = ''; |
| 11 |
|
| 12 |
public function init() { |
| 13 |
$this->name = esc_html__( 'Property Actions', 'propertyhive' ); |
| 14 |
$this->icon = '|'; |
| 15 |
$this->main_css_element = '%%order_class%%'; |
| 16 |
} |
| 17 |
|
| 18 |
public function get_fields() |
| 19 |
{ |
| 20 |
$fields = array( |
| 21 |
'display' => array( |
| 22 |
'label' => __( 'Display As', 'propertyhive' ), |
| 23 |
'type' => 'select', |
| 24 |
'options' => [ |
| 25 |
'list' => __( 'List', 'propertyhive' ), |
| 26 |
'buttons' => __( 'Buttons', 'propertyhive' ), |
| 27 |
], |
| 28 |
'toggle_slug' => 'main_content', |
| 29 |
), |
| 30 |
); |
| 31 |
|
| 32 |
return $fields; |
| 33 |
} |
| 34 |
|
| 35 |
public function render( $attrs, $content, $render_slug ) |
| 36 |
{ |
| 37 |
$post_id = get_the_ID(); |
| 38 |
|
| 39 |
$property = new PH_Property($post_id); |
| 40 |
|
| 41 |
if ( !isset($property->id) ) { |
| 42 |
return; |
| 43 |
} |
| 44 |
|
| 45 |
ob_start(); |
| 46 |
|
| 47 |
if ( isset($this->props['display']) && $this->props['display'] == 'buttons' ) |
| 48 |
{ |
| 49 |
echo '<style type="text/css">'; |
| 50 |
echo '.property_actions ul { list-style-type:none; margin:0; padding:0; }'; |
| 51 |
echo '.property_actions ul li { display:inline-block; }'; |
| 52 |
echo '.property_actions ul li a { display:block; }'; |
| 53 |
echo '</style>'; |
| 54 |
} |
| 55 |
|
| 56 |
propertyhive_template_single_actions(); |
| 57 |
|
| 58 |
return $this->_render_module_wrapper( ob_get_clean(), $render_slug ); |
| 59 |
} |
| 60 |
} |