using apply_filters
This commit is contained in:
@ -9,7 +9,6 @@ use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Setting;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Settings\Pages;
|
||||
use MailPoet\Util\Helpers;
|
||||
|
||||
class Reporter {
|
||||
|
||||
@ -53,7 +52,7 @@ class Reporter {
|
||||
'Number of active welcome emails' => $newsletters['welcome_newsletters_count'],
|
||||
'Number of segments' => isset($segments['dynamic']) ? (int)$segments['dynamic'] : 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 > Bloom' => is_plugin_active('bloom-for-publishers/bloom.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->segments_ids = $this->filterSegmentIds($segments_ids);
|
||||
$this->batch_size = $batch_size;
|
||||
$this->offset = 0;
|
||||
$this->finished = false;
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
protected function filterSegmentIds($ids) {
|
||||
@ -39,17 +38,13 @@ class DefaultSubscribersGetter {
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the `offset` and `finished` properties;
|
||||
* to be able to start getting subscribers again.
|
||||
*/
|
||||
public function reset() {
|
||||
$this->offset = 0;
|
||||
$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() {
|
||||
if($this->finished) {
|
||||
|
@ -5,6 +5,7 @@ use MailPoet\Models\CustomField;
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\Premium\Models\DynamicSegment;
|
||||
use MailPoet\Util\Helpers;
|
||||
use MailPoet\WP\Hooks;
|
||||
|
||||
class ImportExportFactory {
|
||||
const IMPORT_ACTION = 'import';
|
||||
@ -20,9 +21,11 @@ class ImportExportFactory {
|
||||
$segments = ($this->action === self::IMPORT_ACTION) ?
|
||||
Segment::getSegmentsForImport() :
|
||||
Segment::getSegmentsForExport($with_confirmed_subscribers);
|
||||
if(Helpers::isPremiumActive() && $this->action === self::EXPORT_ACTION) {
|
||||
$segments = array_merge($segments, DynamicSegment::getSegmentsForExport());
|
||||
}
|
||||
$segments = Hooks::applyFilters('mailpoet_segments_with_subscriber_count', $segments);
|
||||
$segments = array_values(array_filter($segments, function($segment) {
|
||||
return $segment['subscribers'] > 0;
|
||||
}));
|
||||
|
||||
return array_map(function($segment) {
|
||||
if(!$segment['name']) $segment['name'] = __('Not In List', 'mailpoet');
|
||||
if(!$segment['id']) $segment['id'] = 0;
|
||||
|
@ -160,7 +160,4 @@ class Helpers {
|
||||
: null;
|
||||
}
|
||||
|
||||
static function isPremiumActive() {
|
||||
return is_plugin_active('mailpoet-premium/mailpoet-premium.php');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user