adding dynamic segments to export options
This commit is contained in:
@@ -9,6 +9,7 @@ use MailPoet\Models\Segment;
|
|||||||
use MailPoet\Models\Setting;
|
use MailPoet\Models\Setting;
|
||||||
use MailPoet\Models\Subscriber;
|
use MailPoet\Models\Subscriber;
|
||||||
use MailPoet\Settings\Pages;
|
use MailPoet\Settings\Pages;
|
||||||
|
use MailPoet\Util\Helpers;
|
||||||
|
|
||||||
class Reporter {
|
class Reporter {
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ class Reporter {
|
|||||||
'Number of active welcome emails' => $newsletters['welcome_newsletters_count'],
|
'Number of active welcome emails' => $newsletters['welcome_newsletters_count'],
|
||||||
'Number of segments' => isset($segments['dynamic']) ? (int)$segments['dynamic'] : 0,
|
'Number of segments' => isset($segments['dynamic']) ? (int)$segments['dynamic'] : 0,
|
||||||
'Number of lists' => isset($segments['default']) ? (int)$segments['default'] : 0,
|
'Number of lists' => isset($segments['default']) ? (int)$segments['default'] : 0,
|
||||||
'Plugin > MailPoet Premium' => is_plugin_active('mailpoet-premium/mailpoet-premium.php'),
|
'Plugin > MailPoet Premium' => Helpers::isPremiumActive(),
|
||||||
'Plugin > bounce add-on' => is_plugin_active('mailpoet-bounce-handler/mailpoet-bounce-handler.php'),
|
'Plugin > bounce add-on' => is_plugin_active('mailpoet-bounce-handler/mailpoet-bounce-handler.php'),
|
||||||
'Plugin > Bloom' => is_plugin_active('bloom-for-publishers/bloom.php'),
|
'Plugin > Bloom' => is_plugin_active('bloom-for-publishers/bloom.php'),
|
||||||
'Plugin > WP Holler' => is_plugin_active('holler-box/holler-box.php'),
|
'Plugin > WP Holler' => is_plugin_active('holler-box/holler-box.php'),
|
||||||
|
@@ -597,7 +597,7 @@ class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function import() {
|
function import() {
|
||||||
$import = new ImportExportFactory('import');
|
$import = new ImportExportFactory(ImportExportFactory::IMPORT_ACTION);
|
||||||
$data = $import->bootstrap();
|
$data = $import->bootstrap();
|
||||||
$data = array_merge($data, array(
|
$data = array_merge($data, array(
|
||||||
'date_types' => Block\Date::getDateTypes(),
|
'date_types' => Block\Date::getDateTypes(),
|
||||||
@@ -609,7 +609,7 @@ class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function export() {
|
function export() {
|
||||||
$export = new ImportExportFactory('export');
|
$export = new ImportExportFactory(ImportExportFactory::EXPORT_ACTION);
|
||||||
$data = $export->bootstrap();
|
$data = $export->bootstrap();
|
||||||
$data['sub_menu'] = 'mailpoet-subscribers';
|
$data['sub_menu'] = 'mailpoet-subscribers';
|
||||||
$this->displayPage('subscribers/importExport/export.html', $data);
|
$this->displayPage('subscribers/importExport/export.html', $data);
|
||||||
|
@@ -3,9 +3,13 @@ namespace MailPoet\Subscribers\ImportExport;
|
|||||||
|
|
||||||
use MailPoet\Models\CustomField;
|
use MailPoet\Models\CustomField;
|
||||||
use MailPoet\Models\Segment;
|
use MailPoet\Models\Segment;
|
||||||
|
use MailPoet\Premium\Models\DynamicSegment;
|
||||||
use MailPoet\Util\Helpers;
|
use MailPoet\Util\Helpers;
|
||||||
|
|
||||||
class ImportExportFactory {
|
class ImportExportFactory {
|
||||||
|
const IMPORT_ACTION = 'import';
|
||||||
|
const EXPORT_ACTION = 'export';
|
||||||
|
|
||||||
public $action;
|
public $action;
|
||||||
|
|
||||||
function __construct($action = null) {
|
function __construct($action = null) {
|
||||||
@@ -13,9 +17,12 @@ class ImportExportFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getSegments($with_confirmed_subscribers = false) {
|
function getSegments($with_confirmed_subscribers = false) {
|
||||||
$segments = ($this->action === 'import') ?
|
$segments = ($this->action === self::IMPORT_ACTION) ?
|
||||||
Segment::getSegmentsForImport() :
|
Segment::getSegmentsForImport() :
|
||||||
Segment::getSegmentsForExport($with_confirmed_subscribers);
|
Segment::getSegmentsForExport($with_confirmed_subscribers);
|
||||||
|
if(Helpers::isPremiumActive() && $this->action === self::EXPORT_ACTION) {
|
||||||
|
$segments = array_merge($segments, DynamicSegment::getSegmentsForExport());
|
||||||
|
}
|
||||||
return array_map(function($segment) {
|
return array_map(function($segment) {
|
||||||
if(!$segment['name']) $segment['name'] = __('Not In List', 'mailpoet');
|
if(!$segment['name']) $segment['name'] = __('Not In List', 'mailpoet');
|
||||||
if(!$segment['id']) $segment['id'] = 0;
|
if(!$segment['id']) $segment['id'] = 0;
|
||||||
|
@@ -159,4 +159,8 @@ class Helpers {
|
|||||||
? $_SERVER['REMOTE_ADDR']
|
? $_SERVER['REMOTE_ADDR']
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function isPremiumActive() {
|
||||||
|
return is_plugin_active('mailpoet-premium/mailpoet-premium.php');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user