Reinstall feature
- implemented reinstall in Settings > Advanced - shorten placeholder for Form name input
This commit is contained in:
@@ -23,4 +23,9 @@ class Activator {
|
||||
$populator = new Populator();
|
||||
$populator->up();
|
||||
}
|
||||
|
||||
function deactivate() {
|
||||
$migrator = new Migrator();
|
||||
$migrator->down();
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,8 @@ class Analytics {
|
||||
}
|
||||
|
||||
function init() {
|
||||
add_action('admin_enqueue_scripts', array($this, 'setupAdminDependencies'));
|
||||
// review: this creates a fatal error when mailpoet tables are dropped.
|
||||
//add_action('admin_enqueue_scripts', array($this, 'setupAdminDependencies'));
|
||||
}
|
||||
|
||||
function setupAdminDependencies() {
|
||||
|
@@ -113,6 +113,7 @@ class Initializer {
|
||||
}
|
||||
|
||||
function setupAnalytics() {
|
||||
|
||||
$widget = new Analytics();
|
||||
$widget->init();
|
||||
}
|
||||
|
@@ -41,7 +41,7 @@ class Migrator {
|
||||
function down() {
|
||||
global $wpdb;
|
||||
|
||||
$drop_table = function($model) {
|
||||
$drop_table = function($model) use($wpdb) {
|
||||
$table = $this->prefix . $model;
|
||||
$wpdb->query("DROP TABLE {$table}");
|
||||
};
|
||||
|
25
lib/Router/Setup.php
Normal file
25
lib/Router/Setup.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace MailPoet\Router;
|
||||
use \MailPoet\Config\Activator;
|
||||
use \MailPoet\Models\Setting;
|
||||
|
||||
if(!defined('ABSPATH')) exit;
|
||||
|
||||
class Setup {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
function reset() {
|
||||
try {
|
||||
$activator = new Activator();
|
||||
$activator->deactivate();
|
||||
$activator->activate();
|
||||
$result = true;
|
||||
} catch(Exception $e) {
|
||||
$result = false;
|
||||
}
|
||||
wp_send_json(array(
|
||||
'result' => $result
|
||||
));
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@
|
||||
<h2 class="title">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="<%= __('Click to change the form name!') %>"
|
||||
placeholder="<%= __('Click to change the name!') %>"
|
||||
id="mailpoet_form_name"
|
||||
value="<%= form.name %>"
|
||||
/>
|
||||
|
@@ -182,3 +182,26 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(function($) {
|
||||
$(function() {
|
||||
$('#mailpoet_reinstall').on('click', function() {
|
||||
MailPoet.Ajax.post({
|
||||
'endpoint': 'setup',
|
||||
'action': 'reset'
|
||||
}).done(function(response) {
|
||||
if(response.result === true) {
|
||||
MailPoet.Notice.success(
|
||||
"<%= __('MailPoet has been reinstalled successfully using the same version. Settings and data have been deleted.') %>",
|
||||
{ scroll: true });
|
||||
} else {
|
||||
MailPoet.Notice.error(
|
||||
"<%= __('MailPoet could not be reinstalled. You might need to remove it manually first.') %>",
|
||||
{ scroll: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user