Remove the Update page
[MAILPOET-3406]
This commit is contained in:
@ -1,72 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace MailPoet\AdminPages\Pages;
|
|
||||||
|
|
||||||
use MailPoet\AdminPages\PageRenderer;
|
|
||||||
use MailPoet\Config\Env;
|
|
||||||
use MailPoet\Config\Menu;
|
|
||||||
use MailPoet\Settings\SettingsController;
|
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
|
||||||
use MailPoet\WP\Readme;
|
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
|
||||||
|
|
||||||
class Update {
|
|
||||||
/** @var PageRenderer */
|
|
||||||
private $pageRenderer;
|
|
||||||
|
|
||||||
/** @var WPFunctions */
|
|
||||||
private $wp;
|
|
||||||
|
|
||||||
/** @var SettingsController */
|
|
||||||
private $settings;
|
|
||||||
|
|
||||||
public function __construct(PageRenderer $pageRenderer, WPFunctions $wp, SettingsController $settings) {
|
|
||||||
$this->pageRenderer = $pageRenderer;
|
|
||||||
$this->wp = $wp;
|
|
||||||
$this->settings = $settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function render() {
|
|
||||||
global $wp;
|
|
||||||
$currentUrl = $this->wp->homeUrl(add_query_arg($wp->query_string, $wp->request)); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
|
|
||||||
$redirectUrl =
|
|
||||||
(!empty($_GET['mailpoet_redirect']))
|
|
||||||
? urldecode($_GET['mailpoet_redirect'])
|
|
||||||
: $this->wp->wpGetReferer();
|
|
||||||
|
|
||||||
if (
|
|
||||||
$redirectUrl === $currentUrl
|
|
||||||
or
|
|
||||||
strpos($redirectUrl, 'mailpoet') === false
|
|
||||||
) {
|
|
||||||
$redirectUrl = $this->wp->adminUrl('admin.php?page=' . Menu::MAIN_PAGE_SLUG);
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'settings' => $this->settings->getAll(),
|
|
||||||
'current_user' => $this->wp->wpGetCurrentUser(),
|
|
||||||
'redirect_url' => $redirectUrl,
|
|
||||||
'sub_menu' => Menu::MAIN_PAGE_SLUG,
|
|
||||||
];
|
|
||||||
|
|
||||||
$data['is_new_user'] = true;
|
|
||||||
$data['is_old_user'] = false;
|
|
||||||
if (!empty($data['settings']['installed_at'])) {
|
|
||||||
$installedAt = Carbon::createFromTimestamp(strtotime($data['settings']['installed_at']));
|
|
||||||
$currentTime = Carbon::createFromTimestamp($this->wp->currentTime('timestamp'));
|
|
||||||
$data['is_new_user'] = $currentTime->diffInDays($installedAt) <= 30;
|
|
||||||
$data['is_old_user'] = $currentTime->diffInMonths($installedAt) >= 6;
|
|
||||||
$data['stop_call_for_rating'] = isset($data['settings']['stop_call_for_rating']) ? $data['settings']['stop_call_for_rating'] : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$readmeFile = Env::$path . '/readme.txt';
|
|
||||||
if (is_readable($readmeFile)) {
|
|
||||||
$changelog = Readme::parseChangelog(file_get_contents($readmeFile), 1);
|
|
||||||
if ($changelog) {
|
|
||||||
$data['changelog'] = $changelog;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->pageRenderer->displayPage('update.html', $data);
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,7 +15,6 @@ use MailPoet\AdminPages\Pages\Settings;
|
|||||||
use MailPoet\AdminPages\Pages\Subscribers;
|
use MailPoet\AdminPages\Pages\Subscribers;
|
||||||
use MailPoet\AdminPages\Pages\SubscribersExport;
|
use MailPoet\AdminPages\Pages\SubscribersExport;
|
||||||
use MailPoet\AdminPages\Pages\SubscribersImport;
|
use MailPoet\AdminPages\Pages\SubscribersImport;
|
||||||
use MailPoet\AdminPages\Pages\Update;
|
|
||||||
use MailPoet\AdminPages\Pages\WelcomeWizard;
|
use MailPoet\AdminPages\Pages\WelcomeWizard;
|
||||||
use MailPoet\AdminPages\Pages\WooCommerceSetup;
|
use MailPoet\AdminPages\Pages\WooCommerceSetup;
|
||||||
use MailPoet\DI\ContainerWrapper;
|
use MailPoet\DI\ContainerWrapper;
|
||||||
@ -350,19 +349,6 @@ class Menu {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update page
|
|
||||||
$this->wp->addSubmenuPage(
|
|
||||||
true,
|
|
||||||
$this->setPageTitle(__('Update', 'mailpoet')),
|
|
||||||
$this->wp->__('Update', 'mailpoet'),
|
|
||||||
AccessControl::PERMISSION_ACCESS_PLUGIN_ADMIN,
|
|
||||||
'mailpoet-update',
|
|
||||||
[
|
|
||||||
$this,
|
|
||||||
'update',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Migration page
|
// Migration page
|
||||||
$this->wp->addSubmenuPage(
|
$this->wp->addSubmenuPage(
|
||||||
true,
|
true,
|
||||||
@ -404,10 +390,6 @@ class Menu {
|
|||||||
$this->container->get(WooCommerceSetup::class)->render();
|
$this->container->get(WooCommerceSetup::class)->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
|
||||||
$this->container->get(Update::class)->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function premium() {
|
public function premium() {
|
||||||
$this->container->get(Premium::class)->render();
|
$this->container->get(Premium::class)->render();
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ class ContainerConfigurator implements IContainerConfigurator {
|
|||||||
$container->autowire(\MailPoet\AdminPages\Pages\Subscribers::class)->setPublic(true);
|
$container->autowire(\MailPoet\AdminPages\Pages\Subscribers::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\AdminPages\Pages\SubscribersExport::class)->setPublic(true);
|
$container->autowire(\MailPoet\AdminPages\Pages\SubscribersExport::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\AdminPages\Pages\SubscribersImport::class)->setPublic(true);
|
$container->autowire(\MailPoet\AdminPages\Pages\SubscribersImport::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\AdminPages\Pages\Update::class)->setPublic(true);
|
|
||||||
$container->autowire(\MailPoet\AdminPages\Pages\WelcomeWizard::class)->setPublic(true);
|
$container->autowire(\MailPoet\AdminPages\Pages\WelcomeWizard::class)->setPublic(true);
|
||||||
$container->autowire(\MailPoet\AdminPages\Pages\WooCommerceSetup::class)->setPublic(true);
|
$container->autowire(\MailPoet\AdminPages\Pages\WooCommerceSetup::class)->setPublic(true);
|
||||||
// Analytics
|
// Analytics
|
||||||
|
@ -1,124 +0,0 @@
|
|||||||
<% extends 'layout.html' %>
|
|
||||||
|
|
||||||
<% block content %>
|
|
||||||
|
|
||||||
<div class="wrap mailpoet-about-wrap">
|
|
||||||
<h1><%= __('Thanks for updating MailPoet') %></h1>
|
|
||||||
|
|
||||||
<div class="feature-section one-col mailpoet_centered">
|
|
||||||
<a class="button button-primary go-to-plugin" href="<%= redirect_url %>"><%= __('Thanks, now take me to where I was going.') %> →</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="mailpoet-changelog" class="feature-section one-col">
|
|
||||||
<h2 class="mailpoet-feature-top"><%= __('List of Changes') %></h2>
|
|
||||||
<% if changelog %>
|
|
||||||
<% for item in changelog %>
|
|
||||||
<h3><%= item.version %></h3>
|
|
||||||
<ul>
|
|
||||||
<% for change in item.changes %>
|
|
||||||
<li><%= change %></li>
|
|
||||||
<% endfor %>
|
|
||||||
</ul>
|
|
||||||
<% endfor %>
|
|
||||||
<% else %>
|
|
||||||
<p style="text-align: center"><%= __('See readme.txt for a changelog.') %></p>
|
|
||||||
<% endif %>
|
|
||||||
<a class="button button-secondary" href="https://wordpress.org/plugins/mailpoet/#developers" target="_blank"><%= __('View all changes') %> →</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="feature-section one-col mailpoet_centered">
|
|
||||||
|
|
||||||
<% if(is_new_user) %>
|
|
||||||
<h2><%= __('Care to Give Your Opinion?') %></h2>
|
|
||||||
<div class="pd-embed" id="pd_1519225570"></div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var _polldaddy = [] || _polldaddy;
|
|
||||||
|
|
||||||
_polldaddy.push( {
|
|
||||||
type: "iframe",
|
|
||||||
auto: "1",
|
|
||||||
domain: "mailpoet.polldaddy.com/s/",
|
|
||||||
id: "improvements-first-steps",
|
|
||||||
placeholder: "pd_1519225570"
|
|
||||||
} );
|
|
||||||
|
|
||||||
(function(d,c,j){if(!document.getElementById(j)){var pd=d.createElement(c),s;pd.id=j;pd.src=('https:'==document.location.protocol)?'https://polldaddy.com/survey.js':'http://i0.poll.fm/survey.js';s=document.getElementsByTagName(c)[0];s.parentNode.insertBefore(pd,s);}}(document,'script','pd-embed'));
|
|
||||||
</script><br>
|
|
||||||
<% elseif(is_old_user and not stop_call_for_rating) %>
|
|
||||||
<h2><%= __('Do you enjoy using MailPoet?') %></h2>
|
|
||||||
<p>
|
|
||||||
<%= __('If you have the time, we’d really appreciate it if you left us a review on the WordPress Plugin Directory.') %>
|
|
||||||
<br><%= __('Every star counts.') %>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<a class="button" id="no-thanks"><%= __('No thanks') %></a>
|
|
||||||
<a class="button" href="admin.php?page=mailpoet-newsletters"><%= __('Next time') %></a>
|
|
||||||
<a class="button button-primary" id="rate-now" href="https://wordpress.org/support/plugin/mailpoet/reviews/?rate=5#new-post" target="_blank"><%= __('Rate now') %></a>
|
|
||||||
<p>
|
|
||||||
<%= __('Care to share criticism or a feature request instead?') %>
|
|
||||||
<br><%= __('Click on the question mark (?) in the blue circle at the bottom right of this page to send us a message.') %>
|
|
||||||
<% else %>
|
|
||||||
<h2><%= __('Care to Give Your Opinion?') %></h2>
|
|
||||||
<script type="text/javascript" charset="utf-8" src="https://secure.polldaddy.com/p/9957416.js"></script>
|
|
||||||
<noscript><a href="https://polldaddy.com/poll/9957416/">How would you rate the reliability of MailPoet?</a></noscript>
|
|
||||||
<% endif %>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<div class="feature-section one-col mailpoet_centered">
|
|
||||||
<a class="button button-primary go-to-plugin" href="<%= redirect_url %>"><%= __('Thanks, now take me to where I was going.') %> →</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
jQuery(function($) {
|
|
||||||
function stopShowingCallForRating() {
|
|
||||||
return MailPoet.Ajax.post({
|
|
||||||
api_version: window.mailpoet_api_version,
|
|
||||||
endpoint: 'settings',
|
|
||||||
action: 'set',
|
|
||||||
data: {
|
|
||||||
stop_call_for_rating: true,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$('#no-thanks').click(function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
stopShowingCallForRating().done(function () {
|
|
||||||
window.location.href = 'admin.php?page=mailpoet-newsletters';
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$('#rate-now').click(stopShowingCallForRating);
|
|
||||||
|
|
||||||
$(function() {
|
|
||||||
MailPoet.trackEvent(
|
|
||||||
'User has updated MailPoet',
|
|
||||||
{'MailPoet Free version': window.mailpoet_version}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
$('#mailpoet_analytics_enabled').on('click', function() {
|
|
||||||
var is_enabled = $(this).is(':checked') ? true : '';
|
|
||||||
MailPoet.Ajax.post({
|
|
||||||
api_version: window.mailpoet_api_version,
|
|
||||||
endpoint: 'settings',
|
|
||||||
action: 'set',
|
|
||||||
data: {
|
|
||||||
analytics: { enabled: (is_enabled)}
|
|
||||||
}
|
|
||||||
}).fail(function(response) {
|
|
||||||
if (response.errors.length > 0) {
|
|
||||||
MailPoet.Notice.error(
|
|
||||||
response.errors.map(function(error) { return error.message; }),
|
|
||||||
{ scroll: true }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<% endblock %>
|
|
Reference in New Issue
Block a user