Revert "Revert "Define BlockPostQuery for nicer args processing for quering""
This reverts commit 62e393a76d
.
This commit is contained in:
@ -5,6 +5,7 @@ namespace MailPoet\API\JSON\v1;
|
||||
use MailPoet\API\JSON\Endpoint as APIEndpoint;
|
||||
use MailPoet\Config\AccessControl;
|
||||
use MailPoet\Newsletter\AutomatedLatestContent as ALC;
|
||||
use MailPoet\Newsletter\BlockPostQuery;
|
||||
use MailPoet\Util\APIPermissionHelper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoet\WP\Posts as WPPosts;
|
||||
@ -87,12 +88,12 @@ class AutomatedLatestContent extends APIEndpoint {
|
||||
|
||||
public function getPosts($data = []) {
|
||||
return $this->successResponse(
|
||||
$this->getPermittedPosts($this->ALC->getPosts($data))
|
||||
$this->getPermittedPosts($this->ALC->getPosts(new BlockPostQuery(['args' => $data])))
|
||||
);
|
||||
}
|
||||
|
||||
public function getTransformedPosts($data = []) {
|
||||
$posts = $this->getPermittedPosts($this->ALC->getPosts($data));
|
||||
$posts = $this->getPermittedPosts($this->ALC->getPosts(new BlockPostQuery(['args' => $data])));
|
||||
return $this->successResponse(
|
||||
$this->ALC->transformPosts($data, $posts)
|
||||
);
|
||||
@ -103,7 +104,8 @@ class AutomatedLatestContent extends APIEndpoint {
|
||||
$renderedPosts = [];
|
||||
|
||||
foreach ($data['blocks'] as $block) {
|
||||
$posts = $this->getPermittedPosts($this->ALC->getPosts($block, $usedPosts));
|
||||
$query = new BlockPostQuery(['args' => $block, 'postsToExclude' => $usedPosts]);
|
||||
$posts = $this->getPermittedPosts($this->ALC->getPosts($query));
|
||||
$renderedPosts[] = $this->ALC->transformPosts($block, $posts);
|
||||
|
||||
foreach ($posts as $post) {
|
||||
|
Reference in New Issue
Block a user