Move WPHooks methods to WPFunctions
This commit is contained in:
@ -4,14 +4,16 @@ namespace MailPoet\Segments;
|
||||
|
||||
use MailPoet\Listing\Handler;
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\WP\Hooks;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class BulkAction {
|
||||
|
||||
private $data = null;
|
||||
private $wp;
|
||||
|
||||
function __construct($data) {
|
||||
$this->data = $data;
|
||||
$this->wp = new WPFunctions;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,7 +44,7 @@ class BulkAction {
|
||||
$bulk_action = new \MailPoet\Listing\BulkActionController(new Handler());
|
||||
return $bulk_action->apply('\MailPoet\Models\Subscriber', $this->data);
|
||||
} else {
|
||||
$handlers = Hooks::applyFilters('mailpoet_subscribers_in_segment_apply_bulk_action_handlers', array());
|
||||
$handlers = $this->wp->applyFilters('mailpoet_subscribers_in_segment_apply_bulk_action_handlers', array());
|
||||
foreach($handlers as $handler) {
|
||||
$meta = $handler->apply($segment, $this->data);
|
||||
if($meta) {
|
||||
|
@ -6,11 +6,17 @@ use MailPoet\Models\ScheduledTask;
|
||||
use MailPoet\Models\ScheduledTaskSubscriber;
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use MailPoet\WP\Hooks;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use function MailPoet\Util\array_column;
|
||||
|
||||
class SubscribersFinder {
|
||||
|
||||
private $wp;
|
||||
|
||||
function __construct() {
|
||||
$this->wp = new WPFunctions;
|
||||
}
|
||||
|
||||
function findSubscribersInSegments($subscribers_to_process_ids, $newsletter_segments_ids) {
|
||||
$result = array();
|
||||
foreach($newsletter_segments_ids as $segment_id) {
|
||||
@ -25,7 +31,7 @@ class SubscribersFinder {
|
||||
$subscribers = Subscriber::findSubscribersInSegments($subscribers_to_process_ids, array($segment->id))->findMany();
|
||||
return Subscriber::extractSubscribersIds($subscribers);
|
||||
}
|
||||
$finders = Hooks::applyFilters('mailpoet_get_subscribers_in_segment_finders', array());
|
||||
$finders = $this->wp->applyFilters('mailpoet_get_subscribers_in_segment_finders', array());
|
||||
foreach($finders as $finder) {
|
||||
$subscribers = $finder->findSubscribersInSegment($segment, $subscribers_to_process_ids);
|
||||
if($subscribers) {
|
||||
@ -93,7 +99,7 @@ class SubscribersFinder {
|
||||
}
|
||||
|
||||
private function addSubscribersToTaskFromDynamicSegment(ScheduledTask $task, Segment $segment) {
|
||||
$finders = Hooks::applyFilters('mailpoet_get_subscribers_in_segment_finders', array());
|
||||
$finders = $this->wp->applyFilters('mailpoet_get_subscribers_in_segment_finders', array());
|
||||
$count = 0;
|
||||
foreach($finders as $finder) {
|
||||
$subscribers = $finder->getSubscriberIdsInSegment($segment);
|
||||
|
@ -4,15 +4,18 @@ namespace MailPoet\Segments;
|
||||
|
||||
use MailPoet\Listing\Handler;
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\WP\Hooks;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
|
||||
class SubscribersListings {
|
||||
|
||||
/** @var Handler */
|
||||
private $handler;
|
||||
|
||||
function __construct(Handler $handler) {
|
||||
private $wp;
|
||||
|
||||
function __construct(Handler $handler, WPFunctions $wp) {
|
||||
$this->handler = $handler;
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
function getListingsInSegment($data) {
|
||||
@ -30,7 +33,7 @@ class SubscribersListings {
|
||||
) {
|
||||
return $listing_data = $this->handler->get('\MailPoet\Models\Subscriber', $data);
|
||||
}
|
||||
$handlers = Hooks::applyFilters('mailpoet_get_subscribers_listings_in_segment_handlers', array());
|
||||
$handlers = $this->wp->applyFilters('mailpoet_get_subscribers_listings_in_segment_handlers', array());
|
||||
foreach($handlers as $handler) {
|
||||
$listings = $handler->get($segment, $data);
|
||||
if($listings) {
|
||||
|
Reference in New Issue
Block a user