Prep Plugin for release on WordPress.org (#23)
* Update translation text domain * Escape everything that should be escaped. * Add nonce checks where needed. * Sanitize all inputs. * Apply Code style changes across the codebase. * Correct many deprecation notices. * Optimize load order of many filters. * Add Proper Build script * Use emojii flags * Fix i18n deprecation notice for translating too early * Put all scripts in footer and load async
This commit is contained in:
@ -94,6 +94,26 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
|
||||
add_action('wu_after_delete_domain_modal', [$this, 'domain_after_delete_actions']);
|
||||
}
|
||||
/**
|
||||
* Registers the necessary scripts and styles for this admin page.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts(): void {
|
||||
parent::register_scripts();
|
||||
|
||||
wp_enqueue_script(
|
||||
'wu-dns-table',
|
||||
wu_get_asset('dns-table.js', 'js'),
|
||||
['jquery', 'wu-vue'],
|
||||
\WP_Ultimo::VERSION,
|
||||
[
|
||||
'async' => true,
|
||||
'in_footer' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the extra delete fields to the delete form.
|
||||
@ -119,15 +139,15 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
$custom_fields = [
|
||||
'set_domain_as_primary' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Set another domain as primary', 'wp-ultimo'),
|
||||
'title' => __('Set another domain as primary', 'wp-multisite-waas'),
|
||||
'html_attr' => [
|
||||
'data-model' => 'domain',
|
||||
'data-value-field' => 'id',
|
||||
'data-label-field' => 'domain',
|
||||
'data-search-field' => 'domain',
|
||||
'data-max-items' => 1,
|
||||
'data-exclude' => json_encode([$domain->get_id()]),
|
||||
'data-include' => json_encode($domain->get_blog_id()),
|
||||
'data-exclude' => wp_json_encode([$domain->get_id()]),
|
||||
'data-include' => wp_json_encode($domain->get_blog_id()),
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-if' => $is_primary_domain && $has_other_domains ? 'true' : 'false',
|
||||
@ -135,16 +155,16 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
],
|
||||
'confirm' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Confirm Deletion', 'wp-ultimo'),
|
||||
'desc' => __('This action can not be undone.', 'wp-ultimo'),
|
||||
'title' => __('Confirm Deletion', 'wp-multisite-waas'),
|
||||
'desc' => __('This action can not be undone.', 'wp-multisite-waas'),
|
||||
'html_attr' => [
|
||||
'v-model' => 'confirmed',
|
||||
],
|
||||
],
|
||||
'submit_button' => [
|
||||
'type' => 'submit',
|
||||
'title' => __('Delete', 'wp-ultimo'),
|
||||
'placeholder' => __('Delete', 'wp-ultimo'),
|
||||
'title' => __('Delete', 'wp-multisite-waas'),
|
||||
'placeholder' => __('Delete', 'wp-multisite-waas'),
|
||||
'value' => 'save',
|
||||
'classes' => 'button button-primary wu-w-full',
|
||||
'wrapper_classes' => 'wu-items-end',
|
||||
@ -195,14 +215,14 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
$this->add_fields_widget(
|
||||
'domain-url',
|
||||
[
|
||||
'title' => __('Domain URL', 'wp-ultimo'),
|
||||
'title' => __('Domain URL', 'wp-multisite-waas'),
|
||||
'position' => 'normal',
|
||||
'after' => [$this, 'render_dns_widget'],
|
||||
'fields' => [
|
||||
'domain' => [
|
||||
'type' => 'text-display',
|
||||
'title' => __('Domain', 'wp-ultimo'),
|
||||
'tooltip' => __('Editing an existing domain is not possible. If you want to make changes to this domain, first delete it, and then re-add the right domain.', 'wp-ultimo'),
|
||||
'title' => __('Domain', 'wp-multisite-waas'),
|
||||
'tooltip' => __('Editing an existing domain is not possible. If you want to make changes to this domain, first delete it, and then re-add the right domain.', 'wp-multisite-waas'),
|
||||
'display_value' => '<span class="wu-text-sm wu-uppercase wu-font-mono">' . $this->get_object()->get_domain() . '</span> <a target="_blank" class="wu-no-underline" href="' . esc_url($this->get_object()->get_url()) . '"><span class="dashicons-wu-link1 "></span></a>',
|
||||
],
|
||||
],
|
||||
@ -212,12 +232,12 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
$this->add_tabs_widget(
|
||||
'options',
|
||||
[
|
||||
'title' => __('Domain Options', 'wp-ultimo'),
|
||||
'title' => __('Domain Options', 'wp-multisite-waas'),
|
||||
'position' => 'normal',
|
||||
'sections' => [
|
||||
'general' => [
|
||||
'title' => __('General', 'wp-ultimo'),
|
||||
'desc' => __('General options for the domain.', 'wp-ultimo'),
|
||||
'title' => __('General', 'wp-multisite-waas'),
|
||||
'desc' => __('General options for the domain.', 'wp-multisite-waas'),
|
||||
'icon' => 'dashicons-wu-globe',
|
||||
'state' => [
|
||||
'primary_domain' => $this->get_object()->is_primary_domain(),
|
||||
@ -225,9 +245,9 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'fields' => [
|
||||
'primary_domain' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Is Primary Domain?', 'wp-ultimo'),
|
||||
'desc' => __('Set as the primary domain.', 'wp-ultimo'),
|
||||
'tooltip' => __('Setting this as the primary domain will remove any other domain mapping marked as the primary domain for this site.', 'wp-ultimo'),
|
||||
'title' => __('Is Primary Domain?', 'wp-multisite-waas'),
|
||||
'desc' => __('Set as the primary domain.', 'wp-multisite-waas'),
|
||||
'tooltip' => __('Setting this as the primary domain will remove any other domain mapping marked as the primary domain for this site.', 'wp-multisite-waas'),
|
||||
'value' => $this->get_object()->is_primary_domain(),
|
||||
'html_attr' => [
|
||||
'v-model' => 'primary_domain',
|
||||
@ -235,15 +255,15 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
],
|
||||
'primary_note' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('By making this the primary domain, we will convert the previous primary domain for this site, if one exists, into an alias domain.', 'wp-ultimo'),
|
||||
'desc' => __('By making this the primary domain, we will convert the previous primary domain for this site, if one exists, into an alias domain.', 'wp-multisite-waas'),
|
||||
'wrapper_html_attr' => [
|
||||
'v-if' => "require('primary_domain', true)",
|
||||
],
|
||||
],
|
||||
'secure' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Is Secure?', 'wp-ultimo'),
|
||||
'desc' => __('Force the load using HTTPS.', 'wp-ultimo'),
|
||||
'title' => __('Is Secure?', 'wp-multisite-waas'),
|
||||
'desc' => __('Force the load using HTTPS.', 'wp-multisite-waas'),
|
||||
'value' => $this->get_object()->is_secure(),
|
||||
],
|
||||
],
|
||||
@ -255,18 +275,18 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
$this->add_list_table_widget(
|
||||
'sites',
|
||||
[
|
||||
'title' => __('Linked Site', 'wp-ultimo'),
|
||||
'title' => __('Linked Site', 'wp-multisite-waas'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Memberships_Site_List_Table(),
|
||||
'query_filter' => [$this, 'sites_query_filter'],
|
||||
]
|
||||
);
|
||||
|
||||
add_meta_box('wp-ultimo-domain-log', __('Domain Test Log', 'wp-ultimo'), [$this, 'render_log_widget'], get_current_screen()->id, 'normal', null);
|
||||
add_meta_box('wp-ultimo-domain-log', __('Domain Test Log', 'wp-multisite-waas'), [$this, 'render_log_widget'], get_current_screen()->id, 'normal', null);
|
||||
|
||||
$this->add_list_table_widget(
|
||||
'events',
|
||||
[
|
||||
'title' => __('Events', 'wp-ultimo'),
|
||||
'title' => __('Events', 'wp-multisite-waas'),
|
||||
'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(),
|
||||
'query_filter' => [$this, 'query_filter'],
|
||||
]
|
||||
@ -286,9 +306,9 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'fields' => [
|
||||
'stage' => [
|
||||
'type' => 'select',
|
||||
'title' => __('Stage', 'wp-ultimo'),
|
||||
'placeholder' => __('Select Stage', 'wp-ultimo'),
|
||||
'desc' => __('The stage in the checking lifecycle of this domain.', 'wp-ultimo'),
|
||||
'title' => __('Stage', 'wp-multisite-waas'),
|
||||
'placeholder' => __('Select Stage', 'wp-multisite-waas'),
|
||||
'desc' => __('The stage in the checking lifecycle of this domain.', 'wp-multisite-waas'),
|
||||
'options' => Domain_Stage::to_array(),
|
||||
'value' => $this->get_object()->get_stage(),
|
||||
'wrapper_html_attr' => [
|
||||
@ -301,9 +321,9 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
],
|
||||
'blog_id' => [
|
||||
'type' => 'model',
|
||||
'title' => __('Site', 'wp-ultimo'),
|
||||
'placeholder' => __('Search Site...', 'wp-ultimo'),
|
||||
'desc' => __('The target site of this domain.', 'wp-ultimo'),
|
||||
'title' => __('Site', 'wp-multisite-waas'),
|
||||
'placeholder' => __('Search Site...', 'wp-multisite-waas'),
|
||||
'desc' => __('The target site of this domain.', 'wp-multisite-waas'),
|
||||
'value' => $this->get_object()->get_blog_id(),
|
||||
'tooltip' => '',
|
||||
'html_attr' => [
|
||||
@ -312,7 +332,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'data-label-field' => 'title',
|
||||
'data-search-field' => 'title',
|
||||
'data-max-items' => 1,
|
||||
'data-selected' => $this->get_object()->get_site() ? json_encode($this->get_object()->get_site()->to_search_results()) : '',
|
||||
'data-selected' => $this->get_object()->get_site() ? wp_json_encode($this->get_object()->get_site()->to_search_results()) : '',
|
||||
],
|
||||
'wrapper_html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
@ -322,12 +342,12 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
]
|
||||
);
|
||||
|
||||
$check_for_active_string = sprintf('%s.includes(stage)', json_encode(\WP_Ultimo\Models\Domain::INACTIVE_STAGES));
|
||||
$check_for_active_string = sprintf('%s.includes(stage)', wp_json_encode(\WP_Ultimo\Models\Domain::INACTIVE_STAGES));
|
||||
|
||||
$this->add_fields_widget(
|
||||
'basic',
|
||||
[
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'title' => __('Active', 'wp-multisite-waas'),
|
||||
'html_attr' => [
|
||||
'data-wu-app' => 'basic',
|
||||
'data-state' => wu_convert_to_state(
|
||||
@ -339,8 +359,8 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
'fields' => [
|
||||
'active' => [
|
||||
'type' => 'toggle',
|
||||
'title' => __('Active', 'wp-ultimo'),
|
||||
'desc' => __('Use this option to manually enable or disable this domain.', 'wp-ultimo'),
|
||||
'title' => __('Active', 'wp-multisite-waas'),
|
||||
'desc' => __('Use this option to manually enable or disable this domain.', 'wp-multisite-waas'),
|
||||
'value' => $this->get_object()->is_active(),
|
||||
'html_attr' => [
|
||||
'v-cloak' => '1',
|
||||
@ -353,7 +373,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
],
|
||||
'note' => [
|
||||
'type' => 'note',
|
||||
'desc' => __('This domain has a domain stage that forces it to be inactive. Change the status to Ready or Ready (without SSL) to be able to control the active status directly.', 'wp-ultimo'),
|
||||
'desc' => __('This domain has a domain stage that forces it to be inactive. Change the status to Ready or Ready (without SSL) to be able to control the active status directly.', 'wp-multisite-waas'),
|
||||
'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full',
|
||||
'wrapper_html_attr' => [
|
||||
'v-show' => $check_for_active_string,
|
||||
@ -406,7 +426,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_title() {
|
||||
|
||||
return $this->edit ? __('Edit Domain', 'wp-ultimo') : __('Add new Domain', 'wp-ultimo');
|
||||
return $this->edit ? __('Edit Domain', 'wp-multisite-waas') : __('Add new Domain', 'wp-multisite-waas');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -417,7 +437,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
*/
|
||||
public function get_menu_title() {
|
||||
|
||||
return __('Edit Domain', 'wp-ultimo');
|
||||
return __('Edit Domain', 'wp-multisite-waas');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -440,15 +460,15 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
public function get_labels() {
|
||||
|
||||
return [
|
||||
'edit_label' => __('Edit Domain', 'wp-ultimo'),
|
||||
'add_new_label' => __('Add new Domain', 'wp-ultimo'),
|
||||
'updated_message' => __('Domain updated with success!', 'wp-ultimo'),
|
||||
'title_placeholder' => __('Enter Domain', 'wp-ultimo'),
|
||||
'edit_label' => __('Edit Domain', 'wp-multisite-waas'),
|
||||
'add_new_label' => __('Add new Domain', 'wp-multisite-waas'),
|
||||
'updated_message' => __('Domain updated with success!', 'wp-multisite-waas'),
|
||||
'title_placeholder' => __('Enter Domain', 'wp-multisite-waas'),
|
||||
'title_description' => '',
|
||||
'save_button_label' => __('Save Domain', 'wp-ultimo'),
|
||||
'save_button_label' => __('Save Domain', 'wp-multisite-waas'),
|
||||
'save_description' => '',
|
||||
'delete_button_label' => __('Delete Domain', 'wp-ultimo'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'),
|
||||
'delete_button_label' => __('Delete Domain', 'wp-multisite-waas'),
|
||||
'delete_description' => __('Be careful. This action is irreversible.', 'wp-multisite-waas'),
|
||||
];
|
||||
}
|
||||
|
||||
@ -502,7 +522,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page {
|
||||
$item = wu_get_domain($item_id);
|
||||
|
||||
if ( ! $item) {
|
||||
wp_redirect(wu_network_admin_url('wp-ultimo-domains'));
|
||||
wp_safe_redirect(wu_network_admin_url('wp-ultimo-domains'));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
Reference in New Issue
Block a user