Replace all WP function calls

This commit is contained in:
Amine Ben hammou
2019-02-20 18:56:48 +01:00
committed by M. Shull
parent 986482e34b
commit 0a436087e1
176 changed files with 1066 additions and 803 deletions

View File

@ -10,6 +10,7 @@ use MailPoet\Form\Util;
use MailPoet\Listing;
use MailPoet\Models\Form;
use MailPoet\Models\StatisticsForms;
use MailPoet\WP\Functions as WPFunctions;
if (!defined('ABSPATH')) exit;
@ -38,7 +39,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if ($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet')
));
} else {
return $this->successResponse($form->asArray());
@ -73,31 +74,31 @@ class Forms extends APIEndpoint {
function create() {
// create new form
$form_data = array(
'name' => __('New form', 'mailpoet'),
'name' => WPFunctions::get()->__('New form', 'mailpoet'),
'body' => array(
array(
'id' => 'email',
'name' => __('Email', 'mailpoet'),
'name' => WPFunctions::get()->__('Email', 'mailpoet'),
'type' => 'text',
'static' => true,
'params' => array(
'label' => __('Email', 'mailpoet'),
'label' => WPFunctions::get()->__('Email', 'mailpoet'),
'required' => true
)
),
array(
'id' => 'submit',
'name' => __('Submit', 'mailpoet'),
'name' => WPFunctions::get()->__('Submit', 'mailpoet'),
'type' => 'submit',
'static' => true,
'params' => array(
'label' => __('Subscribe!', 'mailpoet')
'label' => WPFunctions::get()->__('Subscribe!', 'mailpoet')
)
)
),
'settings' => array(
'on_success' => 'message',
'success_message' => __('Check your inbox or spam folder to confirm your subscription.', 'mailpoet'),
'success_message' => WPFunctions::get()->__('Check your inbox or spam folder to confirm your subscription.', 'mailpoet'),
'segments' => null,
'segments_selected_by' => 'admin'
)
@ -124,7 +125,7 @@ class Forms extends APIEndpoint {
$html = FormRenderer::renderHTML($data);
// convert shortcodes
$html = do_shortcode($html);
$html = WPFunctions::get()->doShortcode($html);
// styles
$css = new Util\Styles(FormRenderer::getStyles($data));
@ -140,7 +141,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if ($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet')
));
} else {
$exports = Util\Export::getAll($form->asArray());
@ -152,14 +153,14 @@ class Forms extends APIEndpoint {
$id = (isset($data['id']) ? (int)$data['id'] : false);
$form_id = (isset($data['id']) ? (int)$data['id'] : 0);
$name = (isset($data['name']) ? $data['name'] : __('New form', 'mailpoet'));
$name = (isset($data['name']) ? $data['name'] : WPFunctions::get()->__('New form', 'mailpoet'));
$body = (isset($data['body']) ? $data['body'] : array());
$settings = (isset($data['settings']) ? $data['settings'] : array());
$styles = (isset($data['styles']) ? $data['styles'] : '');
// check if the form is used as a widget
$is_widget = false;
$widgets = get_option('widget_mailpoet_form');
$widgets = WPFunctions::get()->getOption('widget_mailpoet_form');
if (!empty($widgets)) {
foreach ($widgets as $widget) {
if (isset($widget['form']) && (int)$widget['form'] === $form_id) {
@ -223,7 +224,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if ($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet')
));
} else {
$form->restore();
@ -239,7 +240,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if ($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet')
));
} else {
$form->trash();
@ -255,7 +256,7 @@ class Forms extends APIEndpoint {
$form = Form::findOne($id);
if ($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet')
));
} else {
$form->delete();
@ -269,7 +270,7 @@ class Forms extends APIEndpoint {
if ($form === false) {
return $this->errorResponse(array(
APIError::NOT_FOUND => __('This form does not exist.', 'mailpoet')
APIError::NOT_FOUND => WPFunctions::get()->__('This form does not exist.', 'mailpoet')
));
} else {
$data = array(