using apply_filters
This commit is contained in:
@ -9,7 +9,6 @@ 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 {
|
||||||
|
|
||||||
@ -53,7 +52,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' => Helpers::isPremiumActive(),
|
'Plugin > MailPoet Premium' => is_plugin_active('mailpoet-premium/mailpoet-premium.php'),
|
||||||
'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'),
|
||||||
|
@ -21,8 +21,7 @@ class DefaultSubscribersGetter {
|
|||||||
$this->get_subscribers_without_segment = (array_search(0, $segments_ids) !== false);
|
$this->get_subscribers_without_segment = (array_search(0, $segments_ids) !== false);
|
||||||
$this->segments_ids = $this->filterSegmentIds($segments_ids);
|
$this->segments_ids = $this->filterSegmentIds($segments_ids);
|
||||||
$this->batch_size = $batch_size;
|
$this->batch_size = $batch_size;
|
||||||
$this->offset = 0;
|
$this->reset();
|
||||||
$this->finished = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function filterSegmentIds($ids) {
|
protected function filterSegmentIds($ids) {
|
||||||
@ -39,17 +38,13 @@ class DefaultSubscribersGetter {
|
|||||||
return $ids;
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the `offset` and `finished` properties;
|
|
||||||
* to be able to start getting subscribers again.
|
|
||||||
*/
|
|
||||||
public function reset() {
|
public function reset() {
|
||||||
$this->offset = 0;
|
$this->offset = 0;
|
||||||
$this->finished = false;
|
$this->finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the next batch of subscribers or `false` no more!
|
* Gets the next batch of subscribers or `false` if no more!
|
||||||
*/
|
*/
|
||||||
public function get() {
|
public function get() {
|
||||||
if($this->finished) {
|
if($this->finished) {
|
||||||
|
@ -5,6 +5,7 @@ use MailPoet\Models\CustomField;
|
|||||||
use MailPoet\Models\Segment;
|
use MailPoet\Models\Segment;
|
||||||
use MailPoet\Premium\Models\DynamicSegment;
|
use MailPoet\Premium\Models\DynamicSegment;
|
||||||
use MailPoet\Util\Helpers;
|
use MailPoet\Util\Helpers;
|
||||||
|
use MailPoet\WP\Hooks;
|
||||||
|
|
||||||
class ImportExportFactory {
|
class ImportExportFactory {
|
||||||
const IMPORT_ACTION = 'import';
|
const IMPORT_ACTION = 'import';
|
||||||
@ -20,9 +21,11 @@ class ImportExportFactory {
|
|||||||
$segments = ($this->action === self::IMPORT_ACTION) ?
|
$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 = Hooks::applyFilters('mailpoet_segments_with_subscriber_count', $segments);
|
||||||
$segments = array_merge($segments, DynamicSegment::getSegmentsForExport());
|
$segments = array_values(array_filter($segments, function($segment) {
|
||||||
}
|
return $segment['subscribers'] > 0;
|
||||||
|
}));
|
||||||
|
|
||||||
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;
|
||||||
|
@ -160,7 +160,4 @@ class Helpers {
|
|||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function isPremiumActive() {
|
|
||||||
return is_plugin_active('mailpoet-premium/mailpoet-premium.php');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user