Use short array syntax

[MAILPOET-2090]
This commit is contained in:
Pavel Dohnal
2019-05-20 13:48:48 +02:00
committed by M. Shull
parent 9f16cb6a5f
commit 5da7110eb6
385 changed files with 40133 additions and 40131 deletions

View File

@@ -13,9 +13,9 @@ class AutomatedLatestContent extends APIEndpoint {
/** @var \MailPoet\Newsletter\AutomatedLatestContent */
public $ALC;
private $wp;
public $permissions = array(
'global' => AccessControl::PERMISSION_MANAGE_EMAILS
);
public $permissions = [
'global' => AccessControl::PERMISSION_MANAGE_EMAILS,
];
function __construct(\MailPoet\Newsletter\AutomatedLatestContent $alc, WPFunctions $wp) {
$this->ALC = $alc;
@@ -24,17 +24,17 @@ class AutomatedLatestContent extends APIEndpoint {
function getPostTypes() {
$post_types = array_map(function($post_type) {
return array(
return [
'name' => $post_type->name,
'label' => $post_type->label
);
}, WPPosts::getTypes(array(), 'objects'));
'label' => $post_type->label,
];
}, WPPosts::getTypes([], 'objects'));
return $this->successResponse(
array_filter($post_types)
);
}
function getTaxonomies($data = array()) {
function getTaxonomies($data = []) {
$post_type = (isset($data['postType'])) ? $data['postType'] : 'post';
$all_taxonomies = WPFunctions::get()->getObjectTaxonomies($post_type, 'objects');
$taxonomies_with_label = array_filter($all_taxonomies, function($taxonomy) {
@@ -43,20 +43,20 @@ class AutomatedLatestContent extends APIEndpoint {
return $this->successResponse($taxonomies_with_label);
}
function getTerms($data = array()) {
$taxonomies = (isset($data['taxonomies'])) ? $data['taxonomies'] : array();
function getTerms($data = []) {
$taxonomies = (isset($data['taxonomies'])) ? $data['taxonomies'] : [];
$search = (isset($data['search'])) ? $data['search'] : '';
$limit = (isset($data['limit'])) ? (int)$data['limit'] : 100;
$page = (isset($data['page'])) ? (int)$data['page'] : 1;
$args = array(
$args = [
'taxonomy' => $taxonomies,
'hide_empty' => false,
'search' => $search,
'number' => $limit,
'offset' => $limit * ($page - 1),
'orderby' => 'name',
'order' => 'ASC'
);
'order' => 'ASC',
];
$args = $this->wp->applyFilters('mailpoet_search_terms_args', $args);
$terms = WPPosts::getTerms($args);
@@ -64,22 +64,22 @@ class AutomatedLatestContent extends APIEndpoint {
return $this->successResponse(array_values($terms));
}
function getPosts($data = array()) {
function getPosts($data = []) {
return $this->successResponse(
$this->ALC->getPosts($data)
);
}
function getTransformedPosts($data = array()) {
function getTransformedPosts($data = []) {
$posts = $this->ALC->getPosts($data);
return $this->successResponse(
$this->ALC->transformPosts($data, $posts)
);
}
function getBulkTransformedPosts($data = array()) {
$used_posts = array();
$rendered_posts = array();
function getBulkTransformedPosts($data = []) {
$used_posts = [];
$rendered_posts = [];
foreach ($data['blocks'] as $block) {
$posts = $this->ALC->getPosts($block, $used_posts);