| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
class Divi_Property_Map_Widget extends ET_Builder_Module |
| 7 |
{ |
| 8 |
public $slug = 'et_pb_property_map_widget'; |
| 9 |
public $vb_support = 'partial'; |
| 10 |
public $icon = ''; |
| 11 |
|
| 12 |
public function init() { |
| 13 |
$this->name = esc_html__( 'Property Map', 'propertyhive' ); |
| 14 |
$this->icon = 'Y'; |
| 15 |
} |
| 16 |
|
| 17 |
public function get_fields() |
| 18 |
{ |
| 19 |
$fields = array( |
| 20 |
'map_height' => array( |
| 21 |
'label' => __( 'Height (px)', 'propertyhive' ), |
| 22 |
'type' => 'number', |
| 23 |
'toggle_slug' => 'main_content', |
| 24 |
'default' => 400 |
| 25 |
), |
| 26 |
'zoom' => array( |
| 27 |
'label' => __( 'Zoom', 'propertyhive' ), |
| 28 |
'type' => 'number', |
| 29 |
'toggle_slug' => 'main_content', |
| 30 |
'default' => 14 |
| 31 |
), |
| 32 |
'scrollwheel' => array( |
| 33 |
'label' => __( 'Scrollwheel Zoom', 'propertyhive' ), |
| 34 |
'type' => 'select', |
| 35 |
'toggle_slug' => 'main_content', |
| 36 |
'options' => [ |
| 37 |
'true' => __( 'True', 'propertyhive' ), |
| 38 |
'false' => __( 'False', 'propertyhive' ), |
| 39 |
], |
| 40 |
'default' => 'true' |
| 41 |
), |
| 42 |
); |
| 43 |
|
| 44 |
return $fields; |
| 45 |
} |
| 46 |
|
| 47 |
public function render( $attrs, $content, $render_slug ) |
| 48 |
{ |
| 49 |
$post_id = get_the_ID(); |
| 50 |
|
| 51 |
$property = new PH_Property($post_id); |
| 52 |
|
| 53 |
if ( !isset($property->id) ) { |
| 54 |
return; |
| 55 |
} |
| 56 |
|
| 57 |
ob_start(); |
| 58 |
|
| 59 |
$attributes = array(); |
| 60 |
if ( isset($this->props['map_height']) && $this->props['map_height'] != '' ) |
| 61 |
{ |
| 62 |
$attributes['height'] = $this->props['map_height']; |
| 63 |
} |
| 64 |
if ( isset($this->props['zoom']) && isset($this->props['zoom']) && $this->props['zoom'] != '' ) |
| 65 |
{ |
| 66 |
$attributes['zoom'] = $this->props['zoom']; |
| 67 |
} |
| 68 |
if ( isset($this->props['scrollwheel']) && $this->props['scrollwheel'] != '' ) |
| 69 |
{ |
| 70 |
$attributes['scrollwheel'] = $this->props['scrollwheel']; |
| 71 |
} |
| 72 |
|
| 73 |
get_property_map($attributes); |
| 74 |
|
| 75 |
return $this->_render_module_wrapper( ob_get_clean(), $render_slug ); |
| 76 |
} |
| 77 |
} |