Refactor code
[MAILPOET-3037]
This commit is contained in:
@ -97,7 +97,7 @@ class Forms extends APIEndpoint {
|
|||||||
return $this->successResponse($this->formsResponseBuilder->build($form));
|
return $this->successResponse($this->formsResponseBuilder->build($form));
|
||||||
}
|
}
|
||||||
return $this->errorResponse([
|
return $this->errorResponse([
|
||||||
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet'),
|
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,16 +186,16 @@ class Forms extends APIEndpoint {
|
|||||||
|
|
||||||
public function saveEditor($data = []) {
|
public function saveEditor($data = []) {
|
||||||
$formId = (isset($data['id']) ? (int)$data['id'] : 0);
|
$formId = (isset($data['id']) ? (int)$data['id'] : 0);
|
||||||
$name = (isset($data['name']) ? $data['name'] : WPFunctions::get()->__('New form', 'mailpoet'));
|
$name = ($data['name'] ?? __('New form', 'mailpoet'));
|
||||||
$body = (isset($data['body']) ? $data['body'] : []);
|
$body = ($data['body'] ?? []);
|
||||||
$body = $this->dataSanitizer->sanitizeBody($body);
|
$body = $this->dataSanitizer->sanitizeBody($body);
|
||||||
$settings = (isset($data['settings']) ? $data['settings'] : []);
|
$settings = ($data['settings'] ?? []);
|
||||||
$styles = (isset($data['styles']) ? $data['styles'] : '');
|
$styles = ($data['styles'] ?? '');
|
||||||
$status = (isset($data['status']) ? $data['status'] : FormEntity::STATUS_ENABLED);
|
$status = ($data['status'] ?? FormEntity::STATUS_ENABLED);
|
||||||
|
|
||||||
// check if the form is used as a widget
|
// check if the form is used as a widget
|
||||||
$isWidget = false;
|
$isWidget = false;
|
||||||
$widgets = WPFunctions::get()->getOption('widget_mailpoet_form');
|
$widgets = $this->wp->getOption('widget_mailpoet_form');
|
||||||
if (!empty($widgets)) {
|
if (!empty($widgets)) {
|
||||||
foreach ($widgets as $widget) {
|
foreach ($widgets as $widget) {
|
||||||
if (isset($widget['form']) && (int)$widget['form'] === $formId) {
|
if (isset($widget['form']) && (int)$widget['form'] === $formId) {
|
||||||
@ -271,7 +271,7 @@ class Forms extends APIEndpoint {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return $this->errorResponse([
|
return $this->errorResponse([
|
||||||
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet'),
|
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,7 +287,7 @@ class Forms extends APIEndpoint {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return $this->errorResponse([
|
return $this->errorResponse([
|
||||||
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet'),
|
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ class Forms extends APIEndpoint {
|
|||||||
return $this->successResponse(null, ['count' => 1]);
|
return $this->successResponse(null, ['count' => 1]);
|
||||||
} else {
|
} else {
|
||||||
return $this->errorResponse([
|
return $this->errorResponse([
|
||||||
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet'),
|
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ class Forms extends APIEndpoint {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return $this->errorResponse([
|
return $this->errorResponse([
|
||||||
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet'),
|
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user