| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
class Divi_Property_Street_View_Widget extends ET_Builder_Module |
| 7 |
{ |
| 8 |
public $slug = 'et_pb_property_street_view_widget'; |
| 9 |
public $vb_support = 'partial'; |
| 10 |
public $icon = ''; |
| 11 |
|
| 12 |
public function init() { |
| 13 |
$this->name = esc_html__( 'Property Street View', '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 |
); |
| 27 |
|
| 28 |
return $fields; |
| 29 |
} |
| 30 |
|
| 31 |
public function render( $attrs, $content, $render_slug ) |
| 32 |
{ |
| 33 |
$post_id = get_the_ID(); |
| 34 |
|
| 35 |
$property = new PH_Property($post_id); |
| 36 |
|
| 37 |
if ( !isset($property->id) ) { |
| 38 |
return; |
| 39 |
} |
| 40 |
|
| 41 |
ob_start(); |
| 42 |
|
| 43 |
$attributes = array(); |
| 44 |
if ( isset($this->props['map_height']) && $this->props['map_height'] != '' ) |
| 45 |
{ |
| 46 |
$attributes['height'] = $this->props['map_height']; |
| 47 |
} |
| 48 |
|
| 49 |
get_property_street_view($attributes); |
| 50 |
|
| 51 |
return $this->_render_module_wrapper( ob_get_clean(), $render_slug ); |
| 52 |
} |
| 53 |
} |