Move WPHooks methods to WPFunctions
This commit is contained in:
@ -4,7 +4,7 @@ namespace MailPoet\Subscribers\ImportExport\Export;
|
||||
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\WP\Hooks;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
/**
|
||||
* Gets batches of subscribers from dynamic segments.
|
||||
@ -13,6 +13,16 @@ class DynamicSubscribersGetter extends SubscribersGetter {
|
||||
|
||||
protected $segment_index = 0;
|
||||
|
||||
private $wp;
|
||||
|
||||
function __construct($segments_ids, $batch_size, WPFunctions $wp = null) {
|
||||
parent::__construct($segments_ids, $batch_size);
|
||||
if($wp == null) {
|
||||
$wp = new WPFunctions;
|
||||
}
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
public function reset() {
|
||||
parent::reset();
|
||||
$this->segment_index = 0;
|
||||
@ -21,7 +31,7 @@ class DynamicSubscribersGetter extends SubscribersGetter {
|
||||
protected function filter($subscribers) {
|
||||
$segment_id = $this->segments_ids[$this->segment_index];
|
||||
|
||||
$filters = Hooks::applyFilters(
|
||||
$filters = $this->wp->applyFilters(
|
||||
'mailpoet_get_segment_filters',
|
||||
$segment_id
|
||||
);
|
||||
|
@ -5,7 +5,7 @@ use MailPoet\Models\CustomField;
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\Premium\Models\DynamicSegment;
|
||||
use MailPoet\Util\Helpers;
|
||||
use MailPoet\WP\Hooks;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class ImportExportFactory {
|
||||
const IMPORT_ACTION = 'import';
|
||||
@ -13,8 +13,11 @@ class ImportExportFactory {
|
||||
|
||||
public $action;
|
||||
|
||||
private $wp;
|
||||
|
||||
function __construct($action = null) {
|
||||
$this->action = $action;
|
||||
$this->wp = new WPFunctions;
|
||||
}
|
||||
|
||||
function getSegments() {
|
||||
@ -22,7 +25,7 @@ class ImportExportFactory {
|
||||
$segments = Segment::getSegmentsForImport();
|
||||
} else {
|
||||
$segments = Segment::getSegmentsForExport();
|
||||
$segments = Hooks::applyFilters('mailpoet_segments_with_subscriber_count', $segments);
|
||||
$segments = $this->wp->applyFilters('mailpoet_segments_with_subscriber_count', $segments);
|
||||
$segments = array_values(array_filter($segments, function($segment) {
|
||||
return $segment['subscribers'] > 0;
|
||||
}));
|
||||
|
Reference in New Issue
Block a user