diff --git a/README.md b/README.md index ed2a651..9fc81a8 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,86 @@ # Alpha Google Map For Elementor -[![WP](https://img.shields.io/badge/WordPress-%E2%86%92-lightgrey.svg?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) +[![WordPress](https://img.shields.io/badge/WordPress-%E2%86%92-lightgrey.svg?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) [![WordPress Plugin Downloads](https://img.shields.io/wordpress/plugin/dt/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) [![WordPress Plugin Last Updated](https://img.shields.io/wordpress/plugin/last-updated/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) -[![WordPress Plugin Required PHP Version](https://img.shields.io/wordpress/plugin/required-php/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) -[![WordPress Plugin: Required WP Version](https://img.shields.io/wordpress/plugin/wp-version/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) -[![WordPress Plugin: Tested WP Version](https://img.shields.io/wordpress/plugin/tested/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) +[![Required PHP Version](https://img.shields.io/wordpress/plugin/required-php/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) +[![Required WP Version](https://img.shields.io/wordpress/plugin/wp-version/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) +[![Tested WP Version](https://img.shields.io/wordpress/plugin/tested/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) [![WordPress Plugin Rating](https://img.shields.io/wordpress/plugin/stars/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) [![WordPress Plugin Version](https://img.shields.io/wordpress/plugin/v/alpha-google-map-for-elementor?style=flat-square)](https://wordpress.org/plugins/alpha-google-map-for-elementor/) -=== Alpha Google Map For Elementor === +**Author:** ali7ali +**Contributors:** ali7ali +**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 +**License:** [GPLv3](https://www.gnu.org/licenses/gpl-3.0.html) -Author: ali7ali +Alpha Google Map For Elementor offers premium Google Map features for WordPress, enhancing your site with advanced map functionalities. -Contributors: ali7ali +## Description -Tags: google-map, google, premium, elementor, alpha, page builder, landing page, drag-and-drop +This plugin offers the generally needed Google Maps functionality with additional premium features tailored for Elementor. -Requires at least: 6.0 +**Plugin Features:** -Tested up to: 6.6 +- Custom map pins with hover and active states +- Customizable info-box with image gallery support +- Extensive map controls +- Responsive Live Editing within Elementor +- Compatibility with the latest Google Maps API standards -Requires PHP: 7.4 +Elementor Website Builder comes with an exclusive toolset that lets you create a truly responsive website in a whole new and visual way. From different font sizes, padding, and margin per device, to reverse column ordering, this is the most powerful mobile site builder for creating perfect responsive websites. -Stable tag: 1.2.0 +**Demo:** -License: GPLv3 +Check this widget demo [here](https://ali-ali.org/project/alpha-google-map-for-elementor/). -License URI: https://www.gnu.org/licenses/gpl-3.0.html +**Contributing and Reporting Bugs:** -Alpha Google Map For Elementor is a plugin that offers premium Google Map features for WordPress. +You can contribute code to this plugin via GitHub: [Alpha-Google-Map-For-Elementor](https://github.com/ali7ali/Alpha-Google-Map-For-Elementor) -== Description == -This plugin offers the generally needed google Maps functionality with additional premium features. +**Support:** -Plugin features +Use the WordPress.org forums for community support. If you spot a bug, you can log it on [GitHub Issues](https://github.com/ali7ali/Alpha-Google-Map-For-Elementor/issues/new/choose) where we can act upon it more efficiently. -- Custom map pins -- Pins change on-hover and active -- Custom info-box with image gallery feature -- Map controls -- Responsive Live Editing +## Installation -Elementor Website Builder comes with an exclusive toolset, that lets you create a truly responsive website in a whole new and visual way. From different font sizes, padding, and margin per device, to reverse column ordering, this is the most powerful mobile site builder for creating perfect responsive websites. - -= Demo = -Check this widget demo here [here](https://alphatrio.net/alpha-google-map-for-elementor/). - -= Contributing and reporting bugs = - -You can contribute code to this plugin via GitHub: [https://github.com/ali7ali/Alpha-Google-Map-For-Elementor](https://github.com/ali7ali/Alpha-Google-Map-For-Elementor) - -= Support = - -Use the WordPress.org forums for community support. If you spot a bug, you can of course log it on [Github](https://github.com/ali7ali/Alpha-Google-Map-For-Elementor/issues/new/choose) instead where we can act upon it more efficiently. - -== Installation == - -= Minimum Requirements = +**Minimum Requirements:** - WordPress 6.0 or greater - PHP version 7.4 or greater - MySQL version 5.0 or greater -= We recommend your host supports: = +**Recommended:** - PHP version 8.1 or greater - MySQL version 5.6 or greater -- WordPress Memory limit of 64 MB or greater (128 MB or higher is preferred) - -= Installation = +- WordPress Memory limit of 128 MB or higher -First, make sure you have [Elementor Website Builder](https://wordpress.org/plugins/elementor/) plugin installed and activated. +**Installation Steps:** -Then follow these steps to install the plugin: +1. Ensure [Elementor Website Builder](https://wordpress.org/plugins/elementor/) is installed and activated. +2. Navigate to **Plugins > Add New** in your WordPress dashboard. +3. Search for **'Alpha Google Map For Elementor'**. +4. Install and activate the plugin. -1. Log in to the WordPress Dashboard as an administrator. -2. Click the Plugins | Add New button. -3. Search for 'Alpha Google Map For Elementor' in the Search plugins field. -4. Once you see the plugin listed, click the Install Now button. -5. Click the Activate button to activate the plugin. +**Manual Installation:** -Manual or using sFTP install: +1. Upload the `alpha-google-map-for-elementor` folder to `/wp-content/plugins/`. +2. Activate the plugin via the **Plugins** screen in WordPress. -1. Upload 'plugin-directory' to the '/wp-content/plugins/' directory -2. Activate the plugin through the 'Plugins' screen in WordPress +## Upgrade Notice -== Upgrade Notice == +### 1.2.1 -= 1.2.0 = -Compatibility for WP 6.6 and refactor the integration with Elementor. +Compatibility for WP 6.7 and security improvements, code modernization, and compatibility updates. -== Frequently Asked Questions == +## Frequently Asked Questions -**Can I use Alpha Google Map For Elementor as stand-alone plugin** +**Can I use Alpha Google Map For Elementor as a stand-alone plugin?** No. You need to install Elementor Website Builder first. @@ -107,54 +94,61 @@ No. You need to install Elementor Website Builder first. 6. **Pins Controls.** Choose your pins icons, and easily set your pins coordinates. 7. **Pin Gallery.** Choose and add images to each pin gallery. -== Changelog == +## Changelog + +### 1.2.1 - 2024-11-16 + +- Enhanced compatibility with the latest WordPress and Elementor versions. +- Adhered to WordPress coding standards throughout the codebase. +- Refactored JavaScript code to use modern standards and practices. +- Fixed bugs and optimized performance. -= 1.2.0 - 2024-07-20 = +### 1.2.0 - 2024-07-20 -- Compatibility for WP 6.6 and refactor the integration with Elementor. +- Compatibility for WP 6.6 and refactored the integration with Elementor. -= 1.1.0 - 2024-04-04 = +### 1.1.0 - 2024-04-04 -- Compatibility for WP 6.5 and optimize the plugin assets loading method. +- Compatibility for WP 6.5 and optimized the plugin assets loading method. -= 1.0.9 - 2023-11-11 = +### 1.0.9 - 2023-11-11 - Compatibility for WP 6.4 and bug fix for clicked pins. -= 1.0.8 - 2023-08-17 = +### 1.0.8 - 2023-08-17 - Compatibility for WP 6.3. -= 1.0.7 - 2023-06-23 = +### 1.0.7 - 2023-06-23 -- Minor improvements and adding a demo. +- Minor improvements and added a demo. -= 1.0.6 - 2023-06-10 = +### 1.0.6 - 2023-06-10 -- Update deprecated functions. +- Updated deprecated functions. -= 1.0.5 - 2023-01-11 = +### 1.0.5 - 2023-01-11 -- Update deprecated functions. +- Updated deprecated functions. -= 1.0.4 - 2022-07-13 = +### 1.0.4 - 2022-07-13 -- Applying PHPCS standards and fixing bugs. -- Fixing incorrect hook usage and replacing deprecated functions. +- Applied PHPCS standards and fixed bugs. +- Fixed incorrect hook usage and replaced deprecated functions. -= 1.0.3 - 2022-06-19 = +### 1.0.3 - 2022-06-19 -- Adding README.md +- Added `README.md`. -= 1.0.2 - 2022-05-08 = +### 1.0.2 - 2022-05-08 -- Testing for WordPress 6.0 +- Tested with WordPress 6.0. -= 1.0.1 - 2021-06-03 = +### 1.0.1 - 2021-06-03 -- Tweak: Improving the readme.txt file (Tags and more information) -- Tweak: Regenerating the .pot file (fixing one text) +- Tweaked: Improved the `readme.txt` file (Tags and more information). +- Tweaked: Regenerated the `.pot` file (fixed one text). -= 1.0.0 - 2021-06-02 = +### 1.0.0 - 2021-06-02 - Initial Public Release diff --git a/alpha-google-map-for-elementor.php b/alpha-google-map-for-elementor.php index 8e90893..2c5f2a4 100644 --- a/alpha-google-map-for-elementor.php +++ b/alpha-google-map-for-elementor.php @@ -6,7 +6,7 @@ * Description: Premium Google Map features for WordPress. * Author: Ali Ali * Author URI: https://github.com/Ali7Ali - * Version: 1.2.0 + * Version: 1.2.1 * Text Domain: alpha-google-map-for-elementor * Domain Path: /languages * License: GPLv3 @@ -36,7 +36,7 @@ exit; // Exit if accessed directly. } -define('ALPHAMAP_VERSION', '1.2.0'); +define('ALPHAMAP_VERSION', '1.2.1'); 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)); @@ -52,6 +52,6 @@ function alpha_google_map_addon() require_once(ALPHAMAP_PL_INCLUDE . '/class-alpha-google-map.php'); // Run the plugin - \Elementor_Alpha_Google_Map_Addon\Alpha_Google_Map::instance(); + \AlphaGoogleMap\Alpha_Google_Map::instance(); } add_action('plugins_loaded', 'alpha_google_map_addon'); diff --git a/include/class-alpha-google-map-widget.php b/include/class-alpha-google-map-widget.php index 2f1ec01..df8ced3 100644 --- a/include/class-alpha-google-map-widget.php +++ b/include/class-alpha-google-map-widget.php @@ -1,6 +1,6 @@ start_controls_section( 'section_header', @@ -112,7 +112,7 @@ protected function register_controls() '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', @@ -414,9 +414,9 @@ protected function register_controls() array( 'label' => __('Info Container Closed when Mouse Out', 'alpha-google-map-for-elementor'), 'type' => Controls_Manager::SWITCHER, - 'condition' => array( + 'condition' => [ 'alpha_map_marker_hover_open' => 'yes', - ), + ], ) ); @@ -966,9 +966,9 @@ protected function render() $hover_close = 'yes' === $settings['alpha_map_marker_mouse_out'] ? 'true' : 'false'; - $locationlat = !empty($settings['alpha_location_lat']) ? $settings['alpha_location_lat'] : 18.591212; + $locationlat = ! empty($settings['alpha_location_lat']) ? sanitize_text_field($settings['alpha_location_lat']) : '18.591212'; - $locationlong = !empty($settings['alpha_location_long']) ? $settings['alpha_location_long'] : 73.741261; + $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; @@ -1000,51 +1000,93 @@ protected function render()
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-' . $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'); - $title = $settings['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'), $title); + $title = sprintf( + '%2$s', + $this->get_render_attribute_string('url'), + esc_html($title) + ); } - $title_html = sprintf('<%1$s %2$s>%3$s', Utils::validate_html_tag($settings['header_size']), $this->get_render_attribute_string('title'), $title); - - echo $title_html; + // 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' => $pin['map_longitude'], - 'data-lat' => $pin['map_latitude'], - 'data-icon' => $pin['pin_icon']['url'], - 'data-icon-active' => $pin['pin_active_icon']['url'], - 'data-icon-size' => $pin['pin_icon_size']['size'], - 'data-max-width' => $marker_width, - 'data-id' => $index, + '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, ) ); - $ids = wp_list_pluck($pin['pin_desc_gallery'], '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)); ?> @@ -1055,7 +1097,7 @@ protected function render()
-