Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions admin/class-spotmap-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
55 changes: 55 additions & 0 deletions admin/js/spotmap-deactivate.js
Original file line number Diff line number Diff line change
@@ -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 = $(
'<div title="Before you go...">' +
'<p><strong>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.</strong></p>' +
'<p>Would you mind leaving a quick note?</p>' +
'<p><strong>Note:</strong> If you later <em>delete</em> the plugin, all tracked points and settings will be permanently removed.</p>' +
'</div>'
);

$dialog.dialog({
autoOpen: false,
modal: true,
width: 510,
buttons: [
{
text: 'Post on WordPress.org',
'class': 'button button-primary',
click: function () {
openAndDeactivate('https://wordpress.org/support/plugin/spotmap/');
},
},
{
text: 'Post on GitHub',
'class': 'button button-primary',
click: function () {
openAndDeactivate('https://github.com/techtimo/spotmap/issues/new');
},
},
{
text: 'Skip & Deactivate',
'class': 'button',
click: function () { window.location.href = deactivateHref; },
},
],
});

$(orig).on('click', function (e) {
e.preventDefault();
$dialog.dialog('open');
});

})(jQuery);
1 change: 1 addition & 0 deletions includes/class-spotmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private function define_admin_hooks()
{
$this->admin = new Spotmap_Admin();
$this->loader->add_action('admin_enqueue_scripts', $this->admin, 'enqueue_scripts');
$this->loader->add_action('admin_enqueue_scripts', $this->admin, 'enqueue_plugins_page_script');
$this->loader->add_filter('cron_schedules', $this->admin, 'add_cron_schedule');
$this->loader->add_filter('plugin_action_links_' . SPOTMAP_PLUGIN_BASENAME, $this->admin, 'add_link_plugin_overview');
$this->loader->add_action('admin_menu', $this->admin, 'add_options_page');
Expand Down
Loading