Use PHP 7.4 featers and PHP 8 polyfills
This commit is contained in:
@ -78,9 +78,9 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @var array
|
||||
*/
|
||||
protected $supported_panels = array(
|
||||
protected $supported_panels = [
|
||||
'network_admin_menu' => 'wu_edit_emails',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Initializes the class
|
||||
@ -88,14 +88,14 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
public function init(): void {
|
||||
|
||||
/**
|
||||
* Runs the parent init functions
|
||||
*/
|
||||
parent::init();
|
||||
|
||||
add_action('wu_page_edit_redirect_handlers', array($this, 'handle_page_redirect'), 10);
|
||||
add_action('wu_page_edit_redirect_handlers', [$this, 'handle_page_redirect'], 10);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,11 +104,11 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts() {
|
||||
public function register_scripts(): void {
|
||||
|
||||
parent::register_scripts();
|
||||
|
||||
wp_enqueue_script('wu-email-edit-page', wu_get_asset('email-edit-page.js', 'js'), array('jquery', 'clipboard'));
|
||||
wp_enqueue_script('wu-email-edit-page', wu_get_asset('email-edit-page.js', 'js'), ['jquery', 'clipboard']);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +117,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 1.8.2
|
||||
* @return void
|
||||
*/
|
||||
public function register_widgets() {
|
||||
public function register_widgets(): void {
|
||||
|
||||
parent::register_widgets();
|
||||
|
||||
@ -138,224 +138,224 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
$this->add_save_widget(
|
||||
'save',
|
||||
array(
|
||||
'html_attr' => array(
|
||||
[
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'email_edit_save',
|
||||
'data-state' => wu_convert_to_state(
|
||||
array(
|
||||
[
|
||||
'slug' => $this->edit ? $object->get_slug() : '',
|
||||
'target' => $this->edit ? $object->get_target() : 'admin',
|
||||
'schedule' => $this->edit ? $object->has_schedule() : false,
|
||||
'schedule_type' => $this->edit ? $object->get_schedule_type() : 'days',
|
||||
'days' => $this->edit ? $object->get_send_days() : 1,
|
||||
'hours' => $this->edit ? $object->get_send_hours() : '12:00',
|
||||
)
|
||||
]
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'slug' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'slug' => [
|
||||
'type' => 'text',
|
||||
'title' => __('Slug', 'wp-ultimo'),
|
||||
'desc' => __('An unique identifier for this system email.', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $object->get_slug() : '',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'required' => 'required',
|
||||
'v-on:input' => 'slug = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")',
|
||||
'v-bind:value' => 'slug',
|
||||
),
|
||||
),
|
||||
'event' => array(
|
||||
],
|
||||
],
|
||||
'event' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Event', 'wp-ultimo'),
|
||||
'desc' => __('The event that will trigger the sending of this email.', 'wp-ultimo'),
|
||||
'placeholder' => __('Event', 'wp-ultimo'),
|
||||
'options' => 'wu_get_event_types_as_options',
|
||||
'value' => $this->edit ? $object->get_event() : 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'name' => '',
|
||||
),
|
||||
),
|
||||
'target' => array(
|
||||
],
|
||||
],
|
||||
'target' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Target', 'wp-ultimo'),
|
||||
'desc' => __('To whom this email should be sent.', 'wp-ultimo'),
|
||||
'placeholder' => __('Network Administrators', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $object->get_target() : 'admin',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'admin' => __('Network Administrators', 'wp-ultimo'),
|
||||
'customer' => __('Customer', 'wp-ultimo'),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'target',
|
||||
),
|
||||
),
|
||||
'send_copy_to_admin' => array(
|
||||
],
|
||||
],
|
||||
'send_copy_to_admin' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Send Copy to Admins?', 'wp-ultimo'),
|
||||
'desc' => __('Checking this options will add the network admins as bcc every time this email is sent to a customer.', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $object->get_send_copy_to_admin() : false,
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'target == "customer"',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'schedule' => array(
|
||||
],
|
||||
],
|
||||
'schedule' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Schedule?', 'wp-ultimo'),
|
||||
'desc' => __('You can define when the email is sent after the event triggers.', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $this->get_object()->has_schedule() : 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'schedule',
|
||||
),
|
||||
),
|
||||
'send_date' => array(
|
||||
],
|
||||
],
|
||||
'send_date' => [
|
||||
'type' => 'group',
|
||||
'title' => __('Scheduling Options', 'wp-ultimo'),
|
||||
'tooltip' => __('When this email will be sent after the event?', 'wp-ultimo'),
|
||||
'desc' => $desc,
|
||||
'desc_id' => 'send_date_desc',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'schedule',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
'fields' => array(
|
||||
'schedule_type' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'schedule_type' => [
|
||||
'type' => 'select',
|
||||
'default' => 'days',
|
||||
'wrapper_classes' => 'wu-w-2/3',
|
||||
'value' => $this->edit ? $object->get_schedule_type() : 'days',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'hours' => __('Delay for hours', 'wp-ultimo'),
|
||||
'days' => __('Delay for days', 'wp-ultimo'),
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'schedule_type',
|
||||
),
|
||||
),
|
||||
'send_days' => array(
|
||||
],
|
||||
],
|
||||
'send_days' => [
|
||||
'type' => 'number',
|
||||
'value' => $this->edit && $object->get_send_days() ? $object->get_send_days() : 1,
|
||||
'placeholder' => 1,
|
||||
'min' => 0,
|
||||
'wrapper_classes' => 'wu-ml-2 wu-w-1/3',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "schedule_type == 'days'",
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
'html_attr' => array(
|
||||
],
|
||||
'html_attr' => [
|
||||
'v-model' => 'days',
|
||||
),
|
||||
),
|
||||
'send_hours' => array(
|
||||
],
|
||||
],
|
||||
'send_hours' => [
|
||||
'type' => 'text',
|
||||
'date' => true,
|
||||
'placeholder' => $this->edit ? $object->get_send_hours() : '12:00',
|
||||
'value' => $this->edit ? $object->get_send_hours() : '',
|
||||
'wrapper_classes' => 'wu-ml-2 wu-w-1/3',
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'data-no-calendar' => 'true',
|
||||
'wu-datepicker' => 'true',
|
||||
'data-format' => 'H:i',
|
||||
'data-allow-time' => 'true',
|
||||
'v-model' => 'hours',
|
||||
),
|
||||
'wrapper_html_attr' => array(
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => "schedule_type == 'hours'",
|
||||
'v-cloak' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
),
|
||||
)
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
add_meta_box('wp-ultimo-placeholders', __('Placeholders', 'wp-ultimo'), array($this, 'output_default_widget_placeholders'), get_current_screen()->id, 'normal', null, array());
|
||||
add_meta_box('wp-ultimo-placeholders', __('Placeholders', 'wp-ultimo'), [$this, 'output_default_widget_placeholders'], get_current_screen()->id, 'normal', null, []);
|
||||
|
||||
$this->add_fields_widget(
|
||||
'active',
|
||||
array(
|
||||
[
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'active' => array(
|
||||
'fields' => [
|
||||
'active' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'desc' => __('Use this option to manually enable or disable this email.', 'wp-ultimo'),
|
||||
'value' => $this->get_object()->is_active(),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->add_tabs_widget(
|
||||
'email_edit_options',
|
||||
array(
|
||||
[
|
||||
'title' => __('Advanced Options', 'wp-ultimo'),
|
||||
'position' => 'normal',
|
||||
'sections' => array(
|
||||
'general' => array(
|
||||
'sections' => [
|
||||
'general' => [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-lock',
|
||||
'desc' => __('Rules and limitations to the applicability of this discount code.', 'wp-ultimo'),
|
||||
'state' => array(
|
||||
'state' => [
|
||||
'sender' => $this->edit ? $object->get_custom_sender() : 0,
|
||||
),
|
||||
'fields' => array(
|
||||
'style' => array(
|
||||
],
|
||||
'fields' => [
|
||||
'style' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Email Style', 'wp-ultimo'),
|
||||
'desc' => __('Choose if email body will be sent using the HTML template or in plain text.', 'wp-ultimo'),
|
||||
'placeholder' => __('Style', 'wp-ultimo'),
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'default' => __('Use Default', 'wp-ultimo'),
|
||||
'html' => __('HTML Emails', 'wp-ultimo'),
|
||||
'plain' => __('Plain Emails', 'wp-ultimo'),
|
||||
),
|
||||
],
|
||||
'value' => $this->edit ? $object->get_style() : 'html',
|
||||
),
|
||||
),
|
||||
),
|
||||
'sender' => array(
|
||||
],
|
||||
],
|
||||
],
|
||||
'sender' => [
|
||||
'title' => __('Custom Sender', 'wp-ultimo'),
|
||||
'icon' => 'dashicons-wu-mail',
|
||||
'desc' => __('You can define an email and a name that will only be used when this email is sent.', 'wp-ultimo'),
|
||||
'fields' => array(
|
||||
'custom_sender' => array(
|
||||
'fields' => [
|
||||
'custom_sender' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Use a custom sender?', 'wp-ultimo'),
|
||||
'desc' => __('You can define an email and a name that will only be used when this email is sent.', 'wp-ultimo'),
|
||||
'value' => $this->edit ? $object->get_custom_sender() : 0,
|
||||
'html_attr' => array(
|
||||
'html_attr' => [
|
||||
'v-model' => 'sender',
|
||||
),
|
||||
),
|
||||
'custom_sender_name' => array(
|
||||
],
|
||||
],
|
||||
'custom_sender_name' => [
|
||||
'type' => 'text',
|
||||
'title' => __('From "Name"', 'wp-ultimo'),
|
||||
'desc' => __('Override the global from name for this particular email.', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-full',
|
||||
'value' => $this->edit ? $object->get_custom_sender_name() : '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'sender',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
'custom_sender_email' => array(
|
||||
],
|
||||
],
|
||||
'custom_sender_email' => [
|
||||
'type' => 'email',
|
||||
'title' => __('From "Email"', 'wp-ultimo'),
|
||||
'desc' => __('Override the global from email for this particular email.', 'wp-ultimo'),
|
||||
'wrapper_classes' => 'wu-full',
|
||||
'value' => $this->edit ? $object->get_custom_sender_email() : '',
|
||||
'wrapper_html_attr' => array(
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => 'sender',
|
||||
'v-cloak' => 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -368,14 +368,14 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @param array $data Arguments passed by add_meta_box.
|
||||
* @return void
|
||||
*/
|
||||
public function output_default_widget_placeholders($unused, $data) {
|
||||
public function output_default_widget_placeholders($unused, $data): void {
|
||||
|
||||
wu_get_template(
|
||||
'email/widget-placeholders',
|
||||
array(
|
||||
[
|
||||
'title' => __('Event Payload', 'wp-ultimo'),
|
||||
'loading_text' => __('Loading Payload', 'wp-ultimo'),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@ -409,27 +409,27 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function action_links() {
|
||||
|
||||
$url_atts = array(
|
||||
$url_atts = [
|
||||
'id' => $this->get_object()->get_id(),
|
||||
'model' => 'email',
|
||||
'page' => 'edit',
|
||||
);
|
||||
];
|
||||
|
||||
$send_test_link = wu_get_form_url('send_new_test', $url_atts);
|
||||
|
||||
return array(
|
||||
array(
|
||||
return [
|
||||
[
|
||||
'url' => wu_network_admin_url('wp-ultimo-emails'),
|
||||
'label' => __('Go Back', 'wp-ultimo'),
|
||||
'icon' => 'wu-reply',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'url' => $send_test_link,
|
||||
'label' => __('Send Test Email', 'wp-ultimo'),
|
||||
'icon' => 'wu-mail',
|
||||
'classes' => 'wubox',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -440,7 +440,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_labels() {
|
||||
|
||||
return array(
|
||||
return [
|
||||
'edit_label' => __('Edit Email', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add new Email', 'wp-ultimo'),
|
||||
'updated_message' => __('Email updated with success!', 'wp-ultimo'),
|
||||
@ -450,7 +450,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Email', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -463,10 +463,10 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'system_email',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
@ -477,7 +477,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function handle_save() {
|
||||
public function handle_save(): void {
|
||||
|
||||
$_POST['schedule'] = wu_request('schedule');
|
||||
|
||||
@ -491,10 +491,10 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
/**
|
||||
* Handles the redirect notice from sent new test modal.
|
||||
*
|
||||
* @param WP_Ultimo\Admin_Pages\Base_Admin_Page $page The page object.
|
||||
* @param Base_Admin_Page $page The page object.
|
||||
* @return void
|
||||
*/
|
||||
public function handle_page_redirect($page) {
|
||||
public function handle_page_redirect($page): void {
|
||||
|
||||
if ($page->get_id() === 'wp-ultimo-edit-email') {
|
||||
if (wu_request('test_notice')) {
|
||||
@ -567,10 +567,10 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function events_query_filter($args) {
|
||||
|
||||
$extra_args = array(
|
||||
$extra_args = [
|
||||
'object_type' => 'email',
|
||||
'object_id' => absint($this->get_object()->get_id()),
|
||||
);
|
||||
];
|
||||
|
||||
return array_merge($args, $extra_args);
|
||||
}
|
||||
|
Reference in New Issue
Block a user