99 lines
2.9 KiB
PHP
99 lines
2.9 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\PageBuilder\Addons\Common;
|
|
|
|
|
|
use App\FormBuilder;
|
|
use App\Helpers\FormBuilderCustom;
|
|
use App\Helpers\LanguageHelper;
|
|
use App\Helpers\SanitizeInput;
|
|
use App\PageBuilder\Fields\IconPicker;
|
|
use App\PageBuilder\Fields\Image;
|
|
use App\PageBuilder\Fields\Repeater;
|
|
use App\PageBuilder\Fields\Select;
|
|
use App\PageBuilder\Fields\Slider;
|
|
use App\PageBuilder\Fields\Text;
|
|
use App\PageBuilder\Fields\Textarea;
|
|
use App\PageBuilder\Helpers\RepeaterField;
|
|
use App\PageBuilder\Helpers\Traits\RepeaterHelper;
|
|
use App\PageBuilder\PageBuilderBase;
|
|
|
|
class GoogleMap extends PageBuilderBase
|
|
{
|
|
use RepeaterHelper;
|
|
/**
|
|
* preview_image
|
|
* this method must have to implement by all widget to show a preview image at admin panel so that user know about the design which he want to use
|
|
* @since 1.0.0
|
|
* */
|
|
public function preview_image()
|
|
{
|
|
return 'common/googlemap.png';
|
|
}
|
|
|
|
/**
|
|
* admin_render
|
|
* this method must have to implement by all widget to render admin panel widget content
|
|
* @since 1.0.0
|
|
* */
|
|
public function admin_render()
|
|
{
|
|
$output = $this->admin_form_before();
|
|
$output .= $this->admin_form_start();
|
|
$output .= $this->default_fields();
|
|
$widget_saved_values = $this->get_settings();
|
|
|
|
$output .= Text::get([
|
|
'name' => 'location',
|
|
'label' => __('Location'),
|
|
'value' => $widget_saved_values['location'] ?? null,
|
|
]);
|
|
|
|
$output .= Slider::get([
|
|
'name' => 'map_height',
|
|
'label' => __('Map Height'),
|
|
'value' => $widget_saved_values['map_height'] ?? 500,
|
|
'max' => 2000,
|
|
]);
|
|
$output .= $this->admin_form_submit_button();
|
|
$output .= $this->admin_form_end();
|
|
$output .= $this->admin_form_after();
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* frontend_render
|
|
* this method must have to implement by all widget to render frontend widget content
|
|
* @since 1.0.0
|
|
* */
|
|
public function frontend_render(): string
|
|
{
|
|
$all_settings = $this->get_settings();
|
|
$map_height = SanitizeInput::esc_html($all_settings['map_height']);
|
|
$location = SanitizeInput::esc_html($all_settings['location']);
|
|
$location = sprintf(
|
|
'<div class="custom-embed-map"><iframe frameborder="0" scrolling="no" marginheight="0" height="'.$map_height.'px" marginwidth="0" src="https://maps.google.com/maps?q=%s&t=m&z=%d&output=embed&iwloc=near" aria-label="%s"></iframe></div>',
|
|
rawurlencode($location),
|
|
10,
|
|
$location
|
|
);
|
|
|
|
return <<<HTML
|
|
<div class="googlemap-area">
|
|
{$location}
|
|
</div>
|
|
HTML;
|
|
}
|
|
|
|
/**
|
|
* widget_title
|
|
* this method must have to implement by all widget to register widget title
|
|
* @since 1.0.0
|
|
* */
|
|
public function addon_title()
|
|
{
|
|
return __('Google Map: 01');
|
|
}
|
|
} |