- Enables MailChimp key verification (import step 1)
This commit is contained in:
@@ -168,12 +168,11 @@ define(
|
|||||||
// show loading indicator
|
// show loading indicator
|
||||||
MailPoet.Modal.loading(true);
|
MailPoet.Modal.loading(true);
|
||||||
|
|
||||||
/* mailpoet_get_json(
|
MailPoet.Ajax.post({
|
||||||
'subscribers_import_mailchimp.php',
|
endpoint: 'import',
|
||||||
{
|
action: 'getMailChimpLists',
|
||||||
'api_key': subscribers_mailchimp_key.val(), 'action': 'get_lists'
|
data: {api_key: subscribers_mailchimp_key.val()}
|
||||||
},
|
}).done(function (result) {
|
||||||
function (result) {
|
|
||||||
if (result.status === 'success') {
|
if (result.status === 'success') {
|
||||||
jQuery('.mailpoet_mailchimp-key-status').html('').removeClass().addClass('mailpoet_mailchimp-key-status mailpoet_mailchimp-ok');
|
jQuery('.mailpoet_mailchimp-key-status').html('').removeClass().addClass('mailpoet_mailchimp-key-status mailpoet_mailchimp-ok');
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
@@ -212,13 +211,12 @@ define(
|
|||||||
}
|
}
|
||||||
// hide loading indicator
|
// hide loading indicator
|
||||||
MailPoet.Modal.loading(false);
|
MailPoet.Modal.loading(false);
|
||||||
},
|
}).error(function (error) {
|
||||||
function (result) {
|
|
||||||
// hide loading indicator
|
// hide loading indicator
|
||||||
MailPoet.Modal.loading(false);
|
MailPoet.Modal.loading(false);
|
||||||
MailPoet.Notice.error(MailPoetI18n.serverError + result.statusText.toLowerCase() + '.');
|
MailPoet.Notice.error(MailPoetI18n.serverError + error.statusText.toLowerCase() + '.');
|
||||||
}
|
});
|
||||||
);*/
|
MailPoet.Modal.loading(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
subscribers_mailchimp_process.click(function () {
|
subscribers_mailchimp_process.click(function () {
|
||||||
@@ -255,7 +253,9 @@ define(
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Backbone.History.started) Backbone.history.start();
|
if (!Backbone.History.started) {
|
||||||
|
Backbone.history.start();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
@@ -216,11 +216,11 @@ class Menu {
|
|||||||
function import() {
|
function import() {
|
||||||
$import = new Import();
|
$import = new Import();
|
||||||
$data = $import->bootstrapImportMenu();
|
$data = $import->bootstrapImportMenu();
|
||||||
|
|
||||||
echo $this->renderer->render('import.html', $data);
|
echo $this->renderer->render('import.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function formEditor() {
|
function formEditor() {
|
||||||
$id = (isset($_GET['id']) ? (int)$_GET['id'] : 0);
|
$id = (isset($_GET['id']) ? (int)$_GET['id'] : 0);
|
||||||
$form = Form::findOne($id);
|
$form = Form::findOne($id);
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use MailPoet\Models\CustomField;
|
use MailPoet\Models\CustomField;
|
||||||
use MailPoet\Models\Segment;
|
use MailPoet\Models\Segment;
|
||||||
|
use MailPoet\Util\Helpers;
|
||||||
|
|
||||||
class Import {
|
class Import {
|
||||||
|
|
||||||
@@ -98,6 +99,9 @@ class Import {
|
|||||||
$data['subscriberFields'],
|
$data['subscriberFields'],
|
||||||
$data['subscriberCustomFields']
|
$data['subscriberCustomFields']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$data['maximumParseSize'] = Helpers::get_maximum_post_size();
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
13
lib/Router/Import.php
Normal file
13
lib/Router/Import.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
namespace MailPoet\Router;
|
||||||
|
|
||||||
|
use MailPoet\Import\MailChimp;
|
||||||
|
|
||||||
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
|
class Import {
|
||||||
|
function getMailChimpLists($data) {
|
||||||
|
$mailChimp = new MailChimp($data['api_key']);
|
||||||
|
wp_send_json($mailChimp->getLists());
|
||||||
|
}
|
||||||
|
}
|
@@ -1,12 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace MailPoet\Util;
|
namespace MailPoet\Util;
|
||||||
|
|
||||||
|
class Helpers {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Matches each symbol of PHP date format standard
|
* Matches each symbol of PHP date format standard
|
||||||
* with jQuery equivalent codeword
|
* with jQuery equivalent codeword
|
||||||
* @author Tristan Jahier
|
* @author Tristan Jahier
|
||||||
*/
|
*/
|
||||||
function dateformat_PHP_to_jQueryUI($php_format) {
|
static function dateformat_PHP_to_jQueryUI($php_format) {
|
||||||
$SYMBOLS_MATCHING = array(
|
$SYMBOLS_MATCHING = array(
|
||||||
// Day
|
// Day
|
||||||
'd' => 'dd',
|
'd' => 'dd',
|
||||||
@@ -74,7 +76,7 @@ function dateformat_PHP_to_jQueryUI($php_format) {
|
|||||||
/*
|
/*
|
||||||
* Determine maximum post size in bytes
|
* Determine maximum post size in bytes
|
||||||
*/
|
*/
|
||||||
function get_maximum_post_size() {
|
static function get_maximum_post_size() {
|
||||||
$maximum_post_size = ini_get('post_max_size');
|
$maximum_post_size = ini_get('post_max_size');
|
||||||
$maximum_post_size_bytes = (int) $maximum_post_size;
|
$maximum_post_size_bytes = (int) $maximum_post_size;
|
||||||
$unit = strtolower($maximum_post_size[strlen($maximum_post_size) - 1]);
|
$unit = strtolower($maximum_post_size[strlen($maximum_post_size) - 1]);
|
||||||
@@ -93,8 +95,9 @@ function get_maximum_post_size() {
|
|||||||
/*
|
/*
|
||||||
* Flatten multidimensional array
|
* Flatten multidimensional array
|
||||||
*/
|
*/
|
||||||
function flatten_array($array) {
|
static function flatten_array($array) {
|
||||||
return call_user_func_array(
|
return call_user_func_array(
|
||||||
'array_merge_recursive', array_map('array_values', $array)
|
'array_merge_recursive', array_map('array_values', $array)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user