Merged master / fixed merge conflict
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,3 +12,4 @@ npm-debug.log
|
|||||||
/views/cache/**
|
/views/cache/**
|
||||||
temp
|
temp
|
||||||
.idea
|
.idea
|
||||||
|
wysija-newsletters.zip
|
||||||
|
@ -48,15 +48,15 @@ class RoboFile extends \Robo\Tasks {
|
|||||||
|
|
||||||
function makepot() {
|
function makepot() {
|
||||||
$this->_exec('grunt makepot'.
|
$this->_exec('grunt makepot'.
|
||||||
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
||||||
' --base_path '.__DIR__
|
' --base_path '.__DIR__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pushpot() {
|
function pushpot() {
|
||||||
$this->_exec('grunt pushpot'.
|
$this->_exec('grunt pushpot'.
|
||||||
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
|
||||||
' --base_path '.__DIR__
|
' --base_path '.__DIR__
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
46
build
Executable file
46
build
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# remove previouz build.
|
||||||
|
rm wysija-newsletters.zip;
|
||||||
|
|
||||||
|
# Create temp dir.
|
||||||
|
mkdir wysija-newsletters;
|
||||||
|
|
||||||
|
# Cleanup Composer and NPM.
|
||||||
|
rm -rf vendor;
|
||||||
|
rm -rf node_modules;
|
||||||
|
rm composer.lock;
|
||||||
|
|
||||||
|
# Install Composer and NPM deps.
|
||||||
|
./composer.phar install --no-dev;
|
||||||
|
npm install --production;
|
||||||
|
|
||||||
|
# Copy release folders.
|
||||||
|
cp -rf lang wysija-newsletters;
|
||||||
|
cp -rf assets wysija-newsletters;
|
||||||
|
cp -rf lib wysija-newsletters;
|
||||||
|
cp -rf vendor wysija-newsletters;
|
||||||
|
cp -rf views wysija-newsletters;
|
||||||
|
|
||||||
|
# Copy release files.
|
||||||
|
cp LICENSE wysija-newsletters;
|
||||||
|
cp index.php wysija-newsletters;
|
||||||
|
cp mailpoet.php wysija-newsletters;
|
||||||
|
cp readme.txt wysija-newsletters;
|
||||||
|
cp uninstall.php wysija-newsletters;
|
||||||
|
cp webpack.config.js wysija-newsletters;
|
||||||
|
|
||||||
|
# Zip final release.
|
||||||
|
zip -r wysija-newsletters.zip wysija-newsletters;
|
||||||
|
|
||||||
|
# Remove temp dir.
|
||||||
|
rm -rf wysija-newsletters;
|
||||||
|
|
||||||
|
# Cleanup Composer and NPM.
|
||||||
|
rm -rf vendor;
|
||||||
|
rm -rf node_modules;
|
||||||
|
rm composer.lock;
|
||||||
|
|
||||||
|
# Reinstall dev dependencies.
|
||||||
|
./composer.phar install;
|
||||||
|
./do install;
|
2
composer.lock
generated
2
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "ff54fd1b75cd31ce67aaf2fa0ee617da",
|
"hash": "0e2b177a6de46c3a1263386f1b803faf",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "cerdic/css-tidy",
|
"name": "cerdic/css-tidy",
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
namespace MailPoet\Config;
|
namespace MailPoet\Config;
|
||||||
|
|
||||||
use MailPoet\Models;
|
use MailPoet\Models;
|
||||||
|
use MailPoet\Router;
|
||||||
|
|
||||||
if (!defined('ABSPATH')) exit;
|
if (!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ class Initializer {
|
|||||||
$this->setupRenderer();
|
$this->setupRenderer();
|
||||||
$this->setupLocalizer();
|
$this->setupLocalizer();
|
||||||
$this->setupMenu();
|
$this->setupMenu();
|
||||||
|
$this->setupRouter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupDB() {
|
function setupDB() {
|
||||||
@ -57,4 +59,9 @@ class Initializer {
|
|||||||
);
|
);
|
||||||
$menu->init();
|
$menu->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupRouter() {
|
||||||
|
$router = new Router\Router();
|
||||||
|
$router->init();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
43
lib/Router/Router.php
Normal file
43
lib/Router/Router.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
namespace MailPoet\Router;
|
||||||
|
|
||||||
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
|
class Router {
|
||||||
|
function __construct() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
add_action(
|
||||||
|
'admin_head',
|
||||||
|
array($this, 'setToken')
|
||||||
|
);
|
||||||
|
add_action(
|
||||||
|
'wp_ajax_mailpoet',
|
||||||
|
array($this, 'setup')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup() {
|
||||||
|
$this->securityCheck();
|
||||||
|
$class = ucfirst($_POST['endpoint']);
|
||||||
|
$endpoint = __NAMESPACE__ . "\\" . $class;
|
||||||
|
$method = $_POST['method'];
|
||||||
|
$args = $_POST['args'];
|
||||||
|
$endpoint = new $endpoint();
|
||||||
|
$endpoint->$method(json_encode($args));
|
||||||
|
}
|
||||||
|
|
||||||
|
function setToken() {
|
||||||
|
$token = wp_create_nonce('mailpoet_token');
|
||||||
|
$global = '<script type="text/javascript">';
|
||||||
|
$global .= 'var mailpoet_token = "' . $token . '";';
|
||||||
|
$global .= "</script>/n";
|
||||||
|
echo $global;
|
||||||
|
}
|
||||||
|
|
||||||
|
function securityCheck() {
|
||||||
|
if (!current_user_can('manage_options')) {die();}
|
||||||
|
if (!wp_verify_nonce($_POST['token'], 'mailpoet_token')) {die();}
|
||||||
|
}
|
||||||
|
}
|
18
lib/Router/Settings.php
Normal file
18
lib/Router/Settings.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
namespace MailPoet\Router;
|
||||||
|
|
||||||
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
|
class Settings {
|
||||||
|
function __construct() {
|
||||||
|
}
|
||||||
|
|
||||||
|
function get($params) {
|
||||||
|
$data = array(
|
||||||
|
'first_name' => 'John',
|
||||||
|
'last_name' => 'Mailer',
|
||||||
|
'email' => 'john@mailpoet.com'
|
||||||
|
);
|
||||||
|
wp_send_json($params);
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,54 @@
|
|||||||
|
|
||||||
<% block content %>
|
<% block content %>
|
||||||
<h1><%= 'Settings' %></h1>
|
<h1><%= 'Settings' %></h1>
|
||||||
<p><%= __('First Name') %></p>
|
|
||||||
<p><%= __('Last Name') %></p>
|
<form id="mailpoet_settings" novalidate>
|
||||||
<p><%= __('Email') %></p>
|
<p>
|
||||||
|
<label>
|
||||||
|
<%= __('First Name') %>
|
||||||
|
<input type="text" name="first_name" />
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<%= __('Last Name') %>
|
||||||
|
<input type="text" name="last_name" />
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<%= __('Email') %>
|
||||||
|
<input type="email" name="email" />
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<input type="submit" class="button-secondary"
|
||||||
|
value="<%= __('Submit') %>"
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
jQuery(document).ready(function($) {
|
||||||
|
$.ajax({
|
||||||
|
url: ajaxurl,
|
||||||
|
type: 'post',
|
||||||
|
data: {
|
||||||
|
action: 'mailpoet',
|
||||||
|
token: mailpoet_token,
|
||||||
|
endpoint: 'settings',
|
||||||
|
method: 'get',
|
||||||
|
args: {
|
||||||
|
first_name: 'John'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success : function(response) {
|
||||||
|
console.log(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
Reference in New Issue
Block a user