From c3802d461d2a4db2f21a031fdbadd7fa7dc6f498 Mon Sep 17 00:00:00 2001 From: Ali7Ali Date: Wed, 18 Dec 2024 06:38:36 +0400 Subject: [PATCH] Compatibility for the updated Elementor colors and typography schema. --- README.md | 10 +- alpha-google-map-for-elementor.php | 8 +- include/class-alpha-google-map-widget.php | 2242 ++++++++++----------- include/class-alpha-google-map.php | 100 +- readme.txt | 9 +- 5 files changed, 1205 insertions(+), 1164 deletions(-) diff --git a/README.md b/README.md index 9fc81a8..969ef75 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ **Requires at least:** 6.0 **Tested up to:** 6.7 **Requires PHP:** 7.4 -**Stable tag:** 1.2.1 +**Stable tag:** 1.2.2 **License:** [GPLv3](https://www.gnu.org/licenses/gpl-3.0.html) Alpha Google Map For Elementor offers premium Google Map features for WordPress, enhancing your site with advanced map functionalities. @@ -74,9 +74,9 @@ Use the WordPress.org forums for community support. If you spot a bug, you can l ## Upgrade Notice -### 1.2.1 +### 1.2.2 -Compatibility for WP 6.7 and security improvements, code modernization, and compatibility updates. +Compatibility for WP 6.6 and refactor the integration with Elementor. ## Frequently Asked Questions @@ -96,6 +96,10 @@ No. You need to install Elementor Website Builder first. ## Changelog +### 1.2.2 - 2024-12-18 + +- Compatibility for the updated Elementor colors and typography schema. + ### 1.2.1 - 2024-11-16 - Enhanced compatibility with the latest WordPress and Elementor versions. diff --git a/alpha-google-map-for-elementor.php b/alpha-google-map-for-elementor.php index 2c5f2a4..a36aeaf 100644 --- a/alpha-google-map-for-elementor.php +++ b/alpha-google-map-for-elementor.php @@ -6,12 +6,10 @@ * Description: Premium Google Map features for WordPress. * Author: Ali Ali * Author URI: https://github.com/Ali7Ali - * Version: 1.2.1 + * Version: 1.2.2 * Text Domain: alpha-google-map-for-elementor * Domain Path: /languages * License: GPLv3 - * - * * */ /* @@ -36,7 +34,7 @@ exit; // Exit if accessed directly. } -define('ALPHAMAP_VERSION', '1.2.1'); +define('ALPHAMAP_VERSION', '1.2.2'); define('ALPHAMAP_ADDONS_PL_ROOT', __FILE__); define('ALPHAMAP_PL_URL', plugins_url('/', ALPHAMAP_ADDONS_PL_ROOT)); define('ALPHAMAP_PL_PATH', plugin_dir_path(ALPHAMAP_ADDONS_PL_ROOT)); @@ -49,7 +47,7 @@ function alpha_google_map_addon() { // Load plugin file - require_once(ALPHAMAP_PL_INCLUDE . '/class-alpha-google-map.php'); + include_once ALPHAMAP_PL_INCLUDE . '/class-alpha-google-map.php'; // Run the plugin \AlphaGoogleMap\Alpha_Google_Map::instance(); diff --git a/include/class-alpha-google-map-widget.php b/include/class-alpha-google-map-widget.php index df8ced3..96b7cda 100644 --- a/include/class-alpha-google-map-widget.php +++ b/include/class-alpha-google-map-widget.php @@ -1,1121 +1,1121 @@ -start_controls_section( - 'section_header', - array( - 'label' => __('Map Window Location', 'alpha-google-map-for-elementor'), - ) - ); - - $api_key = get_option('elementor_google_maps_api_key'); - if (!$api_key) { - $this->add_control( - 'api_key_notification', - [ - 'type' => Controls_Manager::RAW_HTML, - 'raw' => sprintf( - /* translators: 1: Integration settings link open tag, 2: Create API key link open tag, 3: Link close tag. */ - esc_html__('Set your Google Maps API Key in Elementor\'s %1$sIntegrations Settings%3$s page. Create your key %2$shere.%3$s', 'alpha-google-map-for-elementor'), - '', - '', - '' - ), - 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', - ] - ); - } - - $this->add_control( - 'check_demo', - [ - 'type' => Controls_Manager::RAW_HTML, - 'raw' => sprintf( - /* translators: 1: Demo link open tag, 2: Link close tag. */ - esc_html__('Check this widget demo %1$shere%2$s.', 'alpha-google-map-for-elementor'), - '', - '' - ), - 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', - ] - ); - - $this->add_control( - 'alpha_location_lat', - array( - 'label' => __('Location Latitude', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::TEXT, - 'dynamic' => array('active' => true), - 'description' => __('Enter your location latitude', 'alpha-google-map-for-elementor'), - 'default' => '51.501156639895136', - 'label_block' => true, - ) - ); - - $this->add_control( - 'alpha_location_long', - array( - 'label' => __('Location Longitude', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::TEXT, - 'dynamic' => array('active' => true), - 'description' => __('Enter your location longitude', 'alpha-google-map-for-elementor'), - 'default' => '-0.12479706299020504', - 'label_block' => true, - ) - ); - - $this->end_controls_section(); - - $this->start_controls_section( - 'alpha_map_pins_settings', - array( - 'label' => __('Markers', 'alpha-google-map-for-elementor'), - ) - ); - - $this->add_control( - 'alpha_markers_width', - array( - 'label' => __('Max Width', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::NUMBER, - 'title' => __('Set the Maximum width for markers description box', 'alpha-google-map-for-elementor'), - ) - ); - - $repeater = new REPEATER(); - $upload_dir = wp_upload_dir(); - $repeater->add_control( - 'pin_icon', - array( - 'label' => __('Custom Icon', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::MEDIA, - 'default' => array( - 'url' => $upload_dir['baseurl'] . '/alpha-map/alpha-pin.png', - ), - 'dynamic' => array('active' => true), - ) - ); - - $repeater->add_control( - 'pin_active_icon', - array( - 'label' => __('Icon On Active Pin', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::MEDIA, - 'default' => array( - 'url' => $upload_dir['baseurl'] . '/alpha-map/alpha-pin-hover.png', - ), - 'dynamic' => array('active' => true), - 'label_block' => true, - ) - ); - - $repeater->add_control( - 'pin_icon_size', - array( - 'label' => __('Size', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SLIDER, - 'size_units' => array('px', 'em'), - 'range' => array( - 'px' => array( - 'min' => 1, - 'max' => 200, - ), - 'em' => array( - 'min' => 1, - 'max' => 20, - ), - ), - ) - ); - - $repeater->add_control( - 'map_latitude', - array( - 'label' => __('Pin Latitude', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::TEXT, - 'dynamic' => array('active' => true), - 'label_block' => true, - ) - ); - - $repeater->add_control( - 'map_longitude', - array( - 'label' => __('Pin Longitude', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::TEXT, - 'dynamic' => array('active' => true), - 'label_block' => true, - ) - ); - - $repeater->add_control( - 'pin_title', - array( - 'label' => __('Title', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::TEXT, - 'dynamic' => array('active' => true), - 'label_block' => true, - ) - ); - - $repeater->add_control( - 'pin_desc', - array( - 'label' => __('Description', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::WYSIWYG, - 'dynamic' => array('active' => true), - 'label_block' => true, - ) - ); - - $repeater->add_control( - 'pin_time_desc', - array( - 'label' => __('Time Table', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::WYSIWYG, - 'dynamic' => array('active' => true), - 'label_block' => true, - ) - ); - - $repeater->add_control( - 'pin_desc_gallery', - array( - 'label' => __('Pin Gallery', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::GALLERY, - 'dynamic' => array('active' => true), - 'label_block' => true, - ) - ); - - $this->add_control( - 'alpha_map_pins', - array( - 'label' => __('Map Pins', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::REPEATER, - 'default' => array( - 'map_latitude' => '51.501156639895136', - 'map_longitude' => '-0.12479706299020504', - 'pin_title' => __('Alpha Google Maps', 'alpha-google-map-for-elementor'), - 'pin_desc' => __('Add an optional description to your map pin', 'alpha-google-map-for-elementor'), - 'pin_time_desc' => __('Add a time table for the location pin', 'alpha-google-map-for-elementor'), - ), - 'fields' => $repeater->get_controls(), - 'title_field' => '{{{ pin_title }}}', - ) - ); - - $this->end_controls_section(); - - $this->start_controls_section( - 'alpha_map_controls_section', - array( - 'label' => __('Controls', 'alpha-google-map-for-elementor'), - ) - ); - - $this->add_control( - 'alpha_map_type', - array( - 'label' => __('Map Type', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SELECT, - 'options' => array( - 'roadmap' => __('Road Map', 'alpha-google-map-for-elementor'), - 'satellite' => __('Satellite', 'alpha-google-map-for-elementor'), - 'terrain' => __('Terrain', 'alpha-google-map-for-elementor'), - 'hybrid' => __('Hybrid', 'alpha-google-map-for-elementor'), - ), - 'default' => 'roadmap', - ) - ); - - $this->add_responsive_control( - 'alpha_map_height', - array( - 'label' => __('Height', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SLIDER, - 'default' => array( - 'size' => 500, - ), - 'range' => array( - 'px' => array( - 'min' => 80, - 'max' => 1400, - ), - ), - 'selectors' => array( - '{{WRAPPER}} .alpha_map_height' => 'height: {{SIZE}}px;', - ), - ) - ); - - $this->add_control( - 'alpha_map_zoom', - array( - 'label' => __('Zoom', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SLIDER, - 'default' => array( - 'size' => 12, - ), - 'range' => array( - 'px' => array( - 'min' => 0, - 'max' => 22, - ), - ), - ) - ); - - $this->add_control( - 'disable_drag', - array( - 'label' => __('Disable Map Drag', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SWITCHER, - ) - ); - - $this->add_control( - 'alpha_map_option_map_type_control', - array( - 'label' => __('Map Type Controls', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SWITCHER, - ) - ); - - $this->add_control( - 'alpha_map_option_zoom_controls', - array( - 'label' => __('Zoom Controls', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SWITCHER, - ) - ); - - $this->add_control( - 'alpha_map_option_streeview', - array( - 'label' => __('Street View Control', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SWITCHER, - ) - ); - - $this->add_control( - 'alpha_map_option_fullscreen_control', - array( - 'label' => __('Fullscreen Control', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SWITCHER, - ) - ); - - $this->add_control( - 'alpha_map_option_mapscroll', - array( - 'label' => __('Scroll Wheel Zoom', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SWITCHER, - ) - ); - - $this->add_control( - 'alpha_map_marker_open', - array( - 'label' => __('Info Container Always Opened', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SWITCHER, - ) - ); - - $this->add_control( - 'alpha_map_marker_hover_open', - array( - 'label' => __('Info Container Opened when Hovered', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SWITCHER, - ) - ); - - $this->add_control( - 'alpha_map_marker_mouse_out', - array( - 'label' => __('Info Container Closed when Mouse Out', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SWITCHER, - 'condition' => [ - 'alpha_map_marker_hover_open' => 'yes', - ], - ) - ); - - $this->end_controls_section(); - - $this->start_controls_section( - 'alpha_pin_title_style', - array( - 'label' => __('Title', 'alpha-google-map-for-elementor'), - 'tab' => Controls_Manager::TAB_STYLE, - ) - ); - - $this->add_control( - 'alpha_pin_title_color', - array( - 'label' => __('Color', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::COLOR, - 'scheme' => array( - 'type' => Color::get_type(), - 'value' => Color::COLOR_1, - ), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-title' => 'color: {{VALUE}};', - ), - ) - ); - - $this->add_group_control( - Group_Control_Typography::get_type(), - array( - 'name' => 'pin_title_typography', - 'scheme' => Typography::TYPOGRAPHY_1, - 'selector' => '{{WRAPPER}} .alpha-map-info-title', - ) - ); - - $this->add_responsive_control( - 'alpha_pin_title_margin', - array( - 'label' => __('Margin', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ), - ) - ); - - $this->add_responsive_control( - 'alpha_pin_title_padding', - array( - 'label' => __('Padding', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ), - ) - ); - - $this->add_responsive_control( - 'alpha_pin_title_align', - array( - 'label' => __('Alignment', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::CHOOSE, - 'options' => array( - 'left' => array( - 'title' => __('Left', 'alpha-google-map-for-elementor'), - 'icon' => 'fa fa-align-left', - ), - 'center' => array( - 'title' => __('Center', 'alpha-google-map-for-elementor'), - 'icon' => 'fa fa-align-center', - ), - 'right' => array( - 'title' => __('Right', 'alpha-google-map-for-elementor'), - 'icon' => 'fa fa-align-right', - ), - ), - 'default' => 'center', - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-title' => 'text-align: {{VALUE}};', - ), - ) - ); - - $this->end_controls_section(); - - $this->start_controls_section( - 'alpha_pin_text_style', - array( - 'label' => __('Description', 'alpha-google-map-for-elementor'), - 'tab' => Controls_Manager::TAB_STYLE, - ) - ); - - $this->add_control( - 'alpha_pin_text_color', - array( - 'label' => __('Color', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::COLOR, - 'scheme' => array( - 'type' => Color::get_type(), - 'value' => Color::COLOR_2, - ), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-desc' => 'color: {{VALUE}};', - ), - ) - ); - - $this->add_group_control( - Group_Control_Typography::get_type(), - array( - 'name' => 'pin_text_typo', - 'scheme' => Typography::TYPOGRAPHY_1, - 'selector' => '{{WRAPPER}} .alpha-map-info-desc', - ) - ); - - $this->add_responsive_control( - 'alpha_pin_text_margin', - array( - 'label' => __('Margin', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-desc' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ), - ) - ); - - $this->add_responsive_control( - 'alpha_pin_text_padding', - array( - 'label' => __('Padding', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-desc' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ), - ) - ); - - $this->add_responsive_control( - 'alpha_pin_description_align', - array( - 'label' => __('Alignment', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::CHOOSE, - 'options' => array( - 'left' => array( - 'title' => __('Left', 'alpha-google-map-for-elementor'), - 'icon' => 'fa fa-align-left', - ), - 'center' => array( - 'title' => __('Center', 'alpha-google-map-for-elementor'), - 'icon' => 'fa fa-align-center', - ), - 'right' => array( - 'title' => __('Right', 'alpha-google-map-for-elementor'), - 'icon' => 'fa fa-align-right', - ), - ), - 'default' => 'center', - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-desc' => 'text-align: {{VALUE}};', - ), - ) - ); - - $this->end_controls_section(); - - $this->start_controls_section( - 'alpha_pin_time_style', - array( - 'label' => __('Time Table', 'alpha-google-map-for-elementor'), - 'tab' => Controls_Manager::TAB_STYLE, - ) - ); - - $this->add_control( - 'alpha_pin_time_color', - array( - 'label' => __('Color', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::COLOR, - 'scheme' => array( - 'type' => Color::get_type(), - 'value' => Color::COLOR_2, - ), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-time-desc' => 'color: {{VALUE}};', - ), - ) - ); - - $this->add_group_control( - Group_Control_Typography::get_type(), - array( - 'name' => 'pin_time_typo', - 'scheme' => Typography::TYPOGRAPHY_1, - 'selector' => '{{WRAPPER}} .alpha-map-info-time-desc', - ) - ); - - $this->add_responsive_control( - 'alpha_pin_time_margin', - array( - 'label' => __('Margin', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-time-desc' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ), - ) - ); - - $this->add_responsive_control( - 'alpha_pin_time_padding', - array( - 'label' => __('Padding', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-time-desc' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ), - ) - ); - - $this->add_responsive_control( - 'alpha_pin_time_align', - array( - 'label' => __('Alignment', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::CHOOSE, - 'options' => array( - 'left' => array( - 'title' => __('Left', 'alpha-google-map-for-elementor'), - 'icon' => 'fa fa-align-left', - ), - 'center' => array( - 'title' => __('Center', 'alpha-google-map-for-elementor'), - 'icon' => 'fa fa-align-center', - ), - 'right' => array( - 'title' => __('Right', 'alpha-google-map-for-elementor'), - 'icon' => 'fa fa-align-right', - ), - ), - 'default' => 'center', - 'selectors' => array( - '{{WRAPPER}} .alpha-map-info-time-desc' => 'text-align: {{VALUE}};', - ), - ) - ); - - $this->end_controls_section(); - - $this->start_controls_section( - 'alpha_box_style', - array( - 'label' => __('Map', 'alpha-google-map-for-elementor'), - 'tab' => Controls_Manager::TAB_STYLE, - ) - ); - - $this->add_group_control( - Group_Control_Border::get_type(), - array( - 'name' => 'map_border', - 'selector' => '{{WRAPPER}} .alpha-map-container', - ) - ); - - $this->add_control( - 'alpha_box_radius', - array( - 'label' => __('Border Radius', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SLIDER, - 'size_units' => array('px', '%', 'em'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-container,{{WRAPPER}} .alpha_map_height' => 'border-radius: {{SIZE}}{{UNIT}};', - ), - ) - ); - - $this->add_group_control( - Group_Control_Box_Shadow::get_type(), - array( - 'label' => __('Shadow', 'alpha-google-map-for-elementor'), - 'name' => 'alpha_map_box_shadow', - 'selector' => '{{WRAPPER}} .alpha-map-container', - ) - ); - - $this->add_responsive_control( - 'alpha_box_margin', - array( - 'label' => __('Margin', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-container' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}', - ), - ) - ); - - $this->add_responsive_control( - 'alpha_box_padding', - array( - 'label' => __('Padding', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-container' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}', - ), - ) - ); - - $this->end_controls_section(); - - // Map Title Controls. - $this->start_controls_section( - 'section_title', - array( - 'label' => __('Map Title', 'alpha-google-map-for-elementor'), - ) - ); - - $this->add_control( - 'title', - array( - 'label' => __('Map Title', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::TEXTAREA, - 'dynamic' => array( - 'active' => true, - ), - 'placeholder' => __('Enter your title', 'alpha-google-map-for-elementor'), - 'default' => __('Add Your Title Text Here', 'alpha-google-map-for-elementor'), - ) - ); - - $this->add_control( - 'link', - array( - 'label' => __('Link', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::URL, - 'dynamic' => array( - 'active' => true, - ), - 'default' => array( - 'url' => '', - ), - 'separator' => 'before', - ) - ); - - $this->add_control( - 'size', - array( - 'label' => __('Size', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SELECT, - 'default' => 'default', - 'options' => array( - 'default' => __('Default', 'alpha-google-map-for-elementor'), - 'small' => __('Small', 'alpha-google-map-for-elementor'), - 'medium' => __('Medium', 'alpha-google-map-for-elementor'), - 'large' => __('Large', 'alpha-google-map-for-elementor'), - 'xl' => __('XL', 'alpha-google-map-for-elementor'), - 'xxl' => __('XXL', 'alpha-google-map-for-elementor'), - ), - ) - ); - - $this->add_control( - 'header_size', - array( - 'label' => __('HTML Tag', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::SELECT, - 'options' => array( - 'h1' => 'H1', - 'h2' => 'H2', - 'h3' => 'H3', - 'h4' => 'H4', - 'h5' => 'H5', - 'h6' => 'H6', - 'div' => 'div', - 'span' => 'span', - 'p' => 'p', - ), - 'default' => 'h2', - ) - ); - - $this->add_responsive_control( - 'align', - array( - 'label' => __('Alignment', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::CHOOSE, - 'options' => array( - 'left' => array( - 'title' => __('Left', 'alpha-google-map-for-elementor'), - 'icon' => 'eicon-text-align-left', - ), - 'center' => array( - 'title' => __('Center', 'alpha-google-map-for-elementor'), - 'icon' => 'eicon-text-align-center', - ), - 'right' => array( - 'title' => __('Right', 'alpha-google-map-for-elementor'), - 'icon' => 'eicon-text-align-right', - ), - 'justify' => array( - 'title' => __('Justified', 'alpha-google-map-for-elementor'), - 'icon' => 'eicon-text-align-justify', - ), - ), - 'default' => '', - 'selectors' => array( - '{{WRAPPER}}' => 'text-align: {{VALUE}};', - ), - ) - ); - - $this->add_control( - 'view', - array( - 'label' => __('View', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::HIDDEN, - 'default' => 'traditional', - ) - ); - - $this->end_controls_section(); - - // Map Title Style. - $this->start_controls_section( - 'section_title_style', - array( - 'label' => __('Map Title', 'alpha-google-map-for-elementor'), - 'tab' => Controls_Manager::TAB_STYLE, - ) - ); - - $this->add_control( - 'title_color', - array( - 'label' => __('Text Color', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::COLOR, - 'global' => array( - 'default' => Global_Colors::COLOR_PRIMARY, - ), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-title' => 'color: {{VALUE}};', - ), - ) - ); - - $this->add_group_control( - Group_Control_Typography::get_type(), - array( - 'name' => 'typography', - 'global' => array( - 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, - ), - 'selector' => '{{WRAPPER}} .alpha-map-title', - ) - ); - - $this->add_group_control( - Group_Control_Text_Shadow::get_type(), - array( - 'name' => 'text_shadow', - 'selector' => '{{WRAPPER}} .alpha-map-title', - ) - ); - - $this->add_responsive_control( - 'title_margin', - array( - 'label' => __('Margin', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ), - ) - ); - - $this->add_responsive_control( - 'title_padding', - array( - 'label' => __('Padding', 'alpha-google-map-for-elementor'), - 'type' => Controls_Manager::DIMENSIONS, - 'size_units' => array('px', 'em', '%'), - 'selectors' => array( - '{{WRAPPER}} .alpha-map-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', - ), - ) - ); - - $this->end_controls_section(); - } - - /** - * Show the count of how many images left in the gallery - * - * @param string $link_html link for an image. - * @param string $id the id of an image. - * - * @return string|string[]|null - */ - public function add_lightbox_data_to_image_link($link_html, $id) - { - $settings = $this->get_settings_for_display(); - $open_lightbox = isset($settings['open_lightbox']) ? $settings['open_lightbox'] : null; - - if (Plugin::$instance->editor->is_edit_mode()) { - $this->add_render_attribute('link', 'class', 'elementor-clickable', true); - } - - $this->add_lightbox_data_attributes('link', $id, $open_lightbox, $this->get_id(), true); - return preg_replace('/^get_render_attribute_string('link'), $link_html); - } - - /** - * Render the widget on the frontend. - */ - protected function render() - { - $settings = $this->get_settings_for_display(); - - $map_pins = $settings['alpha_map_pins']; - - $street_view = 'yes' === $settings['alpha_map_option_streeview'] ? 'true' : 'false'; - - $scroll_wheel = 'yes' === $settings['alpha_map_option_mapscroll'] ? 'true' : 'false'; - - $full_screen = 'yes' === $settings['alpha_map_option_fullscreen_control'] ? 'true' : 'false'; - - $zoom_control = 'yes' === $settings['alpha_map_option_zoom_controls'] ? 'true' : 'false'; - - $type_control = 'yes' === $settings['alpha_map_option_map_type_control'] ? 'true' : 'false'; - - $automatic_open = 'yes' === $settings['alpha_map_marker_open'] ? 'true' : 'false'; - - $hover_open = 'yes' === $settings['alpha_map_marker_hover_open'] ? 'true' : 'false'; - - $hover_close = 'yes' === $settings['alpha_map_marker_mouse_out'] ? 'true' : 'false'; - - $locationlat = ! empty($settings['alpha_location_lat']) ? sanitize_text_field($settings['alpha_location_lat']) : '18.591212'; - - $locationlong = ! empty($settings['alpha_location_long']) ? sanitize_text_field($settings['alpha_location_long']) : '73.741261'; - - $marker_width = !empty($settings['alpha_markers_width']) ? $settings['alpha_markers_width'] : 1000; - - $map_settings = array( - 'zoom' => $settings['alpha_map_zoom']['size'], - 'maptype' => $settings['alpha_map_type'], - 'streetViewControl' => $street_view, - 'locationlat' => $locationlat, - 'locationlong' => $locationlong, - 'scrollwheel' => $scroll_wheel, - 'fullScreen' => $full_screen, - 'zoomControl' => $zoom_control, - 'typeControl' => $type_control, - 'automaticOpen' => $automatic_open, - 'hoverOpen' => $hover_open, - 'hoverClose' => $hover_close, - 'drag' => $settings['disable_drag'], - ); - - $this->add_render_attribute( - 'style_wrapper', - array( - 'class' => 'alpha_map_height', - 'data-settings' => wp_json_encode($map_settings), - ) - ); - -?> -
-
- add_render_attribute('title', 'class', 'alpha-map-title'); - // Check and add size class if provided - if (!empty($settings['size'])) { - $this->add_render_attribute('title', 'class', 'elementor-size-' . sanitize_html_class($settings['size'])); - } - // Allow inline editing of the title - $this->add_inline_editing_attributes('title'); - - // Sanitize the title - $title = sanitize_text_field($settings['title']); - // If a link is provided, sanitize and set attributes - if (!empty($settings['link']['url'])) { - $settings['link'] = wp_parse_args($settings['link'], ['url' => '', 'is_external' => '', 'nofollow' => '']); - $this->add_link_attributes('url', $settings['link']); - - $title = sprintf( - '%2$s', - $this->get_render_attribute_string('url'), - esc_html($title) - ); - } - - // Validate and sanitize the header size tag - $header_tag = Utils::validate_html_tag($settings['header_size']); - - // Construct the title HTML with proper escaping - $title_html = sprintf( - '<%1$s %2$s>%3$s', - esc_html($header_tag), - $this->get_render_attribute_string('title'), - $title - ); - - // Sanitize the entire output - echo wp_kses( - $title_html, - [ - 'a' => [ - 'href' => [], - 'target' => [], - 'rel' => [], - 'class' => [] - ], - $header_tag => [ - 'class' => [], - 'id' => [], - 'style' => [] - ] - ] - ); - } - ?> -
- -
get_render_attribute_string('style_wrapper')); ?>> - $pin) { - $key = 'map_marker_' . $index; - // Sanitize data before use - $latitude = isset($pin['map_latitude']) ? sanitize_text_field($pin['map_latitude']) : ''; - $longitude = isset($pin['map_longitude']) ? sanitize_text_field($pin['map_longitude']) : ''; - $icon_url = isset($pin['pin_icon']['url']) ? esc_url($pin['pin_icon']['url']) : ''; - $icon_active_url = isset($pin['pin_active_icon']['url']) ? esc_url($pin['pin_active_icon']['url']) : ''; - $icon_size = isset($pin['pin_icon_size']['size']) ? intval($pin['pin_icon_size']['size']) : ''; - $data_max_width = isset($marker_width) ? intval($marker_width) : ''; - $data_id = intval($index); - - $this->add_render_attribute( - $key, - array( - 'class' => 'alpha-pin', - 'data-lng' => $longitude, - 'data-lat' => $latitude, - 'data-icon' => $icon_url, - 'data-icon-active' => $icon_active_url, - 'data-icon-size' => $icon_size, - 'data-max-width' => $data_max_width, - 'data-id' => $data_id, - ) - ); - - // Sanitize IDs - $ids = array_map('intval', wp_list_pluck($pin['pin_desc_gallery'], 'id')); - $count = count($ids); - $data_count = absint($count - 4); - $this->add_render_attribute('shortcode' . $index, 'ids', implode(',', $ids)); - - ?> -
get_render_attribute_string($key)); ?>> - -
-

