- Enables MailChimp key verification (import step 1)
This commit is contained in:
@@ -168,12 +168,11 @@ define(
|
||||
// show loading indicator
|
||||
MailPoet.Modal.loading(true);
|
||||
|
||||
/* mailpoet_get_json(
|
||||
'subscribers_import_mailchimp.php',
|
||||
{
|
||||
'api_key': subscribers_mailchimp_key.val(), 'action': 'get_lists'
|
||||
},
|
||||
function (result) {
|
||||
MailPoet.Ajax.post({
|
||||
endpoint: 'import',
|
||||
action: 'getMailChimpLists',
|
||||
data: {api_key: subscribers_mailchimp_key.val()}
|
||||
}).done(function (result) {
|
||||
if (result.status === 'success') {
|
||||
jQuery('.mailpoet_mailchimp-key-status').html('').removeClass().addClass('mailpoet_mailchimp-key-status mailpoet_mailchimp-ok');
|
||||
if (result.data) {
|
||||
@@ -212,13 +211,12 @@ define(
|
||||
}
|
||||
// hide loading indicator
|
||||
MailPoet.Modal.loading(false);
|
||||
},
|
||||
function (result) {
|
||||
}).error(function (error) {
|
||||
// hide loading indicator
|
||||
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 () {
|
||||
@@ -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() {
|
||||
$import = new Import();
|
||||
$data = $import->bootstrapImportMenu();
|
||||
|
||||
echo $this->renderer->render('import.html', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function formEditor() {
|
||||
$id = (isset($_GET['id']) ? (int)$_GET['id'] : 0);
|
||||
$form = Form::findOne($id);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
use MailPoet\Models\CustomField;
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\Util\Helpers;
|
||||
|
||||
class Import {
|
||||
|
||||
@@ -98,6 +99,9 @@ class Import {
|
||||
$data['subscriberFields'],
|
||||
$data['subscriberCustomFields']
|
||||
);
|
||||
|
||||
$data['maximumParseSize'] = Helpers::get_maximum_post_size();
|
||||
|
||||
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
|
||||
namespace MailPoet\Util;
|
||||
|
||||
class Helpers {
|
||||
|
||||
/*
|
||||
* Matches each symbol of PHP date format standard
|
||||
* with jQuery equivalent codeword
|
||||
* @author Tristan Jahier
|
||||
*/
|
||||
function dateformat_PHP_to_jQueryUI($php_format) {
|
||||
static function dateformat_PHP_to_jQueryUI($php_format) {
|
||||
$SYMBOLS_MATCHING = array(
|
||||
// Day
|
||||
'd' => 'dd',
|
||||
@@ -74,7 +76,7 @@ function dateformat_PHP_to_jQueryUI($php_format) {
|
||||
/*
|
||||
* 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_bytes = (int) $maximum_post_size;
|
||||
$unit = strtolower($maximum_post_size[strlen($maximum_post_size) - 1]);
|
||||
@@ -93,8 +95,9 @@ function get_maximum_post_size() {
|
||||
/*
|
||||
* Flatten multidimensional array
|
||||
*/
|
||||
function flatten_array($array) {
|
||||
static function flatten_array($array) {
|
||||
return call_user_func_array(
|
||||
'array_merge_recursive', array_map('array_values', $array)
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user