| 1 |
<?php |
| 2 |
/** |
| 3 |
* Bricks Builder Property Street View Widget. |
| 4 |
* |
| 5 |
* @since 1.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 9 |
|
| 10 |
class Bricks_Builder_Property_Street_View_Widget extends \Bricks\Element { |
| 11 |
|
| 12 |
// Element properties |
| 13 |
public $category = 'propertyhive'; |
| 14 |
public $name = 'bricks-builder-property-street-view'; |
| 15 |
public $icon = 'fas fa-street-view'; |
| 16 |
public $scripts = ['initialize_property_street_view']; |
| 17 |
|
| 18 |
public function get_label() |
| 19 |
{ |
| 20 |
return esc_html__( 'Street View', 'propertyhive' ); |
| 21 |
} |
| 22 |
|
| 23 |
// Enqueue element styles and scripts |
| 24 |
public function enqueue_scripts() |
| 25 |
{ |
| 26 |
$suffix = ''; |
| 27 |
$assets_path = str_replace( array( 'http:', 'https:' ), '', PH()->plugin_url() ) . '/assets/'; |
| 28 |
|
| 29 |
if ( get_option('propertyhive_maps_provider') == 'osm' ) |
| 30 |
{ |
| 31 |
|
| 32 |
} |
| 33 |
else |
| 34 |
{ |
| 35 |
$api_key = get_option('propertyhive_google_maps_api_key'); |
| 36 |
wp_register_script('googlemaps', '//maps.googleapis.com/maps/api/js?' . ( ( $api_key != '' && $api_key !== FALSE ) ? 'key=' . $api_key : '' ), false, '3'); |
| 37 |
wp_enqueue_script('googlemaps'); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
public function set_control_groups() |
| 42 |
{ |
| 43 |
/*$this->control_groups['form'] = [ |
| 44 |
'title' => esc_html__( 'Form', 'propertyhive' ), |
| 45 |
'tab' => 'content', // content / style |
| 46 |
];*/ |
| 47 |
} |
| 48 |
|
| 49 |
public function set_controls() |
| 50 |
{ |
| 51 |
$this->controls['height'] = [ |
| 52 |
'tab' => 'content', |
| 53 |
//'group' => 'settings', |
| 54 |
'label' => esc_html__( 'Height', 'propertyhive' ), |
| 55 |
'type' => 'number', |
| 56 |
'default' => 400 |
| 57 |
]; |
| 58 |
} |
| 59 |
|
| 60 |
public function render() |
| 61 |
{ |
| 62 |
global $property; |
| 63 |
|
| 64 |
if ( !isset($property->id) ) |
| 65 |
{ |
| 66 |
return; |
| 67 |
} |
| 68 |
|
| 69 |
if ( $property->latitude == '' || $property->longitude == '' || $property->latitude == '0' || $property->longitude == '0' ) |
| 70 |
{ |
| 71 |
return; |
| 72 |
} |
| 73 |
|
| 74 |
if ( get_option('propertyhive_maps_provider') == 'osm' ) |
| 75 |
{ |
| 76 |
return; |
| 77 |
} |
| 78 |
|
| 79 |
$root_classes[] = $this->name; |
| 80 |
|
| 81 |
// Add 'class' attribute to element root tag |
| 82 |
$this->set_attribute( '_root', 'class', $root_classes ); |
| 83 |
|
| 84 |
echo "<div {$this->render_attributes( '_root' )}>"; |
| 85 |
|
| 86 |
$attributes = array(); |
| 87 |
if ( isset($this->settings['height']) && $this->settings['height'] != '' ) |
| 88 |
{ |
| 89 |
$attributes['height'] = $this->settings['height']; |
| 90 |
} |
| 91 |
|
| 92 |
get_property_street_view($attributes); |
| 93 |
|
| 94 |
echo '</div>'; |
| 95 |
} |
| 96 |
} |