-
-
- - - -
- -
- -
- -
-start_controls_section( + 'section_header', + array( + 'label' => __('Map Window Location', 'alpha-google-map-for-elementor'), + ) + ); + + $api_key = get_option('elementor_google_maps_api_key'); + if (!$api_key) { + $this->add_control( + 'api_key_notification', + [ + 'type' => Controls_Manager::RAW_HTML, + 'raw' => sprintf( + /* translators: 1: Integration settings link open tag, 2: Create API key link open tag, 3: Link close tag. */ + esc_html__('Set your Google Maps API Key in Elementor\'s %1$sIntegrations Settings%3$s page. Create your key %2$shere.%3$s', 'alpha-google-map-for-elementor'), + '', + '', + '' + ), + 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', + ] + ); + } + + $this->add_control( + 'check_demo', + [ + 'type' => Controls_Manager::RAW_HTML, + 'raw' => sprintf( + /* translators: 1: Demo link open tag, 2: Link close tag. */ + esc_html__('Check this widget demo %1$shere%2$s.', 'alpha-google-map-for-elementor'), + '', + '' + ), + 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', + ] + ); + + $this->add_control( + 'alpha_location_lat', + array( + 'label' => __('Location Latitude', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::TEXT, + 'dynamic' => array('active' => true), + 'description' => __('Enter your location latitude', 'alpha-google-map-for-elementor'), + 'default' => '51.501156639895136', + 'label_block' => true, + ) + ); + + $this->add_control( + 'alpha_location_long', + array( + 'label' => __('Location Longitude', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::TEXT, + 'dynamic' => array('active' => true), + 'description' => __('Enter your location longitude', 'alpha-google-map-for-elementor'), + 'default' => '-0.12479706299020504', + 'label_block' => true, + ) + ); + + $this->end_controls_section(); + + $this->start_controls_section( + 'alpha_map_pins_settings', + array( + 'label' => __('Markers', 'alpha-google-map-for-elementor'), + ) + ); + + $this->add_control( + 'alpha_markers_width', + array( + 'label' => __('Max Width', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::NUMBER, + 'title' => __('Set the Maximum width for markers description box', 'alpha-google-map-for-elementor'), + ) + ); + + $repeater = new REPEATER(); + $upload_dir = wp_upload_dir(); + $repeater->add_control( + 'pin_icon', + array( + 'label' => __('Custom Icon', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::MEDIA, + 'default' => array( + 'url' => $upload_dir['baseurl'] . '/alpha-map/alpha-pin.png', + ), + 'dynamic' => array('active' => true), + ) + ); + + $repeater->add_control( + 'pin_active_icon', + array( + 'label' => __('Icon On Active Pin', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::MEDIA, + 'default' => array( + 'url' => $upload_dir['baseurl'] . '/alpha-map/alpha-pin-hover.png', + ), + 'dynamic' => array('active' => true), + 'label_block' => true, + ) + ); + + $repeater->add_control( + 'pin_icon_size', + array( + 'label' => __('Size', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SLIDER, + 'size_units' => array('px', 'em'), + 'range' => array( + 'px' => array( + 'min' => 1, + 'max' => 200, + ), + 'em' => array( + 'min' => 1, + 'max' => 20, + ), + ), + ) + ); + + $repeater->add_control( + 'map_latitude', + array( + 'label' => __('Pin Latitude', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::TEXT, + 'dynamic' => array('active' => true), + 'label_block' => true, + ) + ); + + $repeater->add_control( + 'map_longitude', + array( + 'label' => __('Pin Longitude', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::TEXT, + 'dynamic' => array('active' => true), + 'label_block' => true, + ) + ); + + $repeater->add_control( + 'pin_title', + array( + 'label' => __('Title', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::TEXT, + 'dynamic' => array('active' => true), + 'label_block' => true, + ) + ); + + $repeater->add_control( + 'pin_desc', + array( + 'label' => __('Description', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::WYSIWYG, + 'dynamic' => array('active' => true), + 'label_block' => true, + ) + ); + + $repeater->add_control( + 'pin_time_desc', + array( + 'label' => __('Time Table', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::WYSIWYG, + 'dynamic' => array('active' => true), + 'label_block' => true, + ) + ); + + $repeater->add_control( + 'pin_desc_gallery', + array( + 'label' => __('Pin Gallery', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::GALLERY, + 'dynamic' => array('active' => true), + 'label_block' => true, + ) + ); + + $this->add_control( + 'alpha_map_pins', + array( + 'label' => __('Map Pins', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::REPEATER, + 'default' => array( + 'map_latitude' => '51.501156639895136', + 'map_longitude' => '-0.12479706299020504', + 'pin_title' => __('Alpha Google Maps', 'alpha-google-map-for-elementor'), + 'pin_desc' => __('Add an optional description to your map pin', 'alpha-google-map-for-elementor'), + 'pin_time_desc' => __('Add a time table for the location pin', 'alpha-google-map-for-elementor'), + ), + 'fields' => $repeater->get_controls(), + 'title_field' => '{{{ pin_title }}}', + ) + ); + + $this->end_controls_section(); + + $this->start_controls_section( + 'alpha_map_controls_section', + array( + 'label' => __('Controls', 'alpha-google-map-for-elementor'), + ) + ); + + $this->add_control( + 'alpha_map_type', + array( + 'label' => __('Map Type', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SELECT, + 'options' => array( + 'roadmap' => __('Road Map', 'alpha-google-map-for-elementor'), + 'satellite' => __('Satellite', 'alpha-google-map-for-elementor'), + 'terrain' => __('Terrain', 'alpha-google-map-for-elementor'), + 'hybrid' => __('Hybrid', 'alpha-google-map-for-elementor'), + ), + 'default' => 'roadmap', + ) + ); + + $this->add_responsive_control( + 'alpha_map_height', + array( + 'label' => __('Height', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SLIDER, + 'default' => array( + 'size' => 500, + ), + 'range' => array( + 'px' => array( + 'min' => 80, + 'max' => 1400, + ), + ), + 'selectors' => array( + '{{WRAPPER}} .alpha_map_height' => 'height: {{SIZE}}px;', + ), + ) + ); + + $this->add_control( + 'alpha_map_zoom', + array( + 'label' => __('Zoom', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SLIDER, + 'default' => array( + 'size' => 12, + ), + 'range' => array( + 'px' => array( + 'min' => 0, + 'max' => 22, + ), + ), + ) + ); + + $this->add_control( + 'disable_drag', + array( + 'label' => __('Disable Map Drag', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SWITCHER, + ) + ); + + $this->add_control( + 'alpha_map_option_map_type_control', + array( + 'label' => __('Map Type Controls', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SWITCHER, + ) + ); + + $this->add_control( + 'alpha_map_option_zoom_controls', + array( + 'label' => __('Zoom Controls', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SWITCHER, + ) + ); + + $this->add_control( + 'alpha_map_option_streeview', + array( + 'label' => __('Street View Control', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SWITCHER, + ) + ); + + $this->add_control( + 'alpha_map_option_fullscreen_control', + array( + 'label' => __('Fullscreen Control', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SWITCHER, + ) + ); + + $this->add_control( + 'alpha_map_option_mapscroll', + array( + 'label' => __('Scroll Wheel Zoom', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SWITCHER, + ) + ); + + $this->add_control( + 'alpha_map_marker_open', + array( + 'label' => __('Info Container Always Opened', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SWITCHER, + ) + ); + + $this->add_control( + 'alpha_map_marker_hover_open', + array( + 'label' => __('Info Container Opened when Hovered', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SWITCHER, + ) + ); + + $this->add_control( + 'alpha_map_marker_mouse_out', + array( + 'label' => __('Info Container Closed when Mouse Out', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SWITCHER, + 'condition' => [ + 'alpha_map_marker_hover_open' => 'yes', + ], + ) + ); + + $this->end_controls_section(); + + $this->start_controls_section( + 'alpha_pin_title_style', + array( + 'label' => __('Title', 'alpha-google-map-for-elementor'), + 'tab' => Controls_Manager::TAB_STYLE, + ) + ); + + $this->add_control( + 'alpha_pin_title_color', + array( + 'label' => __('Color', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::COLOR, + 'global' => [ + 'default' => Global_Colors::COLOR_PRIMARY, + ], + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-title' => 'color: {{VALUE}};', + ), + ) + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + array( + 'name' => 'pin_title_typography', + 'global' => [ + 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, + ], + 'selector' => '{{WRAPPER}} .alpha-map-info-title', + ) + ); + + $this->add_responsive_control( + 'alpha_pin_title_margin', + array( + 'label' => __('Margin', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ), + ) + ); + + $this->add_responsive_control( + 'alpha_pin_title_padding', + array( + 'label' => __('Padding', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ), + ) + ); + + $this->add_responsive_control( + 'alpha_pin_title_align', + array( + 'label' => __('Alignment', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::CHOOSE, + 'options' => array( + 'left' => array( + 'title' => __('Left', 'alpha-google-map-for-elementor'), + 'icon' => 'fa fa-align-left', + ), + 'center' => array( + 'title' => __('Center', 'alpha-google-map-for-elementor'), + 'icon' => 'fa fa-align-center', + ), + 'right' => array( + 'title' => __('Right', 'alpha-google-map-for-elementor'), + 'icon' => 'fa fa-align-right', + ), + ), + 'default' => 'center', + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-title' => 'text-align: {{VALUE}};', + ), + ) + ); + + $this->end_controls_section(); + + $this->start_controls_section( + 'alpha_pin_text_style', + array( + 'label' => __('Description', 'alpha-google-map-for-elementor'), + 'tab' => Controls_Manager::TAB_STYLE, + ) + ); + + $this->add_control( + 'alpha_pin_text_color', + array( + 'label' => __('Color', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::COLOR, + 'global' => [ + 'default' => Global_Colors::COLOR_SECONDARY, + ], + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-desc' => 'color: {{VALUE}};', + ), + ) + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + array( + 'name' => 'pin_text_typo', + 'global' => [ + 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, + ], + 'selector' => '{{WRAPPER}} .alpha-map-info-desc', + ) + ); + + $this->add_responsive_control( + 'alpha_pin_text_margin', + array( + 'label' => __('Margin', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-desc' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ), + ) + ); + + $this->add_responsive_control( + 'alpha_pin_text_padding', + array( + 'label' => __('Padding', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-desc' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ), + ) + ); + + $this->add_responsive_control( + 'alpha_pin_description_align', + array( + 'label' => __('Alignment', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::CHOOSE, + 'options' => array( + 'left' => array( + 'title' => __('Left', 'alpha-google-map-for-elementor'), + 'icon' => 'fa fa-align-left', + ), + 'center' => array( + 'title' => __('Center', 'alpha-google-map-for-elementor'), + 'icon' => 'fa fa-align-center', + ), + 'right' => array( + 'title' => __('Right', 'alpha-google-map-for-elementor'), + 'icon' => 'fa fa-align-right', + ), + ), + 'default' => 'center', + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-desc' => 'text-align: {{VALUE}};', + ), + ) + ); + + $this->end_controls_section(); + + $this->start_controls_section( + 'alpha_pin_time_style', + array( + 'label' => __('Time Table', 'alpha-google-map-for-elementor'), + 'tab' => Controls_Manager::TAB_STYLE, + ) + ); + + $this->add_control( + 'alpha_pin_time_color', + array( + 'label' => __('Color', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::COLOR, + 'global' => [ + 'default' => Global_Colors::COLOR_SECONDARY, + ], + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-time-desc' => 'color: {{VALUE}};', + ), + ) + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + array( + 'name' => 'pin_time_typo', + 'global' => [ + 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, + ], + 'selector' => '{{WRAPPER}} .alpha-map-info-time-desc', + ) + ); + + $this->add_responsive_control( + 'alpha_pin_time_margin', + array( + 'label' => __('Margin', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-time-desc' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ), + ) + ); + + $this->add_responsive_control( + 'alpha_pin_time_padding', + array( + 'label' => __('Padding', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-time-desc' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ), + ) + ); + + $this->add_responsive_control( + 'alpha_pin_time_align', + array( + 'label' => __('Alignment', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::CHOOSE, + 'options' => array( + 'left' => array( + 'title' => __('Left', 'alpha-google-map-for-elementor'), + 'icon' => 'fa fa-align-left', + ), + 'center' => array( + 'title' => __('Center', 'alpha-google-map-for-elementor'), + 'icon' => 'fa fa-align-center', + ), + 'right' => array( + 'title' => __('Right', 'alpha-google-map-for-elementor'), + 'icon' => 'fa fa-align-right', + ), + ), + 'default' => 'center', + 'selectors' => array( + '{{WRAPPER}} .alpha-map-info-time-desc' => 'text-align: {{VALUE}};', + ), + ) + ); + + $this->end_controls_section(); + + $this->start_controls_section( + 'alpha_box_style', + array( + 'label' => __('Map', 'alpha-google-map-for-elementor'), + 'tab' => Controls_Manager::TAB_STYLE, + ) + ); + + $this->add_group_control( + Group_Control_Border::get_type(), + array( + 'name' => 'map_border', + 'selector' => '{{WRAPPER}} .alpha-map-container', + ) + ); + + $this->add_control( + 'alpha_box_radius', + array( + 'label' => __('Border Radius', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SLIDER, + 'size_units' => array('px', '%', 'em'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-container,{{WRAPPER}} .alpha_map_height' => 'border-radius: {{SIZE}}{{UNIT}};', + ), + ) + ); + + $this->add_group_control( + Group_Control_Box_Shadow::get_type(), + array( + 'label' => __('Shadow', 'alpha-google-map-for-elementor'), + 'name' => 'alpha_map_box_shadow', + 'selector' => '{{WRAPPER}} .alpha-map-container', + ) + ); + + $this->add_responsive_control( + 'alpha_box_margin', + array( + 'label' => __('Margin', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-container' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}', + ), + ) + ); + + $this->add_responsive_control( + 'alpha_box_padding', + array( + 'label' => __('Padding', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-container' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}', + ), + ) + ); + + $this->end_controls_section(); + + // Map Title Controls. + $this->start_controls_section( + 'section_title', + array( + 'label' => __('Map Title', 'alpha-google-map-for-elementor'), + ) + ); + + $this->add_control( + 'title', + array( + 'label' => __('Map Title', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::TEXTAREA, + 'dynamic' => array( + 'active' => true, + ), + 'placeholder' => __('Enter your title', 'alpha-google-map-for-elementor'), + 'default' => __('Add Your Title Text Here', 'alpha-google-map-for-elementor'), + ) + ); + + $this->add_control( + 'link', + array( + 'label' => __('Link', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::URL, + 'dynamic' => array( + 'active' => true, + ), + 'default' => array( + 'url' => '', + ), + 'separator' => 'before', + ) + ); + + $this->add_control( + 'size', + array( + 'label' => __('Size', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SELECT, + 'default' => 'default', + 'options' => array( + 'default' => __('Default', 'alpha-google-map-for-elementor'), + 'small' => __('Small', 'alpha-google-map-for-elementor'), + 'medium' => __('Medium', 'alpha-google-map-for-elementor'), + 'large' => __('Large', 'alpha-google-map-for-elementor'), + 'xl' => __('XL', 'alpha-google-map-for-elementor'), + 'xxl' => __('XXL', 'alpha-google-map-for-elementor'), + ), + ) + ); + + $this->add_control( + 'header_size', + array( + 'label' => __('HTML Tag', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::SELECT, + 'options' => array( + 'h1' => 'H1', + 'h2' => 'H2', + 'h3' => 'H3', + 'h4' => 'H4', + 'h5' => 'H5', + 'h6' => 'H6', + 'div' => 'div', + 'span' => 'span', + 'p' => 'p', + ), + 'default' => 'h2', + ) + ); + + $this->add_responsive_control( + 'align', + array( + 'label' => __('Alignment', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::CHOOSE, + 'options' => array( + 'left' => array( + 'title' => __('Left', 'alpha-google-map-for-elementor'), + 'icon' => 'eicon-text-align-left', + ), + 'center' => array( + 'title' => __('Center', 'alpha-google-map-for-elementor'), + 'icon' => 'eicon-text-align-center', + ), + 'right' => array( + 'title' => __('Right', 'alpha-google-map-for-elementor'), + 'icon' => 'eicon-text-align-right', + ), + 'justify' => array( + 'title' => __('Justified', 'alpha-google-map-for-elementor'), + 'icon' => 'eicon-text-align-justify', + ), + ), + 'default' => '', + 'selectors' => array( + '{{WRAPPER}}' => 'text-align: {{VALUE}};', + ), + ) + ); + + $this->add_control( + 'view', + array( + 'label' => __('View', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::HIDDEN, + 'default' => 'traditional', + ) + ); + + $this->end_controls_section(); + + // Map Title Style. + $this->start_controls_section( + 'section_title_style', + array( + 'label' => __('Map Title', 'alpha-google-map-for-elementor'), + 'tab' => Controls_Manager::TAB_STYLE, + ) + ); + + $this->add_control( + 'title_color', + array( + 'label' => __('Text Color', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::COLOR, + 'global' => array( + 'default' => Global_Colors::COLOR_PRIMARY, + ), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-title' => 'color: {{VALUE}};', + ), + ) + ); + + $this->add_group_control( + Group_Control_Typography::get_type(), + array( + 'name' => 'typography', + 'global' => array( + 'default' => Global_Typography::TYPOGRAPHY_PRIMARY, + ), + 'selector' => '{{WRAPPER}} .alpha-map-title', + ) + ); + + $this->add_group_control( + Group_Control_Text_Shadow::get_type(), + array( + 'name' => 'text_shadow', + 'selector' => '{{WRAPPER}} .alpha-map-title', + ) + ); + + $this->add_responsive_control( + 'title_margin', + array( + 'label' => __('Margin', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ), + ) + ); + + $this->add_responsive_control( + 'title_padding', + array( + 'label' => __('Padding', 'alpha-google-map-for-elementor'), + 'type' => Controls_Manager::DIMENSIONS, + 'size_units' => array('px', 'em', '%'), + 'selectors' => array( + '{{WRAPPER}} .alpha-map-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', + ), + ) + ); + + $this->end_controls_section(); + } + + /** + * Show the count of how many images left in the gallery + * + * @param string $link_html link for an image. + * @param string $id the id of an image. + * + * @return string|string[]|null + */ + public function add_lightbox_data_to_image_link($link_html, $id) + { + $settings = $this->get_settings_for_display(); + $open_lightbox = isset($settings['open_lightbox']) ? $settings['open_lightbox'] : null; + + if (Plugin::$instance->editor->is_edit_mode()) { + $this->add_render_attribute('link', 'class', 'elementor-clickable', true); + } + + $this->add_lightbox_data_attributes('link', $id, $open_lightbox, $this->get_id(), true); + return preg_replace('/^get_render_attribute_string('link'), $link_html); + } + + /** + * Render the widget on the frontend. + */ + protected function render() + { + $settings = $this->get_settings_for_display(); + + $map_pins = $settings['alpha_map_pins']; + + $street_view = 'yes' === $settings['alpha_map_option_streeview'] ? 'true' : 'false'; + + $scroll_wheel = 'yes' === $settings['alpha_map_option_mapscroll'] ? 'true' : 'false'; + + $full_screen = 'yes' === $settings['alpha_map_option_fullscreen_control'] ? 'true' : 'false'; + + $zoom_control = 'yes' === $settings['alpha_map_option_zoom_controls'] ? 'true' : 'false'; + + $type_control = 'yes' === $settings['alpha_map_option_map_type_control'] ? 'true' : 'false'; + + $automatic_open = 'yes' === $settings['alpha_map_marker_open'] ? 'true' : 'false'; + + $hover_open = 'yes' === $settings['alpha_map_marker_hover_open'] ? 'true' : 'false'; + + $hover_close = 'yes' === $settings['alpha_map_marker_mouse_out'] ? 'true' : 'false'; + + $locationlat = ! empty($settings['alpha_location_lat']) ? sanitize_text_field($settings['alpha_location_lat']) : '18.591212'; + + $locationlong = ! empty($settings['alpha_location_long']) ? sanitize_text_field($settings['alpha_location_long']) : '73.741261'; + + $marker_width = !empty($settings['alpha_markers_width']) ? $settings['alpha_markers_width'] : 1000; + + $map_settings = array( + 'zoom' => $settings['alpha_map_zoom']['size'], + 'maptype' => $settings['alpha_map_type'], + 'streetViewControl' => $street_view, + 'locationlat' => $locationlat, + 'locationlong' => $locationlong, + 'scrollwheel' => $scroll_wheel, + 'fullScreen' => $full_screen, + 'zoomControl' => $zoom_control, + 'typeControl' => $type_control, + 'automaticOpen' => $automatic_open, + 'hoverOpen' => $hover_open, + 'hoverClose' => $hover_close, + 'drag' => $settings['disable_drag'], + ); + + $this->add_render_attribute( + 'style_wrapper', + array( + 'class' => 'alpha_map_height', + 'data-settings' => wp_json_encode($map_settings), + ) + ); + + ?> +
+
+ add_render_attribute('title', 'class', 'alpha-map-title'); + // Check and add size class if provided + if (!empty($settings['size'])) { + $this->add_render_attribute('title', 'class', 'elementor-size-' . sanitize_html_class($settings['size'])); + } + // Allow inline editing of the title + $this->add_inline_editing_attributes('title'); + + // Sanitize the title + $title = sanitize_text_field($settings['title']); + // If a link is provided, sanitize and set attributes + if (!empty($settings['link']['url'])) { + $settings['link'] = wp_parse_args($settings['link'], ['url' => '', 'is_external' => '', 'nofollow' => '']); + $this->add_link_attributes('url', $settings['link']); + + $title = sprintf( + '%2$s', + $this->get_render_attribute_string('url'), + esc_html($title) + ); + } + + // Validate and sanitize the header size tag + $header_tag = Utils::validate_html_tag($settings['header_size']); + + // Construct the title HTML with proper escaping + $title_html = sprintf( + '<%1$s %2$s>%3$s', + esc_html($header_tag), + $this->get_render_attribute_string('title'), + $title + ); + + // Sanitize the entire output + echo wp_kses( + $title_html, + [ + 'a' => [ + 'href' => [], + 'target' => [], + 'rel' => [], + 'class' => [] + ], + $header_tag => [ + 'class' => [], + 'id' => [], + 'style' => [] + ] + ] + ); + } + ?> +
+ +
get_render_attribute_string('style_wrapper')); ?>> + $pin) { + $key = 'map_marker_' . $index; + // Sanitize data before use + $latitude = isset($pin['map_latitude']) ? sanitize_text_field($pin['map_latitude']) : ''; + $longitude = isset($pin['map_longitude']) ? sanitize_text_field($pin['map_longitude']) : ''; + $icon_url = isset($pin['pin_icon']['url']) ? esc_url($pin['pin_icon']['url']) : ''; + $icon_active_url = isset($pin['pin_active_icon']['url']) ? esc_url($pin['pin_active_icon']['url']) : ''; + $icon_size = isset($pin['pin_icon_size']['size']) ? intval($pin['pin_icon_size']['size']) : ''; + $data_max_width = isset($marker_width) ? intval($marker_width) : ''; + $data_id = intval($index); + + $this->add_render_attribute( + $key, + array( + 'class' => 'alpha-pin', + 'data-lng' => $longitude, + 'data-lat' => $latitude, + 'data-icon' => $icon_url, + 'data-icon-active' => $icon_active_url, + 'data-icon-size' => $icon_size, + 'data-max-width' => $data_max_width, + 'data-id' => $data_id, + ) + ); + + // Sanitize IDs + $ids = array_map('intval', wp_list_pluck($pin['pin_desc_gallery'], 'id')); + $count = count($ids); + $data_count = absint($count - 4); + $this->add_render_attribute('shortcode' . $index, 'ids', implode(',', $ids)); + + ?> +
get_render_attribute_string($key)); ?>> + +
+

+
+
+ + + +
+ +
+ +
+ +
+ ' . esc_html__('Alpha Google Map For Elementor', 'alpha-google-map-for-elementor') . '', - '' . esc_html__('Elementor', 'alpha-google-map-for-elementor') . '' + /* translators: 1: Plugin name 2: Elementor */ + __('"%1$s" requires "%2$s" to be installed and activated.', 'alpha-google-map-for-elementor'), + '' . __('Alpha Google Map For Elementor', 'alpha-google-map-for-elementor') . '', + '' . __('Elementor', 'alpha-google-map-for-elementor') . '' ); $elementor = 'elementor/elementor.php'; @@ -199,11 +199,23 @@ public function admin_notice_missing_main_plugin(): void $activation_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor'); $button_text = esc_html__('Install Elementor', 'alpha-google-map-for-elementor'); } - $button = '

' . $button_text . '

'; + $button = '

' . esc_html($button_text) . '

'; + + $allowed_html = [ + 'strong' => [], + 'a' => [ + 'href' => [], + 'class' => [], + ], + 'p' => [], + 'div' => [ + 'class' => [], + ], + ]; + printf( - '

%1$s

%2$s
', - esc_html($message), - wp_kses_post($button) + '
%s
', + wp_kses('

' . $message . '

' . $button, $allowed_html) ); } @@ -212,20 +224,31 @@ public function admin_notice_missing_main_plugin(): void * * Warning when the site doesn't have a minimum required Elementor version. * - * @since 1.0.0 + * @since 1.0.0 * @access public */ public function admin_notice_minimum_elementor_version(): void { $message = sprintf( - /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ - esc_html__('"%1$s" requires "%2$s" version %3$s or greater.', 'alpha-google-map-for-elementor'), - '' . esc_html__('Alpha Google Map For Elementor', 'alpha-google-map-for-elementor') . '', - '' . esc_html__('Elementor', 'alpha-google-map-for-elementor') . '', + /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ + __('"%1$s" requires "%2$s" version %3$s or greater.', 'alpha-google-map-for-elementor'), + '' . __('Alpha Google Map For Elementor', 'alpha-google-map-for-elementor') . '', + '' . __('Elementor', 'alpha-google-map-for-elementor') . '', self::MINIMUM_ELEMENTOR_VERSION ); - printf('

%1$s

', esc_html($message)); + $allowed_html = [ + 'strong' => [], + 'p' => [], + 'div' => [ + 'class' => [], + ], + ]; + + printf( + '
%s
', + wp_kses('

' . $message . '

', $allowed_html) + ); } /** @@ -233,20 +256,31 @@ public function admin_notice_minimum_elementor_version(): void * * Warning when the site doesn't have a minimum required PHP version. * - * @since 1.0.0 + * @since 1.0.0 * @access public */ public function admin_notice_minimum_php_version(): void { $message = sprintf( - /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ - esc_html__('"%1$s" requires "%2$s" version %3$s or greater.', 'alpha-google-map-for-elementor'), - '' . esc_html__('Alpha Google Map For Elementor', 'alpha-google-map-for-elementor') . '', - '' . esc_html__('PHP', 'alpha-google-map-for-elementor') . '', + /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ + __('"%1$s" requires "%2$s" version %3$s or greater.', 'alpha-google-map-for-elementor'), + '' . __('Alpha Google Map For Elementor', 'alpha-google-map-for-elementor') . '', + '' . __('PHP', 'alpha-google-map-for-elementor') . '', self::MINIMUM_PHP_VERSION ); - printf('

%1$s

', esc_html($message)); + $allowed_html = [ + 'strong' => [], + 'p' => [], + 'div' => [ + 'class' => [], + ], + ]; + + printf( + '
%s
', + wp_kses('

' . $message . '

', $allowed_html) + ); } /** @@ -263,10 +297,12 @@ public function frontend_styles(): void public function frontend_scripts(): void { // Script register. - wp_enqueue_script('alphamap', ALPHAMAP_PL_ASSETS . 'js/alpha-map.js', ['jquery', 'alpha-api-js'], ALPHAMAP_VERSION, array( + wp_enqueue_script( + 'alphamap', ALPHAMAP_PL_ASSETS . 'js/alpha-map.js', ['jquery', 'alpha-api-js'], ALPHAMAP_VERSION, array( 'in_footer' => true, 'strategy' => 'defer', - )); + ) + ); // get an option. $api_key = get_option('elementor_google_maps_api_key'); @@ -296,7 +332,7 @@ public function frontend_scripts(): void public function register_widgets($widgets_manager): void { // Include Widget files. - require_once ALPHAMAP_PL_INCLUDE . '/class-alpha-google-map-widget.php'; + include_once ALPHAMAP_PL_INCLUDE . '/class-alpha-google-map-widget.php'; // Register widget. $widgets_manager->register(new \AlphaGoogleMap\Alpha_Google_Map_Widget()); } diff --git a/readme.txt b/readme.txt index 3c0d11b..9c26502 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: google-map, google, elementor, maps, page builder Requires at least: 6.0 Tested up to: 6.7 Requires PHP: 7.4 -Stable tag: 1.2.1 +Stable tag: 1.2.2 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -63,8 +63,8 @@ For community support, use the WordPress.org forums. Report bugs on [GitHub Issu == Upgrade Notice == -= 1.2.1 = -Compatibility for WP 6.7 and security improvements, code modernization, and compatibility updates. += 1.2.2 = +Compatibility for the updated Elementor colors and typography schema. == Frequently Asked Questions == @@ -84,6 +84,9 @@ No. Elementor Website Builder must be installed and activated. == Changelog == += 1.2.2 - 2024-12-18 = +* Compatibility for the updated Elementor colors and typography schema. + = 1.2.1 - 2024-11-16 = * Enhanced compatibility with the latest WordPress and Elementor versions. * Adhered to WordPress coding standards throughout the codebase.