Redirect to welcome or update page
This commit is contained in:
@ -159,23 +159,6 @@ body.mailpoet_modal_opened
|
||||
margin: 0
|
||||
text-align: right
|
||||
|
||||
.mailpoet_button
|
||||
padding: 3px 15px
|
||||
border: 1px solid #444
|
||||
font-weight: normal
|
||||
cursor: pointer
|
||||
background-color: #222
|
||||
color: #cfcfcf
|
||||
font-size: 1em
|
||||
|
||||
.mailpoet_button:hover
|
||||
background-color: #00aacc
|
||||
color: #fff
|
||||
|
||||
.mailpoet_button:active
|
||||
background-color: #00ccff
|
||||
color: #fff
|
||||
|
||||
@media screen and (max-width: 782px)
|
||||
#mailpoet_modal_overlay.mailpoet_panel_overlay
|
||||
top: 46px
|
||||
|
27
lib/Config/Changelog.php
Normal file
27
lib/Config/Changelog.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
namespace MailPoet\Config;
|
||||
use \MailPoet\Models\Setting;
|
||||
|
||||
class Changelog {
|
||||
function init() {
|
||||
add_action(
|
||||
'admin_init',
|
||||
array($this, 'setup')
|
||||
);
|
||||
}
|
||||
|
||||
function setup() {
|
||||
$version = Setting::getValue('version', null);
|
||||
if($version === null) {
|
||||
// new install
|
||||
Setting::setValue('version', Env::$version);
|
||||
wp_redirect(admin_url('admin.php?page=mailpoet-welcome'));
|
||||
exit;
|
||||
} else if($version !== Env::$version) {
|
||||
// update
|
||||
Setting::setValue('version', Env::$version);
|
||||
wp_redirect(admin_url('admin.php?page=mailpoet-update'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ class Initializer {
|
||||
$this->setupWidget();
|
||||
$this->setupAnalytics();
|
||||
$this->setupPermissions();
|
||||
$this->setupChangelog();
|
||||
}
|
||||
|
||||
function setupDB() {
|
||||
@ -104,4 +105,9 @@ class Initializer {
|
||||
$permissions = new Permissions();
|
||||
$permissions->init();
|
||||
}
|
||||
|
||||
function setupChangelog() {
|
||||
$changelog = new Changelog();
|
||||
$changelog->init();
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class Menu {
|
||||
'MailPoet',
|
||||
'manage_options',
|
||||
'mailpoet',
|
||||
array($this, 'welcome'),
|
||||
array($this, 'home'),
|
||||
$this->assets_url . '/img/menu_icon.png',
|
||||
30
|
||||
);
|
||||
@ -94,31 +94,42 @@ class Menu {
|
||||
'mailpoet-export',
|
||||
array($this, 'export')
|
||||
);
|
||||
// add_submenu_page(
|
||||
// 'mailpoet',
|
||||
// __('Newsletter editor'),
|
||||
// __('Newsletter editor'),
|
||||
// 'manage_options',
|
||||
// 'mailpoet-newsletter-editor',
|
||||
// array($this, 'newletterEditor')
|
||||
// );
|
||||
$this->registered_pages();
|
||||
}
|
||||
|
||||
function registered_pages() {
|
||||
global $_registered_pages;
|
||||
$pages = array(
|
||||
'mailpoet-welcome' => array($this, 'welcome'),
|
||||
'mailpoet-form-editor' => array($this, 'formEditor'),
|
||||
'mailpoet-newsletter-editor' => array($this, 'newletterEditor')
|
||||
add_submenu_page(
|
||||
null,
|
||||
__('Welcome'),
|
||||
__('Welcome'),
|
||||
'manage_options',
|
||||
'mailpoet-welcome',
|
||||
array($this, 'welcome')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
null,
|
||||
__('Update'),
|
||||
__('Update'),
|
||||
'manage_options',
|
||||
'mailpoet-update',
|
||||
array($this, 'update')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
null,
|
||||
__('Form editor'),
|
||||
__('Form editor'),
|
||||
'manage_options',
|
||||
'mailpoet-form-editor',
|
||||
array($this, 'formEditor')
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
null,
|
||||
__('Newsletter editor'),
|
||||
__('Newsletter editor'),
|
||||
'manage_options',
|
||||
'mailpoet-newsletter-editor',
|
||||
array($this, 'newletterEditor')
|
||||
);
|
||||
foreach($pages as $menu_slug => $callback) {
|
||||
$hookname = get_plugin_page_hookname($menu_slug, null);
|
||||
if(!empty($hookname)) {
|
||||
add_action($hookname, $callback);
|
||||
}
|
||||
$_registered_pages[$hookname] = true;
|
||||
}
|
||||
}
|
||||
|
||||
function home() {
|
||||
@ -135,6 +146,15 @@ class Menu {
|
||||
echo $this->renderer->render('welcome.html', $data);
|
||||
}
|
||||
|
||||
function update() {
|
||||
$data = array(
|
||||
'settings' => Setting::getAll(),
|
||||
'current_user' => wp_get_current_user()
|
||||
);
|
||||
|
||||
echo $this->renderer->render('update.html', $data);
|
||||
}
|
||||
|
||||
function settings() {
|
||||
$settings = Setting::getAll();
|
||||
|
||||
|
@ -28,6 +28,13 @@ class Setting extends Model {
|
||||
}
|
||||
}
|
||||
|
||||
public static function setValue($key, $value) {
|
||||
return Setting::createOrUpdate(array(
|
||||
'name' => $key,
|
||||
'value' => $value
|
||||
));
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$settingsCollection = self::findMany();
|
||||
$settings = array();
|
||||
|
20
views/update.html
Normal file
20
views/update.html
Normal file
@ -0,0 +1,20 @@
|
||||
<% extends 'layout.html' %>
|
||||
|
||||
<% block content %>
|
||||
<div id="mailpoet_welcome">
|
||||
<h2><%= __("What's new") %></h2>
|
||||
|
||||
<h3>Settings:</h3>
|
||||
<%= dump(settings) %>
|
||||
|
||||
<h3>Current user:</h3>
|
||||
<%= dump(current_user) %>
|
||||
|
||||
<p>
|
||||
<a
|
||||
class="button button-primary"
|
||||
href="<%= admin_url('admin.php?page=mailpoet') %>"
|
||||
>Take me to MailPoet</a>
|
||||
</p>
|
||||
</div>
|
||||
<% endblock %>
|
@ -9,5 +9,12 @@
|
||||
|
||||
<h3>Current user:</h3>
|
||||
<%= dump(current_user) %>
|
||||
|
||||
<p>
|
||||
<a
|
||||
class="button button-primary"
|
||||
href="<%= admin_url('admin.php?page=mailpoet') %>"
|
||||
>Take me to MailPoet</a>
|
||||
</p>
|
||||
</div>
|
||||
<% endblock %>
|
||||
|
Reference in New Issue
Block a user