diff --git a/README.md b/README.md
index 3ff340d..ed2a651 100644
--- a/README.md
+++ b/README.md
@@ -19,11 +19,11 @@ Tags: google-map, google, premium, elementor, alpha, page builder, landing page,
Requires at least: 6.0
-Tested up to: 6.5
+Tested up to: 6.6
-Requires PHP: 7.3
+Requires PHP: 7.4
-Stable tag: 1.1.0
+Stable tag: 1.2.0
License: GPLv3
@@ -60,12 +60,12 @@ Use the WordPress.org forums for community support. If you spot a bug, you can o
= Minimum Requirements =
- WordPress 6.0 or greater
-- PHP version 7.3 or greater
+- PHP version 7.4 or greater
- MySQL version 5.0 or greater
= We recommend your host supports: =
-- PHP version 7.4 or greater
+- 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)
@@ -88,8 +88,8 @@ Manual or using sFTP install:
== Upgrade Notice ==
-= 1.1.0 =
-Compatibility for WP 6.5 and optimize the plugin assets loading method.
+= 1.2.0 =
+Compatibility for WP 6.6 and refactor the integration with Elementor.
== Frequently Asked Questions ==
@@ -109,6 +109,10 @@ No. You need to install Elementor Website Builder first.
== Changelog ==
+= 1.2.0 - 2024-07-20 =
+
+- Compatibility for WP 6.6 and refactor the integration with Elementor.
+
= 1.1.0 - 2024-04-04 =
- Compatibility for WP 6.5 and optimize the plugin assets loading method.
diff --git a/alpha-google-map-for-elementor.php b/alpha-google-map-for-elementor.php
index 7448a7f..8e90893 100644
--- a/alpha-google-map-for-elementor.php
+++ b/alpha-google-map-for-elementor.php
@@ -6,14 +6,13 @@
* Description: Premium Google Map features for WordPress.
* Author: Ali Ali
* Author URI: https://github.com/Ali7Ali
- * Version: 1.1.0
+ * Version: 1.2.0
* Text Domain: alpha-google-map-for-elementor
* Domain Path: /languages
* License: GPLv3
*
*
- * @package alpha-google-map-for-elementor
- */
+ * */
/*
Copyright 2021 Ali Ali (email : ali.abdalhadi.ali@gmail.com)
@@ -37,13 +36,22 @@
exit; // Exit if accessed directly.
}
-define('ALPHAMAP_VERSION', '1.1.0');
+define('ALPHAMAP_VERSION', '1.2.0');
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));
define('ALPHAMAP_PL_ASSETS', trailingslashit(ALPHAMAP_PL_URL . 'assets'));
define('ALPHAMAP_PL_INCLUDE', trailingslashit(ALPHAMAP_PL_PATH . 'include'));
+define('ALPHAMAP_PL_LANGUAGES', trailingslashit(ALPHAMAP_PL_PATH . 'languages'));
define('ALPHAMAP_PLUGIN_BASE', plugin_basename(ALPHAMAP_ADDONS_PL_ROOT));
-// Required File.
-require ALPHAMAP_PL_INCLUDE . '/class-alpha-google-map.php';
+function alpha_google_map_addon()
+{
+
+ // Load plugin file
+ require_once(ALPHAMAP_PL_INCLUDE . '/class-alpha-google-map.php');
+
+ // Run the plugin
+ \Elementor_Alpha_Google_Map_Addon\Alpha_Google_Map::instance();
+}
+add_action('plugins_loaded', 'alpha_google_map_addon');
diff --git a/assets/js/alpha-map.js b/assets/js/alpha-map.js
index 1c1ed69..a74748a 100644
--- a/assets/js/alpha-map.js
+++ b/assets/js/alpha-map.js
@@ -152,7 +152,7 @@ jQuery(window).on("elementor/frontend/init", function () {
});
jQuery(function () {
- $("body").click(function (e) {
+ jQuery("body").click(function (e) {
let count = jQuery('.alpha-image-gallery').attr("data-count");
count = parseInt(count);
jQuery('.alpha-image-gallery').find("figure:nth-child(4)").append('
' + count + ' more
');
diff --git a/assets/js/pa-maps-finder.js b/assets/js/pa-maps-finder.js
deleted file mode 100644
index eca0c79..0000000
--- a/assets/js/pa-maps-finder.js
+++ /dev/null
@@ -1 +0,0 @@
-var $ = jQuery; function alertError(e) { alert("Geocode was not successful for the following reason: " + e) } function getAddress(e) { var o = $(e).parent().find("input").val(), t = new google.maps.Geocoder, n = $(e).parents(".elementor-control-alpha_notice"); o && t.geocode({ address: o }, function (e, o) { if (o == google.maps.GeocoderStatus.OK) { var t = e[0].geometry.location.lat(), r = e[0].geometry.location.lng(); n.nextAll(".elementor-control-alpha_location_lat").find("input").val(t).trigger("input"), n.nextAll(".elementor-control-alpha_location_long").find("input").val(r).trigger("input") } else alertError(o) }) } function getPinAddress(e) { var o = $(e).parent().find("input").val(), t = new google.maps.Geocoder, n = $(e).parents(".elementor-control-alpha_pin_notice"); o && t.geocode({ address: o }, function (e, o) { if (o == google.maps.GeocoderStatus.OK) { var t = e[0].geometry.location.lat(), r = e[0].geometry.location.lng(); n.nextAll(".elementor-control-map_latitude").find("input").val(t).trigger("input"), n.nextAll(".elementor-control-map_longitude").find("input").val(r).trigger("input") } else alertError(o) }) }
\ No newline at end of file
diff --git a/include/class-alpha-google-map-widget.php b/include/class-alpha-google-map-widget.php
index f153937..2f1ec01 100644
--- a/include/class-alpha-google-map-widget.php
+++ b/include/class-alpha-google-map-widget.php
@@ -1,18 +1,23 @@
is_compatible()) {
+ add_action('elementor/init', [$this, 'init']);
+ }
}
/**
@@ -52,53 +81,38 @@ public function __construct()
*/
public function i18n()
{
- load_plugin_textdomain('alpha-google-map-for-elementor');
+ load_plugin_textdomain('alpha-google-map-for-elementor', false, ALPHAMAP_PL_LANGUAGES);
}
/**
- * On plugins load check for compatibility.
- */
- public function on_plugins_loaded()
- {
- if ($this->is_compatible()) {
- add_action('elementor/init', array($this, 'init'));
- }
- }
-
- /**
- * Check if is compatible.
+ * Compatibility Checks
+ *
+ * Checks whether the site meets the addon requirement.
*
- * @return bool
+ * @since 1.0.0
+ * @access public
*/
public function is_compatible()
{
- // Check if Elementor installed and activated.
+ // Check if Elementor installed and activated
if (!did_action('elementor/loaded')) {
- add_action('admin_notices', array($this, 'admin_notice_missing_main_plugin'));
+ add_action('admin_notices', [$this, 'admin_notice_missing_main_plugin']);
return false;
}
- // Check for required PHP version.
- if (version_compare(PHP_VERSION, self::MINIMUM_PHP_VERSION, '<')) {
- add_action('admin_notices', array($this, 'admin_notice_minimum_php_version'));
+ // Check for required Elementor version
+ if (!version_compare(ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=')) {
+ add_action('admin_notices', [$this, 'admin_notice_minimum_elementor_version']);
return false;
}
- $elementor = 'elementor/elementor.php';
- $pathpluginurl = WP_PLUGIN_DIR . '/' . $elementor;
- $isinstalled = file_exists($pathpluginurl);
-
- // Check for required Elementor version.
- if (!defined('ELEMENTOR_VERSION') || !version_compare(ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=')) {
- add_action('admin_notices', array($this, 'admin_notice_minimum_elementor_version'));
- return false;
- } elseif ($isinstalled && $this->is_elementor_active()) {
- return true;
- } else {
- add_action('admin_notices', array($this, 'admin_notice_missing_main_plugin'));
+ // Check for required PHP version
+ if (version_compare(PHP_VERSION, self::MINIMUM_PHP_VERSION, '<')) {
+ add_action('admin_notices', [$this, 'admin_notice_minimum_php_version']);
return false;
}
+
return true;
}
@@ -109,10 +123,11 @@ public function init()
{
$this->i18n();
- // Add Plugin actions.
- add_action('elementor/widgets/register', array($this, 'init_widgets'));
-
$this->add_assets();
+ add_action('elementor/frontend/after_enqueue_styles', [$this, 'frontend_styles']);
+ add_action('elementor/frontend/after_register_scripts', [$this, 'frontend_scripts']);
+
+ add_action('elementor/widgets/register', [$this, 'register_widgets']);
}
/**
@@ -127,7 +142,7 @@ public function add_assets()
$dir = $upload_dir['basedir'];
if (!empty($dir)) {
wp_mkdir_p($dir . '/alpha-map');
- $wp_file_sys = new WP_Filesystem_Direct('direct');
+ $wp_file_sys = new \WP_Filesystem_Direct('direct');
if (!$wp_file_sys->exists($dir . '/alpha-map/alpha-pin.png')) {
$wp_file_sys->put_contents($dir . '/alpha-map/alpha-pin.png', $wp_file_sys->get_contents(ALPHAMAP_PL_ASSETS . 'img/alpha-pin.png'));
}
@@ -138,46 +153,33 @@ public function add_assets()
}
/**
- * Check if Elementor is active or not.
- */
- public function is_elementor_active()
- {
- if (function_exists('elementor_load_plugin_textdomain')) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Admin notice.
- * For missing elementor.
+ * Admin notice
+ *
+ * Warning when the site doesn't have Elementor installed or activated.
+ *
+ * @since 1.0.0
+ * @access public
*/
public function admin_notice_missing_main_plugin()
{
- if (isset($_GET['activate'])) {
- unset($_GET['activate']);
- }
+ if (isset($_GET['activate'])) unset($_GET['activate']);
+
+ $message = sprintf(
+ /* translators: 1: Plugin name 2: Elementor */
+ esc_html__('"%1$s" requires "%2$s" to be installed and activated.', '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') . ''
+ );
+
$elementor = 'elementor/elementor.php';
- $pathpluginurl = WP_PLUGIN_DIR . '/' . $elementor;
+ $pathpluginurl = \WP_PLUGIN_DIR . '/' . $elementor;
$isinstalled = file_exists($pathpluginurl);
- if ($isinstalled && $this->is_elementor_active()) {
- return;
- } elseif ($isinstalled && !$this->is_elementor_active()) {
- if (!current_user_can('activate_plugins')) {
- return;
- }
+ // If installed but didn't load
+ if ($isinstalled && !did_action('elementor/loaded')) {
$activation_url = wp_nonce_url('plugins.php?action=activate&plugin=' . $elementor . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $elementor);
- /* translators: 1: Just text decoration 2: Just text decoration */
- $message = sprintf(__('%1$sAlpha Google Map For Elementor%2$s requires %1$s"Elementor"%2$s plugin to be active. Please activate Elementor to continue.', 'alpha-google-map-for-elementor'), '', '');
$button_text = esc_html__('Activate Elementor', 'alpha-google-map-for-elementor');
} else {
- if (!current_user_can('activate_plugins')) {
- return;
- }
$activation_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=elementor'), 'install-plugin_elementor');
- /* translators: 1: Just text decoration 2: Just text decoration */
- $message = sprintf(__('%1$sAlpha Google Map For Elementor%2$s requires %1$s"Elementor"%2$s plugin to be installed and activated. Please install Elementor to continue.', 'alpha-google-map-for-elementor'), '', '');
$button_text = esc_html__('Install Elementor', 'alpha-google-map-for-elementor');
}
$button = '' . $button_text . '
';
@@ -185,14 +187,17 @@ public function admin_notice_missing_main_plugin()
}
/**
- * Admin notice.
- * For minimum Elementor version required.
+ * Admin notice
+ *
+ * Warning when the site doesn't have a minimum required Elementor version.
+ *
+ * @since 1.0.0
+ * @access public
*/
public function admin_notice_minimum_elementor_version()
{
- if (isset($_GET['activate'])) {
- unset($_GET['activate']);
- }
+
+ if (isset($_GET['activate'])) unset($_GET['activate']);
$message = sprintf(
/* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */
@@ -206,19 +211,23 @@ public function admin_notice_minimum_elementor_version()
}
/**
- * Admin notice.
- * For minimum PHP version required.
+ * Admin notice
+ *
+ * Warning when the site doesn't have a minimum required PHP version.
+ *
+ * @since 1.0.0
+ * @access public
*/
public function admin_notice_minimum_php_version()
{
- if (isset($_GET['activate'])) {
- unset($_GET['activate']);
- }
+
+ if (isset($_GET['activate'])) unset($_GET['activate']);
$message = sprintf(
- /* translators: 1: Plugin name 2: Required PHP version */
- esc_html__('"%1$s" requires PHP version %3$s or greater.', 'alpha-google-map-for-elementor'),
+ /* 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') . '',
self::MINIMUM_PHP_VERSION
);
@@ -228,7 +237,7 @@ public function admin_notice_minimum_php_version()
/**
* Loading plugin css.
*/
- public function plugin_css()
+ public function frontend_styles()
{
wp_enqueue_style('alphamap-widget', ALPHAMAP_PL_ASSETS . 'css/alpha-map-widget.css', '', ALPHAMAP_VERSION);
}
@@ -236,13 +245,9 @@ public function plugin_css()
/**
* Loading plugin JavaScript.
*/
- public function plugin_js()
+ public function frontend_scripts()
{
// Script register.
- wp_enqueue_script('alpha-maps-finder', ALPHAMAP_PL_ASSETS . 'js/pa-maps-finder.js', array('jquery'), ALPHAMAP_VERSION, array(
- 'in_footer' => true,
- 'strategy' => 'defer',
- ));
wp_enqueue_script('alphamap', ALPHAMAP_PL_ASSETS . 'js/alpha-map.js', array('jquery', 'alpha-api-js'), ALPHAMAP_VERSION, array(
'in_footer' => true,
'strategy' => 'defer',
@@ -265,18 +270,19 @@ public function plugin_js()
}
/**
- * Register the plugin widget.
+ * Register Widgets
+ *
+ * Load widgets files and register new Elementor widgets.
*
- * @param object $widgets_manager Elementor widgets object.
+ * Fired by `elementor/widgets/register` action hook.
*
- * @throws Exception File.
+ * @param \Elementor\Widgets_Manager $widgets_manager Elementor widgets manager.
*/
- public function init_widgets($widgets_manager)
+ public function register_widgets($widgets_manager)
{
// Include Widget files.
require_once ALPHAMAP_PL_INCLUDE . '/class-alpha-google-map-widget.php';
// Register widget.
- $widgets_manager->register(new \Elementor\Alpha_Google_Map_Widget());
+ $widgets_manager->register(new \Elementor_Alpha_Google_Map_Addon\Alpha_Google_Map_Widget());
}
}
-Alpha_Google_Map::instance();
diff --git a/index.php b/index.php
index 3f0d9c7..0968031 100644
--- a/index.php
+++ b/index.php
@@ -3,7 +3,7 @@
/**
* Direct access security.
*
- * @package alpha-google-map-for-elementor
- * */
+ *
+ * */
wp_die();
diff --git a/readme.txt b/readme.txt
index 0e647e4..afccc5b 100644
--- a/readme.txt
+++ b/readme.txt
@@ -3,9 +3,9 @@ Author: ali7ali
Contributors: ali7ali
Tags: google-map, google, premium, elementor, alpha, page builder, landing page, drag-and-drop
Requires at least: 6.0
-Tested up to: 6.5
-Requires PHP: 7.3
-Stable tag: 1.1.0
+Tested up to: 6.6
+Requires PHP: 7.4
+Stable tag: 1.2.0
License: GPLv3
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -39,12 +39,12 @@ Use the WordPress.org forums for community support. If you spot a bug, you can o
= Minimum Requirements =
* WordPress 6.0 or greater
-* PHP version 7.3 or greater
+* PHP version 7.4 or greater
* MySQL version 5.0 or greater
= We recommend your host supports: =
-* PHP version 7.4 or greater
+* 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)
@@ -66,8 +66,8 @@ Manual or using sFTP install:
== Upgrade Notice ==
-= 1.1.0 =
-Compatibility for WP 6.5 and optimize the plugin assets loading method.
+= 1.2.0 =
+Compatibility for WP 6.6 and refactor the integration with Elementor.
== Frequently Asked Questions ==
@@ -87,6 +87,9 @@ No. You need to install Elementor Website Builder first.
== Changelog ==
+= 1.2.0 - 2024-07-20 =
+* Compatibility for WP 6.6 and refactor the integration with Elementor.
+
= 1.1.0 - 2024-04-04 =
* Compatibility for WP 6.5 and optimize the plugin assets loading method.