𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/builxejc/public_html/wp-content/plugins/kinsley-plugin/elementor/widgets//map.php
<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Kinsley Map Widget.
*
* @since 1.0
*/
class Kinsley_Map_Widget extends Widget_Base {
public function get_name() {
return 'kinsley-map';
}
public function get_title() {
return esc_html__( 'Map (mapbox)', 'kinsley-plugin' );
}
public function get_icon() {
return 'eicon-parallax';
}
public function get_categories() {
return [ 'kinsley-category' ];
}
/**
* Register widget controls.
*
* @since 1.0
*/
protected function register_controls() {
$this->start_controls_section(
'content_tab',
[
'label' => esc_html__( 'Content', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'kinsley-plugin' ),
'type' => Controls_Manager::TEXTAREA,
'placeholder' => esc_html__( 'Enter title', 'kinsley-plugin' ),
'default' => esc_html__( 'Title', 'kinsley-plugin' ),
]
);
$this->add_control(
'map_lng',
[
'label' => esc_html__( 'Longitude', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter lng value', 'kinsley-plugin' ),
'default' => esc_html__( '-70.00133907824335', 'kinsley-plugin' ),
]
);
$this->add_control(
'map_lat',
[
'label' => esc_html__( 'Latitude', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter lat value', 'kinsley-plugin' ),
'default' => esc_html__( '18.49315226156898', 'kinsley-plugin' ),
]
);
$this->add_control(
'map_zoom',
[
'label' => esc_html__( 'Zoom', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::NUMBER,
'default' => 13,
]
);
$this->add_control(
'map_style',
[
'label' => esc_html__( 'Style', 'kinsley-plugin' ),
'label_block' => true,
'type' => Controls_Manager::SELECT,
'default' => 'default',
'options' => [
'default' => __( 'Default', 'kinsley-plugin' ),
'light-v10' => __( 'Light', 'kinsley-plugin' ),
'dark-v10' => __( 'Dark', 'kinsley-plugin' ),
'streets-v11' => __( 'Streets', 'kinsley-plugin' ),
'outdoors-v11' => __( 'Outdoors', 'kinsley-plugin' ),
'satellite-v9' => __( 'Satellite', 'kinsley-plugin' ),
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'content_styling',
[
'label' => esc_html__( 'Styling', 'kinsley-plugin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .row h3' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Title Typography', 'kinsley-plugin' ),
'selector' => '{{WRAPPER}} .row h3',
]
);
$this->add_control(
'marker_color1',
[
'label' => esc_html__( 'Marker Color #1', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .mapboxgl-marker svg g' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'marker_color2',
[
'label' => esc_html__( 'Marker Color #2', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .mapboxgl-marker svg circle' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'map_border_color',
[
'label' => esc_html__( 'Map Border Color', 'kinsley-plugin' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .knsl-map-frame' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_section();
}
/**
* Render widget output on the frontend.
*
* @since 1.0
*/
protected function render() {
$settings = $this->get_settings_for_display();
$this->add_inline_editing_attributes( 'title', 'basic' );
$map_key = get_field( 'mapbox_key', 'options' );
?>
<!-- map -->
<section>
<div class="row">
<?php if ( $settings['title'] ) : ?>
<div class="col-lg-12">
<h3 class="knsl-mb-40 knsl-scroll-animation">
<span <?php echo $this->get_render_attribute_string( 'title' ); ?>>
<?php echo wp_kses_post( $settings['title'] ); ?>
</span>
</h3>
</div>
<?php endif; ?>
<div class="col-lg-12">
<div class="knsl-map-frame knsl-mb-60">
<div class="knsl-lock"><i class="fas fa-lock"></i></div>
<div id="map" class="knsl-map" data-key="<?php echo esc_attr( $map_key ); ?>" data-style="<?php echo esc_attr( $settings['map_style'] ); ?>" data-zoom="<?php echo esc_attr( $settings['map_zoom'] ); ?>" data-lng="<?php echo esc_attr( $settings['map_lng'] ); ?>" data-lat="<?php echo esc_attr( $settings['map_lat'] ); ?>"></div>
</div>
</div>
</div>
</section>
<!-- map end -->
<?php
}
/**
* Render widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @since 1.0.0
* @access protected
*/
protected function content_template() {
?>
<#
view.addInlineEditingAttributes( 'title', 'basic' );
#>
<!-- map -->
<section>
<div class="row">
<# if ( settings.title ) { #>
<div class="col-lg-12">
<h3 class="knsl-mb-40 knsl-scroll-animation">
<span {{{ view.getRenderAttributeString( 'title' ) }}}>
{{{ settings.title }}}
</span>
</h3>
</div>
<# } #>
<div class="col-lg-12">
<div class="knsl-map-frame knsl-mb-60">
<div class="knsl-lock"><i class="fas fa-lock"></i></div>
<div id="map" class="knsl-map" data-zoom="{{{ settings.map_zoom }}}" data-lng="{{{ settings.map_lng }}}" data-lat="{{{ settings.map_lat }}}"></div>
</div>
</div>
</div>
</section>
<!-- map end -->
<?php
}
}
Plugin::instance()->widgets_manager->register( new Kinsley_Map_Widget() );