diff --git a/admin/class-spotmap-admin.php b/admin/class-spotmap-admin.php index 68e5859..f237c61 100644 --- a/admin/class-spotmap-admin.php +++ b/admin/class-spotmap-admin.php @@ -282,6 +282,21 @@ public function get_maps() return $maps; } + public function enqueue_plugins_page_script($hook) + { + if ($hook !== 'plugins.php') { + return; + } + wp_enqueue_style('wp-jquery-ui-dialog'); + wp_enqueue_script( + 'spotmap-deactivate', + plugin_dir_url(__DIR__) . 'admin/js/spotmap-deactivate.js', + [ 'jquery', 'jquery-ui-dialog' ], + SPOTMAP_VERSION, + true + ); + } + public function allow_gpx_upload($mime_types) { $mime_types['gpx'] = 'text/xml'; diff --git a/admin/js/spotmap-deactivate.js b/admin/js/spotmap-deactivate.js new file mode 100644 index 0000000..1f23347 --- /dev/null +++ b/admin/js/spotmap-deactivate.js @@ -0,0 +1,55 @@ +(function ($) { + 'use strict'; + + var orig = document.getElementById('deactivate-spotmap'); + if (!orig) { + return; + } + var deactivateHref = orig.href; + + function openAndDeactivate(url) { + window.open(url, '_blank'); + window.location.href = deactivateHref; + } + + var $dialog = $( + '
Spotmap is a hobby project I pour a lot of sweat and love into. It would mean the world to me to know why you\'re moving on.
' + + 'Would you mind leaving a quick note?
' + + 'Note: If you later delete the plugin, all tracked points and settings will be permanently removed.
' + + '